public interface SystemTagsManager
Deals with global, app-level, and scope to be included in the external representation (output and IDs in delegate
meter registries) for all metrics.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assignScope
(String scope, Function<Tag, ?> consumer) Invokes the specified consumer with the scope tag name setting from the configuration (if present) and the provided scope value.static SystemTagsManager
create
(MetricsConfig metricsConfig) Creates a new system tags manager using the provided metrics settings.effectiveScope
(Optional<String> candidateScope) Returns the effective scope, given the provided candidate scope combined with any default scope value in the configuration which initialized this manager.effectiveScope
(Optional<String> explicitScope, Iterable<Tag> tags) Returns the effective scope, given the provided explicit setting and tags (which might specify the scope) combined with any default scope value in the configuration which was used to initialize this system tags manager.static SystemTagsManager
instance()
Returns the initialized instance of the tags manager.static SystemTagsManager
instance
(MetricsConfig metricsConfig) Creates a new system tags manager using the provide metrics settings, saving the new instance as the initialized singleton which will be returned to subsequent invocations ofinstance()
.static void
onChange
(Consumer<SystemTagsManager> changeListener) Allows subscription to notification when a new system tags manager is created with a new configuration.reservedTagNamesUsed
(Collection<String> tagNames) Scans the provided tag names and throws an exception if any is a reserved tag name.Returns a scope tag so long as the candidate scope or configured default scope are present and the scope tag name is configured.Returns the scope tag name derived from configuration.withoutSystemOrScopeTags
(Iterable<Tag> tags) withoutSystemTags
(Iterable<Tag> tags) withScopeTag
(Iterable<Tag> tags, Optional<String> explicitScope) Augments, if necessary, the provided tags with an additional tag with the scope tag name and value from the explicit scope provided, an existing tag, or the default scope value, if configured.Augments map entries (tag names and values) with, possibly, one more for the scope (if configured that way).
-
Method Details
-
create
Creates a new system tags manager using the provided metrics settings.- Parameters:
metricsConfig
- settings containing the global and app-level tags (if any)- Returns:
- new tags manager
-
instance
Returns the initialized instance of the tags manager.- Returns:
- current instance of the tags manager
-
instance
Creates a new system tags manager using the provide metrics settings, saving the new instance as the initialized singleton which will be returned to subsequent invocations ofinstance()
.- Parameters:
metricsConfig
- settings containing the global and app-level tags (if any)- Returns:
- new (and saved) tags manager
-
onChange
Allows subscription to notification when a new system tags manager is created with a new configuration.- Parameters:
changeListener
- subscriber to receive change notifications
-
scopeTag
Returns a scope tag so long as the candidate scope or configured default scope are present and the scope tag name is configured.- Parameters:
candidateScope
- candidate scope value- Returns:
Tag
representing the scope if suitable; empty otherwise
-
withScopeTag
Iterable<Map.Entry<String,String>> withScopeTag(Iterable<Map.Entry<String, String>> tags, String scope) Augments map entries (tag names and values) with, possibly, one more for the scope (if configured that way).- Parameters:
tags
- original tagsscope
- the scope value- Returns:
- augmented iterable including, if appropriate, a scope tag entry
-
withScopeTag
Augments, if necessary, the provided tags with an additional tag with the scope tag name and value from the explicit scope provided, an existing tag, or the default scope value, if configured.- Parameters:
tags
- original tagsexplicitScope
- explicit scope setting if available- Returns:
- tags containing a tag for the scope
-
withoutSystemTags
Returns anIterable
ofTag
omitting any system tags but including the scope tag, if these appear in the provided tags.- Parameters:
tags
- tags to filter- Returns:
- tags without the system tags
-
withoutSystemOrScopeTags
- Parameters:
tags
- tags to filter- Returns:
- tags without system or scope tags
-
displayTags
Returns anIterable
ofTag
representing the any system tags configured for display (for example, an app tag or global tags set through configuration).- Returns:
- system tags
-
reservedTagNamesUsed
Scans the provided tag names and throws an exception if any is a reserved tag name.- Parameters:
tagNames
- tag names- Returns:
- reserved tag names present in the provided tag names
-
assignScope
Invokes the specified consumer with the scope tag name setting from the configuration (if present) and the provided scope value. This method is most useful to assign a tag to a meter if configuration implies that.- Parameters:
scope
- scope value to useconsumer
- uses the tag and scope in some appropriate way
-
effectiveScope
Returns the effective scope, given the provided candidate scope combined with any default scope value in the configuration which initialized this manager.- Parameters:
candidateScope
- candidate scope- Returns:
- effective scope, preferring the candidate and falling back to the default; empty if neither is present
-
effectiveScope
Returns the effective scope, given the provided explicit setting and tags (which might specify the scope) combined with any default scope value in the configuration which was used to initialize this system tags manager.- Parameters:
explicitScope
- explicit scope to use (if present)tags
- tag which might specify the scope using the configured scope tag name- Returns:
- effective scope; empty if none available from the arguments or the system default
-
scopeTagName
Returns the scope tag name derived from configuration.- Returns:
- scope tag name; empty if not set
-