Include global metrics in the per-request collector registry#956
Include global metrics in the per-request collector registry#956candlerb wants to merge 1 commit intoprometheus:mainfrom
Conversation
a2b1d10 to
99fa3dd
Compare
Fixes prometheus#950 Signed-off-by: Brian Candler <b.candler@pobox.com>
|
Aside: for some reason I get E-mail notifications of "golangci-lint workflow run" failing when I push to my own repo:
However, the checks in the pull request pass. |
|
Hmm, I'm not sure about this approach. I much prefer using promauto and passing a registry. If we need to init some metrics, it's better to loop over things with As for the labels, I'm on the fence. |
I think a global persistent registry makes a lot of sense, but I don't know how to do that given that the current architecture creates a disposable registry for every request, containing a dynamically-created collector: Perhaps Aside: I wondered briefly if this is a use case for Unregister but ruled it out, since there could be concurrent scrapes with different auth and module parameters. |
|
I figured it out, see #971. |
|
Being fixed in #971 |
This is a quick proof-of-concept fix for the zero metrics (
snmp_packet_duration_seconds_bucket/sum/count,snmp_unexpected_pdu_type_total,snmp_packets_total,snmp_packet_retries_total) and missing metrics (snmp_collection_duration_seconds_count/sum,snmp_request_errors_total)To consider:
snmp_collection_duration_seconds_count/sum(for every possible combination of auth and module, even those not being used?) Maybe this can be dropped given that Support fetching multiple modules in one scrape #945 will be introducing per-module scrape metrics?metricsmember from the Collector struct, and usingglobalMetricsdirectly wherever it's needed, instead of passing it around.Fixes #950