Skip to content

Commit 612b996

Browse files
authored
Document limitation on same name with different set of tag keys for PrometheusMeterRegistry (#4878)
See gh-4622
1 parent c9792c5 commit 612b996

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/modules/ROOT/pages/implementations/prometheus.adoc

+21
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,24 @@ The following example shows a Prometheus query to plot the duration of a long ta
154154

155155
.Simulated back-to-back long tasks with a fixed alert threshold.
156156
image::implementations/prometheus-long-task-timer.png[Grafana-rendered Prometheus long task timer]
157+
158+
== Limitation on same name with different set of tag keys
159+
160+
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.
161+
Otherwise, subsequent meters having the same name with a different set of tag keys will not be registered silently by default.
162+
You can change the default behavior by registering a meter registration failed listener.
163+
For example, you can register a meter registration failed listener that throws an exception as follows:
164+
165+
[source,java]
166+
----
167+
registry.config().onMeterRegistrationFailed((id, reason) -> {
168+
throw new IllegalArgumentException(reason);
169+
});
170+
----
171+
172+
Actually, the `PrometheusMeterRegistry` has a shortcut for this, so you can do the following to achieve the same:
173+
174+
[source,java]
175+
----
176+
registry.throwExceptionOnRegistrationFailure();
177+
----

0 commit comments

Comments
 (0)