Closed CinchBlue closed 1 year ago
The calls to counter!
(or any other macro for emitting a metric) will register a metric if it doesn't yet exist, so the call to register_counter!
is extraneous here.
I am using metrics-prometheus
which allows for freezing metrics after a certain point: https://docs.rs/metrics-prometheus/0.3.1/metrics_prometheus/struct.FreezableRecorder.html
This allows downstream consumers of libraries that use metrics
to only listen to the metrics that they desire, and then disallow the reporting of other metrics that are not specified.
Because there is not a way to pre-specify the labels without creating the default metric, you'll need to pay the cost of having this default metric if you do not have a good default value for all of your labels.
You could potentially work around this with configuration on the consumer/agent side, but that's not ideal.
Admittedly, taking a quick look at metrics_prometheus::FreezableRecorder
... it looks like you'd have to register the precise metrics that you want (i.e. the labels would need to be populated).
Registering a metric, and having it immediately show up despite not yet having been emitted, is pretty fundamental. It's not something that we would change on the metrics
side, at least.
Ok, that sounds reasonable. Thanks.
Currently using
metrics
andmetrics-prometheus
andprometheus
.Consider:
when the metrics report is generated, you get:
This is not so great because there's the extra "default" metric
is there a way to not have to have this? I know the set of labels but not the full set of values.