mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-22 01:21:06 +00:00
Update metrics
This commit is contained in:
parent
e377f3988b
commit
36aa9120ea
7 changed files with 40 additions and 73 deletions
73
Cargo.lock
generated
73
Cargo.lock
generated
|
@ -466,9 +466,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
|
|||
|
||||
[[package]]
|
||||
name = "async-cpupool"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba06506d5e5f2e45254bfb3175d5ca14b7dbb817cf0651cc2cc3a8b18a12c5a5"
|
||||
checksum = "6e8033cee1f97627591df5401e0f20496c1940dc935f3de8ddc642bf9cf836c9"
|
||||
dependencies = [
|
||||
"flume",
|
||||
"metrics",
|
||||
|
@ -561,9 +561,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "background-jobs"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0788884be043a6ea4812f533b53f47180f1fb68a45d6a1e7c9f55369f187bd9"
|
||||
checksum = "220c1b532c3b8532a43282f0871cf43d6238421f0e72084cb1f6ddb65fc0e8e6"
|
||||
dependencies = [
|
||||
"background-jobs-actix",
|
||||
"background-jobs-core",
|
||||
|
@ -571,9 +571,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "background-jobs-actix"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6918aac07d254c283e83e74d94d2a4137eb8eb2bb35749553b2aeedefc13243d"
|
||||
checksum = "d084a3dec6f0bd656a7c388e255e988a340b397985bfe7bebdb0ebebb34b50b6"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
"anyhow",
|
||||
|
@ -591,9 +591,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "background-jobs-core"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19188ccc4964d2d7ac0349ec05290b079c49a6218dc9a70516c9084790efc039"
|
||||
checksum = "c585c87a70e090f8f0b52cd25951ba156e7faca26464e11611fc6ab0d700815c"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
"anyhow",
|
||||
|
@ -1923,15 +1923,6 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "mach2"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplit"
|
||||
version = "1.0.2"
|
||||
|
@ -1987,20 +1978,19 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
|||
|
||||
[[package]]
|
||||
name = "metrics"
|
||||
version = "0.21.1"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5"
|
||||
checksum = "77b9e10a211c839210fd7f99954bda26e5f8e26ec686ad68da6a32df7c80e782"
|
||||
dependencies = [
|
||||
"ahash 0.8.7",
|
||||
"metrics-macros",
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "metrics-exporter-prometheus"
|
||||
version = "0.12.2"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950"
|
||||
checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea"
|
||||
dependencies = [
|
||||
"base64 0.21.5",
|
||||
"hyper",
|
||||
|
@ -2013,22 +2003,11 @@ dependencies = [
|
|||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "metrics-macros"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "metrics-util"
|
||||
version = "0.15.1"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e"
|
||||
checksum = "2670b8badcc285d486261e2e9f1615b506baff91427b61bd336a472b65bbf5ed"
|
||||
dependencies = [
|
||||
"aho-corasick 1.1.2",
|
||||
"crossbeam-epoch",
|
||||
|
@ -2037,7 +2016,7 @@ dependencies = [
|
|||
"indexmap 1.9.3",
|
||||
"metrics",
|
||||
"num_cpus",
|
||||
"ordered-float 3.9.2",
|
||||
"ordered-float",
|
||||
"quanta",
|
||||
"radix_trie",
|
||||
"sketches-ddsketch",
|
||||
|
@ -2350,7 +2329,7 @@ dependencies = [
|
|||
"glob",
|
||||
"once_cell",
|
||||
"opentelemetry",
|
||||
"ordered-float 4.2.0",
|
||||
"ordered-float",
|
||||
"percent-encoding",
|
||||
"rand",
|
||||
"thiserror",
|
||||
|
@ -2358,15 +2337,6 @@ dependencies = [
|
|||
"tokio-stream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "3.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "4.2.0"
|
||||
|
@ -2828,13 +2798,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quanta"
|
||||
version = "0.11.1"
|
||||
version = "0.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab"
|
||||
checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"libc",
|
||||
"mach2",
|
||||
"once_cell",
|
||||
"raw-cpuid",
|
||||
"wasi",
|
||||
|
@ -2899,11 +2868,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "10.7.0"
|
||||
version = "11.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
|
||||
checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -28,7 +28,7 @@ actix-webfinger = { version = "0.5.0", default-features = false }
|
|||
activitystreams = "0.7.0-alpha.25"
|
||||
activitystreams-ext = "0.1.0-alpha.3"
|
||||
ammonia = "3.1.0"
|
||||
async-cpupool = "0.1.0"
|
||||
async-cpupool = "0.2.0"
|
||||
bcrypt = "0.15"
|
||||
base64 = "0.21"
|
||||
clap = { version = "4.0.0", features = ["derive"] }
|
||||
|
@ -38,11 +38,11 @@ dashmap = "5.1.0"
|
|||
dotenv = "0.15.0"
|
||||
flume = "0.11.0"
|
||||
lru = "0.12.0"
|
||||
metrics = "0.21.0"
|
||||
metrics-exporter-prometheus = { version = "0.12.0", default-features = false, features = [
|
||||
metrics = "0.22.0"
|
||||
metrics-exporter-prometheus = { version = "0.13.0", default-features = false, features = [
|
||||
"http-listener",
|
||||
] }
|
||||
metrics-util = "0.15.0"
|
||||
metrics-util = "0.16.0"
|
||||
mime = "0.3.16"
|
||||
minify-html = "0.15.0"
|
||||
opentelemetry = "0.21"
|
||||
|
@ -50,7 +50,7 @@ opentelemetry_sdk = { version = "0.21", features = ["rt-tokio"] }
|
|||
opentelemetry-otlp = "0.14"
|
||||
pin-project-lite = "0.2.9"
|
||||
# pinned to metrics-util
|
||||
quanta = "0.11.0"
|
||||
quanta = "0.12.0"
|
||||
rand = "0.8"
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream"]}
|
||||
reqwest-middleware = "0.2"
|
||||
|
@ -85,7 +85,7 @@ uuid = { version = "1", features = ["v4", "serde"] }
|
|||
streem = "0.2.0"
|
||||
|
||||
[dependencies.background-jobs]
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
default-features = false
|
||||
features = ["background-jobs-actix", "error-logging"]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use metrics::{Key, Recorder, SetRecorderError};
|
||||
use metrics::{Key, Metadata, Recorder, SetRecorderError};
|
||||
use metrics_util::{
|
||||
registry::{AtomicStorage, GenerationalStorage, Recency, Registry},
|
||||
MetricKindMask, Summary,
|
||||
|
@ -360,8 +360,8 @@ impl MemoryCollector {
|
|||
d.entry(key.as_str().to_owned()).or_insert(description);
|
||||
}
|
||||
|
||||
pub(crate) fn install(&self) -> Result<(), SetRecorderError> {
|
||||
metrics::set_boxed_recorder(Box::new(self.clone()))
|
||||
pub(crate) fn install(&self) -> Result<(), SetRecorderError<Self>> {
|
||||
metrics::set_global_recorder(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,19 +393,19 @@ impl Recorder for MemoryCollector {
|
|||
self.add_description_if_missing(&key, description)
|
||||
}
|
||||
|
||||
fn register_counter(&self, key: &Key) -> metrics::Counter {
|
||||
fn register_counter(&self, key: &Key, _: &Metadata<'_>) -> metrics::Counter {
|
||||
self.inner
|
||||
.registry
|
||||
.get_or_create_counter(key, |c| c.clone().into())
|
||||
}
|
||||
|
||||
fn register_gauge(&self, key: &Key) -> metrics::Gauge {
|
||||
fn register_gauge(&self, key: &Key, _: &Metadata<'_>) -> metrics::Gauge {
|
||||
self.inner
|
||||
.registry
|
||||
.get_or_create_gauge(key, |c| c.clone().into())
|
||||
}
|
||||
|
||||
fn register_histogram(&self, key: &Key) -> metrics::Histogram {
|
||||
fn register_histogram(&self, key: &Key, _: &Metadata<'_>) -> metrics::Histogram {
|
||||
self.inner
|
||||
.registry
|
||||
.get_or_create_histogram(key, |c| c.clone().into())
|
||||
|
|
|
@ -200,10 +200,8 @@ impl FromRequest for Admin {
|
|||
Box::pin(async move {
|
||||
let (db, c, s, t) = res?;
|
||||
Self::verify(c, s, t).await?;
|
||||
metrics::histogram!(
|
||||
"relay.admin.verify",
|
||||
now.elapsed().as_micros() as f64 / 1_000_000_f64
|
||||
);
|
||||
metrics::histogram!("relay.admin.verify")
|
||||
.record(now.elapsed().as_micros() as f64 / 1_000_000_f64);
|
||||
Ok(Admin { db })
|
||||
})
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
.add_recorder(recorder)
|
||||
.add_recorder(collector.clone())
|
||||
.build();
|
||||
metrics::set_boxed_recorder(Box::new(recorder))?;
|
||||
metrics::set_global_recorder(recorder).map_err(|e| anyhow::anyhow!("{e}"))?;
|
||||
} else {
|
||||
collector.install()?;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Drop for LogOnDrop {
|
|||
fn drop(&mut self) {
|
||||
if self.arm {
|
||||
let duration = self.begin.elapsed();
|
||||
metrics::histogram!("relay.request.complete", duration, "path" => self.path.clone(), "method" => self.method.clone());
|
||||
metrics::histogram!("relay.request.complete", "path" => self.path.clone(), "method" => self.method.clone()).record(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ where
|
|||
{
|
||||
let id = uuid::Uuid::new_v4();
|
||||
|
||||
metrics::increment_counter!("relay.spawner.wait-timer.start");
|
||||
metrics::counter!("relay.spawner.wait-timer.start").increment(1);
|
||||
|
||||
let mut interval = actix_rt::time::interval(Duration::from_secs(5));
|
||||
|
||||
|
@ -47,12 +47,12 @@ where
|
|||
loop {
|
||||
tokio::select! {
|
||||
out = &mut fut => {
|
||||
metrics::increment_counter!("relay.spawner.wait-timer.end");
|
||||
metrics::counter!("relay.spawner.wait-timer.end").increment(1);
|
||||
return out;
|
||||
}
|
||||
_ = interval.tick() => {
|
||||
counter += 1;
|
||||
metrics::increment_counter!("relay.spawner.wait-timer.pending");
|
||||
metrics::counter!("relay.spawner.wait-timer.pending").increment(1);
|
||||
tracing::warn!("Blocking operation {id} is taking a long time, {} seconds", counter * 5);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue