public class MetricId extends Object implements Comparable<MetricId>
Instances of this class are immutable. There are methods that copy-then-modify MetricId's, these should be used sparingly and not in performance critical sections since they are slow.
If you find the need to mutate a MetricId frequently, consider using MetricIdMutator
which will cache values for you.
This replaces the previous style where metric names where strictly dot-separated strings.
| Modifier and Type | Field and Description |
|---|---|
static MetricId |
EMPTY |
static SortedMap<String,String> |
EMPTY_TAGS |
static String |
SEPARATOR |
| Constructor and Description |
|---|
MetricId() |
MetricId(String key) |
MetricId(String key,
Map<String,String> tags) |
| Modifier and Type | Method and Description |
|---|---|
static MetricId |
build(String... parts)
Build a new metric name using the specific path components.
|
int |
compareTo(MetricId o) |
boolean |
equals(Object obj) |
String |
getKey()
Get the current key of the metric id.
|
Map<String,String> |
getTags()
Get the current set of tags.
|
int |
hashCode() |
static MetricId |
join(MetricId... parts)
Join the specified set of metric names.
|
MetricId |
resolve(String part)
Build the MetricName that is this with another path appended to it.
|
MetricId |
tagged(Map<String,String> add)
Add tags to a metric name and return the newly created MetricName.
|
MetricId |
tagged(String... pairs)
Same as
tagged(Map), but takes a variadic list of arguments. |
String |
toString() |
public static final String SEPARATOR
public static final MetricId EMPTY
public MetricId()
public MetricId(String key)
public String getKey()
public Map<String,String> getTags()
public MetricId resolve(String part)
The new MetricName inherits the tags of this one.
part - The extra path element to add to the new metric.public MetricId tagged(Map<String,String> add)
add - Tags to add.public MetricId tagged(String... pairs)
tagged(Map), but takes a variadic list of arguments.pairs - An even list of strings acting as key-value pairs.tagged(Map)public static MetricId join(MetricId... parts)
parts - Multiple metric names to join using the separator.public static MetricId build(String... parts)
parts - Path of the new metric name.public int compareTo(MetricId o)
compareTo in interface Comparable<MetricId>Copyright © 2017. All rights reserved.