You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by piotrpio January 2, 2024
I am writing a custom exporter with collectors discovering and adding new metrics based on response from the server. Up until now, we were simply sending a single request when the exporter starts up and based on the response we were adding metrics and then registering collectors. However, we have a use case where not all metrics we may want to track are available when the exporter first starts, so I would like to be able to add new metrics to the collector during scrape (basically in Collect()).
Simply creating e.g. NewGaugeVec() with config for the new metric seems to work, but there is a problem when I try to unregister the collector - since I added new metrics and those are exposed in my Describe() implementation, the collectorID calculated in func (r *Registry) Unregister(c Collector) bool will be different from the one calculated when first registering the collector. Because of that, the collector is never removed from collectors map in Registry (https://github.com/prometheus/client_golang/blob/main/prometheus/registry.go#L383).
Is my approach to the problem even valid? If so, do you have any suggestions how this problem can be solved?
The text was updated successfully, but these errors were encountered:
Discussed in #1421
Originally posted by piotrpio January 2, 2024
I am writing a custom exporter with collectors discovering and adding new metrics based on response from the server. Up until now, we were simply sending a single request when the exporter starts up and based on the response we were adding metrics and then registering collectors. However, we have a use case where not all metrics we may want to track are available when the exporter first starts, so I would like to be able to add new metrics to the collector during scrape (basically in
Collect()
).Simply creating e.g.
NewGaugeVec()
with config for the new metric seems to work, but there is a problem when I try to unregister the collector - since I added new metrics and those are exposed in myDescribe()
implementation, thecollectorID
calculated infunc (r *Registry) Unregister(c Collector) bool
will be different from the one calculated when first registering the collector. Because of that, the collector is never removed from collectors map inRegistry
(https://github.com/prometheus/client_golang/blob/main/prometheus/registry.go#L383).Is my approach to the problem even valid? If so, do you have any suggestions how this problem can be solved?
The text was updated successfully, but these errors were encountered: