Package io.dropwizard.metrics5
Class MetricName
- java.lang.Object
-
- io.dropwizard.metrics5.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.
-
-
Constructor Summary
Constructors Constructor Description MetricName(String key, Map<String,String> tags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MetricName
append(MetricName append)
Build the MetricName that is this with another path and tags appended to it.static MetricName
build(String... parts)
Build a new metric name using the specific path components.int
compareTo(MetricName o)
static MetricName
empty()
Returns an empty metric name.boolean
equals(Object o)
String
getKey()
Map<String,String>
getTags()
Returns the tags, sorted by key.int
hashCode()
MetricName
resolve(String... parts)
Build the MetricName that is this with another path appended to it.MetricName
tagged(String... pairs)
Same astagged(Map)
, but takes a variadic list of arguments.MetricName
tagged(Map<String,String> add)
Add tags to a metric name and return the newly created MetricName.String
toString()
-
-
-
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 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:
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.
-
compareTo
public int compareTo(MetricName o)
- Specified by:
compareTo
in interfaceComparable<MetricName>
-
-