mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
fix prometheus timeout mask metrics
This commit is contained in:
parent
c4f645e03e
commit
40e33d8af1
7 changed files with 15 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -199,6 +199,7 @@ dependencies = [
|
|||
"log",
|
||||
"memchr",
|
||||
"metrics",
|
||||
"metrics-util",
|
||||
"mimalloc",
|
||||
"once_cell",
|
||||
"privdrop",
|
||||
|
|
@ -379,7 +380,6 @@ dependencies = [
|
|||
"indexmap 2.1.0",
|
||||
"log",
|
||||
"metrics",
|
||||
"metrics-exporter-prometheus",
|
||||
"metrics-util",
|
||||
"mimalloc",
|
||||
"privdrop",
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ impl CanonicalSocketAddr {
|
|||
pub fn spawn_prometheus_endpoint(
|
||||
addr: SocketAddr,
|
||||
timeout: Option<::std::time::Duration>,
|
||||
timeout_mask: Option<metrics_util::MetricKindMask>,
|
||||
) -> anyhow::Result<::std::thread::JoinHandle<anyhow::Result<()>>> {
|
||||
use std::thread::Builder;
|
||||
use std::time::Duration;
|
||||
|
|
@ -125,8 +126,10 @@ pub fn spawn_prometheus_endpoint(
|
|||
.context("build prometheus tokio runtime")?;
|
||||
|
||||
rt.block_on(async {
|
||||
let mask = timeout_mask.unwrap_or(MetricKindMask::ALL);
|
||||
|
||||
let (recorder, exporter) = PrometheusBuilder::new()
|
||||
.idle_timeout(MetricKindMask::ALL, timeout)
|
||||
.idle_timeout(mask, timeout)
|
||||
.with_http_listener(addr)
|
||||
.build()
|
||||
.context("build prometheus recorder and exporter")?;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ name = "aquatic_http"
|
|||
|
||||
[features]
|
||||
default = ["prometheus"]
|
||||
prometheus = ["aquatic_common/prometheus", "metrics"]
|
||||
prometheus = ["aquatic_common/prometheus", "metrics", "dep:metrics-util"]
|
||||
metrics = ["dep:metrics"]
|
||||
|
||||
[dependencies]
|
||||
|
|
@ -54,6 +54,7 @@ thiserror = "1"
|
|||
|
||||
# metrics feature
|
||||
metrics = { version = "0.22", optional = true }
|
||||
metrics-util = { version = "0.16", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "1"
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
|||
let handle = aquatic_common::spawn_prometheus_endpoint(
|
||||
config.metrics.prometheus_endpoint_address,
|
||||
Some(Duration::from_secs(idle_timeout)),
|
||||
Some(metrics_util::MetricKindMask::GAUGE),
|
||||
)?;
|
||||
|
||||
join_handles.push((WorkerType::Prometheus, handle));
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
|||
Some(Duration::from_secs(
|
||||
config.cleaning.torrent_cleaning_interval * 2,
|
||||
)),
|
||||
None,
|
||||
)?;
|
||||
|
||||
join_handles.push((WorkerType::Prometheus, handle));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ name = "aquatic_ws"
|
|||
[features]
|
||||
default = ["prometheus", "mimalloc"]
|
||||
prometheus = ["metrics", "aquatic_common/prometheus"]
|
||||
metrics = ["dep:metrics", "metrics-util"]
|
||||
metrics = ["dep:metrics", "dep:metrics-util"]
|
||||
# Use mimalloc allocator for much better performance. Requires cmake and a
|
||||
# C/C++ compiler
|
||||
mimalloc = ["dep:mimalloc"]
|
||||
|
|
@ -43,9 +43,6 @@ hashbrown = { version = "0.14", features = ["serde"] }
|
|||
httparse = "1"
|
||||
indexmap = "2"
|
||||
log = "0.4"
|
||||
metrics = { version = "0.22", optional = true }
|
||||
metrics-util = { version = "0.16", optional = true }
|
||||
metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] }
|
||||
mimalloc = { version = "0.1", default-features = false, optional = true }
|
||||
privdrop = "0.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
|
|
@ -58,6 +55,10 @@ slotmap = "1"
|
|||
socket2 = { version = "0.5", features = ["all"] }
|
||||
tungstenite = "0.21"
|
||||
|
||||
# metrics feature
|
||||
metrics = { version = "0.22", optional = true }
|
||||
metrics-util = { version = "0.16", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "1"
|
||||
quickcheck_macros = "1"
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
|||
let handle = aquatic_common::spawn_prometheus_endpoint(
|
||||
config.metrics.prometheus_endpoint_address,
|
||||
Some(Duration::from_secs(idle_timeout)),
|
||||
Some(metrics_util::MetricKindMask::GAUGE),
|
||||
)?;
|
||||
|
||||
join_handles.push((WorkerType::Prometheus, handle));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue