We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I wrote a little sample program, the whole source is here: https://github.com/kolloch/debug-opentelemetry-poem
use std::time::Duration; use eyre::Context; use opentelemetry::sdk::{metrics::{controllers, processors, selectors}, export::metrics::aggregation}; use poem::{Server, listener::TcpListener, Route, get, EndpointExt, middleware::OpenTelemetryMetrics, handler, web::Path, endpoint::PrometheusExporter}; use tokio::time::sleep; #[tokio::main] async fn main() -> color_eyre::Result<()> { let prometheus_controller = controllers::basic( processors::factory( selectors::simple::histogram([1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 70.0, 100.0, 200.0, 300.0, 400.0, 500.0, 700.0, 1000.0, 1500.0, 3000.0]), aggregation::cumulative_temporality_selector(), ) .with_memory(true), ) .build(); println!("Starting server at localhost:8080"); Server::new(TcpListener::bind("localhost:8080")) .run( Route::new() .at("/hello/:name", get(hello)) .nest("/prometheus_metrics", PrometheusExporter::with_controller(prometheus_controller)) .with(OpenTelemetryMetrics::new())) .await .context("while running public API")?; Ok(()) } #[handler] async fn hello(Path(name): Path<String>) -> String { sleep(Duration::from_millis(100)).await; format!("hello: {}", name) }
If I perform some requests, e.g. by reloading http://localhost:8080/hello/program a couple of times. I expect plausible values for poem_request_duration_ms_bucket in http://localhost:8080/prometheus_metrics afterwards.
poem_request_duration_ms_bucket
That means that all requests should take at least 100 ms -- because of the sleep.
Instead, the counters for all buckets in the
# HELP poem_request_duration_ms request duration histogram (in milliseconds, since start of service) # TYPE poem_request_duration_ms histogram poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="1"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="2"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="5"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="10"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="20"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="50"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="70"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="100"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="200"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="300"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="400"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="500"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="700"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="1000"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="1500"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="3000"} 11 poem_request_duration_ms_bucket{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service",le="+Inf"} 11 poem_request_duration_ms_sum{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service"} 0.001111163905 poem_request_duration_ms_count{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service"} 11 # HELP poem_requests_count total request count (since start of service) # TYPE poem_requests_count counter poem_requests_count{http_method="GET",http_status_code="200",http_url="/hello/program",service_name="unknown_service"} 11
cargo run
opentelemetry
prometheus
Thanks a lot!
The text was updated successfully, but these errors were encountered:
I added a test showing that the underlying libraries should be fine: https://github.com/kolloch/debug-opentelemetry-poem/blob/main/tests/correct_metric_values.rs
(basically, it is a stripped down version of the code that poem uses here)
Sorry, something went wrong.
Fixes poem-web#448. opentelemetry_metrics: Correct duration conversion
f5fada1
from seconds to milliseconds.
fb7cbe7
No branches or pull requests
Expected Behavior
I wrote a little sample program, the whole source is here: https://github.com/kolloch/debug-opentelemetry-poem
If I perform some requests, e.g. by reloading http://localhost:8080/hello/program a couple of times. I expect plausible values for
poem_request_duration_ms_bucket
in http://localhost:8080/prometheus_metrics afterwards.That means that all requests should take at least 100 ms -- because of the sleep.
Actual Behavior
Instead, the counters for all buckets in the
Steps to Reproduce the Problem
cargo run
Specifications
opentelemetry
/prometheus
Thanks a lot!
The text was updated successfully, but these errors were encountered: