spans on the stat add function
This commit is contained in:
parent
dc4b6d501c
commit
d4518cd2bf
@ -48,6 +48,7 @@ check-if-email-exists = "0.9.0"
|
|||||||
chrono = { version = "0.4.26" }
|
chrono = { version = "0.4.26" }
|
||||||
console-subscriber = { version = "0.1.10", features = ["env-filter", "parking_lot"], optional = true }
|
console-subscriber = { version = "0.1.10", features = ["env-filter", "parking_lot"], optional = true }
|
||||||
counter = "0.5.7"
|
counter = "0.5.7"
|
||||||
|
derivative = "2.2.0"
|
||||||
derive_more = { version = "0.99.17", features = ["nightly"] }
|
derive_more = { version = "0.99.17", features = ["nightly"] }
|
||||||
ethbloom = { version = "0.13.0" }
|
ethbloom = { version = "0.13.0" }
|
||||||
ethers = { version = "2.0.8", default-features = false, features = ["rustls", "ws"] }
|
ethers = { version = "2.0.8", default-features = false, features = ["rustls", "ws"] }
|
||||||
@ -83,6 +84,7 @@ rust_decimal = { version = "1.30.0", features = ["maths"] }
|
|||||||
sentry = { version = "0.31.5", default-features = false, features = ["anyhow", "backtrace", "contexts", "panic", "reqwest", "rustls", "serde_json", "tracing"] }
|
sentry = { version = "0.31.5", default-features = false, features = ["anyhow", "backtrace", "contexts", "panic", "reqwest", "rustls", "serde_json", "tracing"] }
|
||||||
sentry-tracing = "0.31.5"
|
sentry-tracing = "0.31.5"
|
||||||
serde = { version = "1.0.173" }
|
serde = { version = "1.0.173" }
|
||||||
|
serde-inline-default = "0.1.1"
|
||||||
serde_json = { version = "1.0.103", default-features = false, features = ["raw_value"] }
|
serde_json = { version = "1.0.103", default-features = false, features = ["raw_value"] }
|
||||||
serde_prometheus = "0.2.3"
|
serde_prometheus = "0.2.3"
|
||||||
strum = { version = "0.25.0", features = ["derive"] }
|
strum = { version = "0.25.0", features = ["derive"] }
|
||||||
@ -102,8 +104,6 @@ uuid = { version = "1.4.1", default-features = false, features = ["fast-rng", "v
|
|||||||
|
|
||||||
# TODO: why doesn't this work in dev-dependencies
|
# TODO: why doesn't this work in dev-dependencies
|
||||||
test-log = { version = "0.2.12", default-features = false, features = ["trace"] }
|
test-log = { version = "0.2.12", default-features = false, features = ["trace"] }
|
||||||
serde-inline-default = "0.1.1"
|
|
||||||
derivative = "2.2.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.10"
|
env_logger = "0.10"
|
||||||
|
@ -13,7 +13,7 @@ use migration::sea_orm::prelude::Decimal;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::{broadcast, mpsc, oneshot};
|
use tokio::sync::{broadcast, mpsc, oneshot};
|
||||||
use tokio::time::{interval, sleep};
|
use tokio::time::{interval, sleep};
|
||||||
use tracing::{error, info, trace, warn};
|
use tracing::{error, info, trace, warn, Instrument};
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@ -277,29 +277,46 @@ impl StatBuffer {
|
|||||||
|
|
||||||
let accounting_key = stat.accounting_key(self.billing_period_seconds);
|
let accounting_key = stat.accounting_key(self.billing_period_seconds);
|
||||||
if accounting_key.is_registered() {
|
if accounting_key.is_registered() {
|
||||||
|
let span = tracing::trace_span!(
|
||||||
|
"accounting",
|
||||||
|
key = tracing::field::debug(&accounting_key)
|
||||||
|
)
|
||||||
|
.or_current();
|
||||||
self.accounting_db_buffer
|
self.accounting_db_buffer
|
||||||
.entry(accounting_key)
|
.entry(accounting_key)
|
||||||
.or_default()
|
.or_default()
|
||||||
.add(stat.clone(), approximate_balance_remaining)
|
.add(stat.clone(), approximate_balance_remaining)
|
||||||
|
.instrument(span)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.influxdb_client.is_some() {
|
if self.influxdb_client.is_some() {
|
||||||
if let Some(opt_in_timeseries_key) = stat.owned_timeseries_key(active_premium) {
|
if let Some(opt_in_timeseries_key) = stat.owned_timeseries_key(active_premium) {
|
||||||
|
let span = tracing::trace_span!(
|
||||||
|
"owned_timeseries",
|
||||||
|
key = tracing::field::debug(&opt_in_timeseries_key)
|
||||||
|
)
|
||||||
|
.or_current();
|
||||||
self.opt_in_timeseries_buffer
|
self.opt_in_timeseries_buffer
|
||||||
.entry(opt_in_timeseries_key)
|
.entry(opt_in_timeseries_key)
|
||||||
.or_default()
|
.or_default()
|
||||||
.add(stat.clone(), approximate_balance_remaining)
|
.add(stat.clone(), approximate_balance_remaining)
|
||||||
|
.instrument(span)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let global_timeseries_key = stat.global_timeseries_key();
|
let global_timeseries_key = stat.global_timeseries_key();
|
||||||
|
let span = tracing::trace_span!(
|
||||||
|
"global_timeseries",
|
||||||
|
key = tracing::field::debug(&global_timeseries_key)
|
||||||
|
)
|
||||||
|
.or_current();
|
||||||
self.global_timeseries_buffer
|
self.global_timeseries_buffer
|
||||||
.entry(global_timeseries_key)
|
.entry(global_timeseries_key)
|
||||||
.or_default()
|
.or_default()
|
||||||
.add(stat, approximate_balance_remaining)
|
.add(stat, approximate_balance_remaining)
|
||||||
|
.instrument(span)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user