refactor: split telemetry module

This commit is contained in:
2026-06-13 06:38:33 +02:00
parent da910a88c7
commit 0f195de9e5
4 changed files with 122 additions and 119 deletions

18
tests/telemetry.rs Normal file
View File

@@ -0,0 +1,18 @@
use pokedex_api::telemetry::Telemetry;
use std::time::Duration;
#[test]
fn records_http_and_upstream_metrics_in_prometheus_text_format() {
let telemetry = Telemetry::new("test-service");
let metrics = telemetry.metrics();
metrics.record_http_request("GET", "/pokemon/{name}", 200, Duration::from_millis(10));
metrics.record_upstream_request("pokeapi", "pokemon_species", true, Duration::from_millis(5));
let rendered = telemetry
.render_prometheus()
.expect("metrics should render as text");
assert!(rendered.contains("http_server_requests"));
assert!(rendered.contains("upstream_client_requests"));
assert!(rendered.contains("service_name=\"test-service\""));
}