Prevent name conflicts and rename jvm_classes_loaded #681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ClassLoadingExports
collector provides aGauge
namedjvm_classes_loaded
and aCounter
namedjvm_classes_loaded_total
. This is an illegal name conflict in OpenMetrics, and this is also the root cause for prometheus/jmx_exporter#621.This PR renames
jvm_classes_loaded
tojvm_classes_currently_loaded
.This is a breaking change. Prometheus queries referencing
jvm_classes_loaded
need to be adapted to the new namejvm_classes_currently_loaded
.Moreover, the PR adds a check in
CollectorRegistry.register(Collector)
to prevent collectors with such name conflicts from being registered.The check will be performed if the
Collector
implementsCollector.Describable
, or ifCollectorRegistry.autoDescribe
istrue
(it'strue
by default for theCollectorRegistry.defaultRegistry
andfalse
by default for custom registries).