-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[prometheus-metrics-instrumentation-caffeine] Cannot register multiple Caffeine cache #1174
Comments
I am having a similar issue, although I am able to recreate it without even creating a cache: private val cacheMetrics = new CacheMetricsCollector()
PrometheusRegistry.defaultRegistry.register(cacheMetrics) is sufficient to reproduce the error:
|
Hey @kaustubhDsarathi & @ChrisMcD1, could you check if the old, simpleclient_caffeine CacheMetricCollector is registered via the simpleclient-bridge? This could indeed cause this error, as the metric names are the same for both. Regarding the documentation: correct, this was a mistake on my side when migrating the CacheMetricCollector. The register method does not exist anymore |
I have identified that my problem was user error! I had my cache being created and registered inside of a class that our dependency injection framework was instantiating twice. Fixing that and making it instantiated once fixed it for me, and I am happily getting metrics! |
I guess I should ask the question though, should having two |
This is the intended behavior of the prometheus client in general. E.g. if you register any other metric twice, an error would be thrown as well (e.g. you cannot have two counters with the same name). In the end some other library / user could create a metric with the same name and not the |
@pheyken any reason why |
Tested again using the |
Context:
I'm using prometheus-metrics-instrumentation-caffeine to instrument my caffeine cache.
After running the application and accessing the metrics, I'm getting the following error



caffeine_cache_estimated_size: duplicate metric name.
There is no mention in the Javadoc whether we can provide different names to the collector also the

register()
method seems to be missing in the actual codeAs a workaround, I'm currently manually registering the Gauge objects in PrometheusMeterRegistry
Is there a way we can instrument multiple Cache objects using
CacheMetricsCollector
?The text was updated successfully, but these errors were encountered: