Add default factoryType tag in CommonsObjectPool2Metrics #5316
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.
Overview
This PR addresses the issue of Prometheus tag collision by introducing distinct metric name prefixes for different pool types in theCommonsObjectPool2Metrics
class. This change ensures that metrics fromGenericObjectPool
andGenericKeyedObjectPool
have unique names, preventing conflicts caused by differing tag sets.This PR addresses the issue of Prometheus tag collision by ensuring that all metrics have a consistent set of tags. For
GenericObjectPool
, afactoryType
tag is added, and for other pool types, a default value offactoryType=none
is used. This approach resolves the conflict caused by differing tag sets betweenGenericObjectPool
and other pool types.Changes
- Introduced distinct metric name prefixes:objectpool.
forGenericObjectPool
andkeyedobjectpool.
forGenericKeyedObjectPool
.- Updated theregisterMetricsEventually
method to apply the appropriate prefix based on the pool type.- Adjusted metric registration methods (registerGaugeForObject
,registerFunctionCounterForObject
,registerTimeGaugeForObject
) to use the new prefixes.factoryType=none
tag for all pool types exceptGenericObjectPool
.Reasoning
Prometheus requires that all meters with the same name have the same set of tag keys. The previous implementation violated this rule by adding a
factoryType
tag forGenericObjectPool
, which was not present in other pool types. This caused registration failures inPrometheusMeterRegistry
at this line. By ensuring that all metrics include a consistent set of tags, we eliminate tag collisions and comply with Prometheus' requirements.