Skip to content

Commit

Permalink
Document limitation on same name with different set of tag keys for P…
Browse files Browse the repository at this point in the history
…rometheusMeterRegistry

See gh-4622
  • Loading branch information
izeye committed Mar 31, 2024
1 parent c9792c5 commit d13d437
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/modules/ROOT/pages/implementations/prometheus.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,24 @@ The following example shows a Prometheus query to plot the duration of a long ta

.Simulated back-to-back long tasks with a fixed alert threshold.
image::implementations/prometheus-long-task-timer.png[Grafana-rendered Prometheus long task timer]

== 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 silently by default.
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]
----
registry.config().onMeterRegistrationFailed((id, reason) -> {
throw new IllegalArgumentException(reason);
});
----

Actually, the `PrometheusMeterRegistry` has a shortcut for this, so you can do the following to achieve the same:

[source,java]
----
registry.throwExceptionOnRegistrationFailure();
----

0 comments on commit d13d437

Please sign in to comment.