Interface SystemTagsManager


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 Details

    • create

      static SystemTagsManager create(MetricsConfig metricsConfig)
      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

      static SystemTagsManager instance()
      Returns the initialized instance of the tags manager.
      Returns:
      current instance of the tags manager
    • instance

      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 of instance().
      Parameters:
      metricsConfig - settings containing the global and app-level tags (if any)
      Returns:
      new (and saved) tags manager
    • onChange

      static void onChange(Consumer<SystemTagsManager> changeListener)
      Allows subscription to notification when a new system tags manager is created with a new configuration.
      Parameters:
      changeListener - subscriber to receive change notifications
    • scopeTag

      Optional<Tag> scopeTag(Optional<String> candidateScope)
      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

      Augments map entries (tag names and values) with, possibly, one more for the scope (if configured that way).
      Parameters:
      tags - original tags
      scope - the scope value
      Returns:
      augmented iterable including, if appropriate, a scope tag entry
    • withScopeTag

      Iterable<Tag> 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.
      Parameters:
      tags - original tags
      explicitScope - explicit scope setting if available
      Returns:
      tags containing a tag for the scope
    • withoutSystemTags

      Iterable<Tag> withoutSystemTags(Iterable<Tag> tags)
      Returns an Iterable of Tag 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

      Iterable<Tag> withoutSystemOrScopeTags(Iterable<Tag> tags)
      Returns an Iterable of Tag omitting system and scope tags.
      Parameters:
      tags - tags to filter
      Returns:
      tags without system or scope tags
    • displayTags

      Iterable<Tag> displayTags()
      Returns an Iterable of Tag representing the any system tags configured for display (for example, an app tag or global tags set through configuration).
      Returns:
      system tags
    • reservedTagNamesUsed

      Collection<String> reservedTagNamesUsed(Collection<String> tagNames)
      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

      void 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. This method is most useful to assign a tag to a meter if configuration implies that.
      Parameters:
      scope - scope value to use
      consumer - uses the tag and scope in some appropriate way
    • effectiveScope

      Optional<String> 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.
      Parameters:
      candidateScope - candidate scope
      Returns:
      effective scope, preferring the candidate and falling back to the default; empty if neither is present
    • effectiveScope

      Optional<String> 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.
      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

      Optional<String> scopeTagName()
      Returns the scope tag name derived from configuration.
      Returns:
      scope tag name; empty if not set