mirror of https://github.com/telemt/telemt.git
metrics: export telemt_build_info version metric
This commit is contained in:
parent
f6704d7d65
commit
873618ce53
|
|
@ -234,6 +234,14 @@ async fn render_metrics(stats: &Stats, config: &ProxyConfig, ip_tracker: &UserIp
|
||||||
let me_allows_normal = telemetry.me_level.allows_normal();
|
let me_allows_normal = telemetry.me_level.allows_normal();
|
||||||
let me_allows_debug = telemetry.me_level.allows_debug();
|
let me_allows_debug = telemetry.me_level.allows_debug();
|
||||||
|
|
||||||
|
let _ = writeln!(out, "# HELP telemt_build_info Build information for the running telemt binary");
|
||||||
|
let _ = writeln!(out, "# TYPE telemt_build_info gauge");
|
||||||
|
let _ = writeln!(
|
||||||
|
out,
|
||||||
|
"telemt_build_info{{version=\"{}\"}} 1",
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
|
||||||
let _ = writeln!(out, "# HELP telemt_uptime_seconds Proxy uptime");
|
let _ = writeln!(out, "# HELP telemt_uptime_seconds Proxy uptime");
|
||||||
let _ = writeln!(out, "# TYPE telemt_uptime_seconds gauge");
|
let _ = writeln!(out, "# TYPE telemt_uptime_seconds gauge");
|
||||||
let _ = writeln!(out, "telemt_uptime_seconds {:.1}", stats.uptime_secs());
|
let _ = writeln!(out, "telemt_uptime_seconds {:.1}", stats.uptime_secs());
|
||||||
|
|
@ -2679,6 +2687,10 @@ mod tests {
|
||||||
|
|
||||||
let output = render_metrics(&stats, &config, &tracker).await;
|
let output = render_metrics(&stats, &config, &tracker).await;
|
||||||
|
|
||||||
|
assert!(output.contains(&format!(
|
||||||
|
"telemt_build_info{{version=\"{}\"}} 1",
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
)));
|
||||||
assert!(output.contains("telemt_connections_total 2"));
|
assert!(output.contains("telemt_connections_total 2"));
|
||||||
assert!(output.contains("telemt_connections_bad_total 1"));
|
assert!(output.contains("telemt_connections_bad_total 1"));
|
||||||
assert!(output.contains("telemt_handshake_timeouts_total 1"));
|
assert!(output.contains("telemt_handshake_timeouts_total 1"));
|
||||||
|
|
@ -2768,6 +2780,7 @@ mod tests {
|
||||||
let tracker = UserIpTracker::new();
|
let tracker = UserIpTracker::new();
|
||||||
let config = ProxyConfig::default();
|
let config = ProxyConfig::default();
|
||||||
let output = render_metrics(&stats, &config, &tracker).await;
|
let output = render_metrics(&stats, &config, &tracker).await;
|
||||||
|
assert!(output.contains("# TYPE telemt_build_info gauge"));
|
||||||
assert!(output.contains("# TYPE telemt_uptime_seconds gauge"));
|
assert!(output.contains("# TYPE telemt_uptime_seconds gauge"));
|
||||||
assert!(output.contains("# TYPE telemt_connections_total counter"));
|
assert!(output.contains("# TYPE telemt_connections_total counter"));
|
||||||
assert!(output.contains("# TYPE telemt_connections_bad_total counter"));
|
assert!(output.contains("# TYPE telemt_connections_bad_total counter"));
|
||||||
|
|
@ -2822,6 +2835,10 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.contains("telemt_connections_total 3")
|
.contains("telemt_connections_total 3")
|
||||||
);
|
);
|
||||||
|
assert!(std::str::from_utf8(body.as_ref()).unwrap().contains(&format!(
|
||||||
|
"telemt_build_info{{version=\"{}\"}} 1",
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
)));
|
||||||
|
|
||||||
config.general.beobachten = true;
|
config.general.beobachten = true;
|
||||||
config.general.beobachten_minutes = 10;
|
config.general.beobachten_minutes = 10;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue