Package io.dropwizard.metrics5
Class MetricName
java.lang.Object
io.dropwizard.metrics5.MetricName
- All Implemented Interfaces:
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(MetricName append) Build the MetricName that is this with another path and tags appended to it.static MetricNameBuild a new metric name using the specific path components.intstatic MetricNameempty()Returns an empty metric name.booleangetKey()getTags()Returns the tags, sorted by key.inthashCode()static MetricNameParse a metric name from its string representation.Build the MetricName that is this with another path appended to it.Same astagged(Map), but takes a variadic list of arguments.Add tags to a metric name and return the newly created MetricName.toString()
-
Constructor Details
-
MetricName
-
-
Method Details
-
empty
Returns an empty metric name.- Returns:
- an empty metric name.
-
getKey
-
getTags
Returns the tags, sorted by key.- Returns:
- the tags (immutable), sorted by key.
-
resolve
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
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
Same astagged(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:
-
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
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.
-
toString
-
parse
Parse a metric name from its string representation.Format: "measurement,tag1=value1,tag2=value2" or just "measurement"
- Parameters:
metricNameString- the string representation of the metric name- Returns:
- the parsed MetricName
- Throws:
IllegalArgumentException- if the string cannot be parsed
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<MetricName>
-