Class MetricName

  • All Implemented Interfaces:
    Comparable<MetricName>

    public class MetricName
    extends Object
    implements Comparable<MetricName>
    A metric name with the ability to include semantic tags. This replaces the previous style where metric names where strictly dot-separated strings.
    • Method Detail

      • empty

        public static MetricName empty()
        Returns an empty metric name.
        Returns:
        an empty metric name.
      • getKey

        public String getKey()
      • getTags

        public Map<String,​String> getTags()
        Returns the tags, sorted by key.
        Returns:
        the tags (immutable), sorted by key.
      • resolve

        public MetricName resolve​(String... parts)
        Build the MetricName that is this with another path appended to it. The new MetricName inherits the tags of this one.
        Parameters:
        parts - The extra path elements to add to the new metric.
        Returns:
        A new metric name relative to the original by the path specified in parts.
      • tagged

        public MetricName tagged​(Map<String,​String> add)
        Add tags to a metric name and return the newly created MetricName.
        Parameters:
        add - Tags to add.
        Returns:
        A newly created metric name with the specified tags associated with it.
      • tagged

        public MetricName tagged​(String... pairs)
        Same as tagged(Map), but takes a variadic list of arguments.
        Parameters:
        pairs - An even list of strings acting as key-value pairs.
        Returns:
        A newly created metric name with the specified tags associated with it.
        See Also:
        tagged(Map)
      • append

        public MetricName append​(MetricName append)
        Build the MetricName that is this with another path and tags appended to it.

        Semantically equivalent to:
        this.resolve(append.getKey()).tagged(append.getTags());

        Parameters:
        append - The extra name element to add to the new metric.
        Returns:
        A new metric name with path appended to the original, and tags included from both names.
      • build

        public static MetricName build​(String... parts)
        Build a new metric name using the specific path components.

        Equivalent to:
        MetricName.empty().resolve(parts);

        Parameters:
        parts - Path of the new metric name.
        Returns:
        A newly created metric name with the specified path.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object