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