Open
Description
Issue
During periods of inactivity, after the idle_timeout
period, metrics are correctly no longer exported. However, if these same metrics become active again, they are not re-exported.
This is problematic for my use case since my server provides long-lived streams with periods of activity lasting 15 minutes and then long periods of inactivity (>90 minutes). Additionally, even without supporting long-lived streams, clients can connect anytime before data is available, which would trigger the same idle timeout -> not re-exported issue.
Example
Currently I'm constructing and installing a prometheus push gateway exporter (with VictoriaMetrics instead of Prometheus):
PrometheusBuilder::new()
.with_push_gateway(addr, Duration::from_secs(1))
.expect("invalid push gateway endpoint")
.idle_timeout(
MetricKindMask::COUNTER | MetricKindMask::HISTOGRAM | MetricKindMask::GAUGE,
Some(Duration::from_secs(30 * 60)), // 30 minutes
)
.install()
.expect("failed to install prometheus exporter");
Timeline
- @ 0m
- client connects to server
- client is assigned a long-lived stream with
stream_id=A
- metrics for
stream_id=A
start being exported (all 0s)
- @ 30m
- idle timeout kicks in
- metrics for
stream_id=A
no longer exported
- @ 60m
- data is available
- client's long-lived stream with
stream_id=A
starts receiving data - metrics not re-exported = no metrics for long-lived stream with
stream_id=A
being exported
Crate Versions
I'm currently using the following (which are a tiny bit out of date if that matters):
metrics = "0.20.1"
metrics-exporter-prometheus = { version = "0.11.0", features = ["push-gateway"] }
metrics-util = "0.14.0"