Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Cache telemetry collectors per registry #20

Open
turbolent opened this issue Mar 18, 2018 · 0 comments
Open

Cache telemetry collectors per registry #20

turbolent opened this issue Mar 18, 2018 · 0 comments

Comments

@turbolent
Copy link

turbolent commented Mar 18, 2018

Currently theTelemetry caches collectors (counters, histograms, and gauges):

https://github.com/samstarling/finagle-prometheus/blob/master/src/main/scala/com/samstarling/prometheusfinagle/metrics/Telemetry.scala#L10

However, that doesn't prevent a user from creating multiple instances of Telemetry for the same registry and attempting to register an object which is already registered:

Caused by: java.lang.IllegalArgumentException: Collector already registered that provides name: test
    at io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:54)
    at io.prometheus.client.SimpleCollector$Builder.register(SimpleCollector.java:245)
    at com.samstarling.prometheusfinagle.metrics.Telemetry.$anonfun$counter$1(Telemetry.scala:28)
    at scala.collection.concurrent.TrieMap.getOrElseUpdate(TrieMap.scala:903)
    at com.samstarling.prometheusfinagle.metrics.Telemetry.counter(Telemetry.scala:28)

The caching should take the registry into account, not only the object name and namespace. It seems currently not possible to get a previously registered collection from CollectorRegistry (no method available and namesToCollectors is unfortunately not exposed)

@turbolent turbolent changed the title Cache telemetry objects per registry Cache telemetry collectors per registry Mar 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant