From 318faae064892c15355a3f8cd53af9f7e801bdf8 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 10 Jan 2025 08:49:42 +0900 Subject: [PATCH] Polish gh-5751 (#5760) --- .../ROOT/pages/implementations/prometheus.adoc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/modules/ROOT/pages/implementations/prometheus.adoc b/docs/modules/ROOT/pages/implementations/prometheus.adoc index 5f0df1f3df..00c440abee 100644 --- a/docs/modules/ROOT/pages/implementations/prometheus.adoc +++ b/docs/modules/ROOT/pages/implementations/prometheus.adoc @@ -133,26 +133,25 @@ image::implementations/prometheus-long-task-timer.png[Grafana-rendered Prometheu == Limitation on same name with different set of tag keys The `PrometheusMeterRegistry` doesn't allow to create meters having the same name with a different set of tag keys, so you should guarantee that meters having the same name have the same set of tag keys. -Otherwise, subsequent meters having the same name with a different set of tag keys will not be registered. This means that you should not do things like: +Otherwise, subsequent meters having the same name with a different set of tag keys will not be registered silently by default. +This means that you should not do things like: + [source,java] ---- // Please don't do this registry.counter("test", "first", "1").increment(); registry.counter("test", "second", "2").increment(); ---- -This will result in the following warning and the second `Meter` will not be registered: -[source] ----- -WARNING: The meter (MeterId{name='test', tags=[tag(second=2)]}) registration has failed: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'test' containing tag keys [first]. The meter you are attempting to register has keys [second]. Note that subsequent logs will be logged at debug level. ----- + Instead you can do something like this: + [source,java] ---- registry.counter("test", "first", "1", "second", "none").increment(); registry.counter("test", "first", "none", "second", "2").increment(); ---- -You can change the default warning behavior by registering a meter registration failed listener. +You can change the default behavior by registering a meter registration failed listener. For example, you can register a meter registration failed listener that throws an exception as follows: [source,java]