tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.04k stars 182 forks source link

Don't panic in `with_label_values` #517

Closed JellyWX closed 4 months ago

JellyWX commented 4 months ago

Currently, with_label_values panics if the cardinality is incorrect: https://github.com/tikv/rust-prometheus/blob/f49c724df0e123520554664436da68e555593af0/src/counter.rs#L287

It would be better if this returned a Result<Self, Error> which can then be handled by the user

JellyWX commented 4 months ago

Looks like I should be using get_metric_with_label_values