Hanaasagi / tokio-metrics-collector

Provides utilities for collecting Prometheus-compatible metrics from Tokio runtime and tasks.
https://crates.io/crates/tokio-metrics-collector
Apache License 2.0
21 stars 3 forks source link

example panics #4

Closed dizda closed 1 year ago

dizda commented 1 year ago

Hi there,

The provided example starts well and shows the information on the metrics page http://127.0.0.1:8000/metrics, but then panics at some point:

2023-05-02T09:35:27.129597Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-05-02T09:35:27.132073Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.132113Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
2023-05-02T09:35:27.133559Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.133587Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
2023-05-02T09:35:27.134570Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.134593Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
2023-05-02T09:35:27.135544Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.135570Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
2023-05-02T09:35:27.136488Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.136517Z DEBUG hyper::proto::h1::conn: incoming body is empty
thread 'tokio-runtime-worker' panicked at 'new: 0.000110958 >= past: 0.000119583', src/task.rs:272:9
2023-05-02T09:35:27.137841Z DEBUG hyper::proto::h1::io: parsed 12 headers
2023-05-02T09:35:27.137874Z DEBUG hyper::proto::h1::conn: incoming body is empty

This is in debug release. It panics after sending many requests to /send_email

Also I've noticed that instrumented_count doesn't decrease for "get_user".

# HELP tokio_task_instrumented_count The number of tasks instrumented.
# TYPE tokio_task_instrumented_count gauge
tokio_task_instrumented_count{task="email"} 1
tokio_task_instrumented_count{task="get_user"} 24
Hanaasagi commented 1 year ago

Thank you for the feedback. I will try to resolve this issue in the coming days.

Hanaasagi commented 1 year ago

About the first issue, I believe I demonstrated an incorrect usage in example/server.rs where a monitor with the same label should not be added repeatedly. This would cause data to overwrite each other.

https://github.com/Hanaasagi/tokio-metrics-collector/blob/fed5eeb184fddf96a86da5111f137e856bc54c50/examples/server.rs#L57-L60

About the second issue, this is indeed a bug where the values were calculated as Counter.

Fixed in https://github.com/Hanaasagi/tokio-metrics-collector/pull/5 and released 0.2.0. If there are any other problems, feel free to reopen this issue.

dizda commented 1 year ago

Thank you @Hanaasagi, will give it a try!

dizda commented 1 year ago

Thanks @Hanaasagi it doesn't crash anymore.