Package org.eclipse.microprofile.metrics
Class MetricID
- java.lang.Object
-
- org.eclipse.microprofile.metrics.MetricID
-
- All Implemented Interfaces:
java.lang.Comparable<MetricID>
public class MetricID extends java.lang.Object implements java.lang.Comparable<MetricID>
A unique identifier forMetric
andMetadata
that are registered in theMetricRegistry
The MetricID contains:-
Name
: (Required) The name of the metric. -
Tags
: (Optional) The tags (represented byTag
objects) of the metric which is augmented by global tags (if available). The tag name must match the regex `[a-zA-Z_][a-zA-Z0-9_]*` (Ascii alphabet, numbers and underscore). The tag value may contain any UTF-8 encoded character. Global tags can be set by passing the list of tags in an environment variableMP_METRICS_TAGS
. Tag values set through `MP_METRICS_TAGS` MUST escape equal symbols `=` and commas `,` with a backslash `\` For example, the following can be used to set the global tags:export MP_METRICS_TAGS=app=shop,tier=integration,special=deli\=ver\,y
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPLICATION_NAME_TAG
static java.lang.String
APPLICATION_NAME_VARIABLE
static java.lang.String
GLOBAL_TAGS_VARIABLE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(MetricID other)
Compares two MetricID objects through the following steps:
Compares the names of the two MetricIDs lexicographically.boolean
equals(java.lang.Object o)
java.lang.String
getName()
Returns the Metric name associated with this MetricIDjava.util.Map<java.lang.String,java.lang.String>
getTags()
Returns the underlying map containing the tags.java.util.List<Tag>
getTagsAsList()
Gets the list of tags as a list ofTag
objectsjava.lang.String
getTagsAsString()
Gets the list of tags as a single String in the format 'key="value",key2="value2",...'int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
GLOBAL_TAGS_VARIABLE
public static final java.lang.String GLOBAL_TAGS_VARIABLE
- See Also:
- Constant Field Values
-
APPLICATION_NAME_VARIABLE
public static final java.lang.String APPLICATION_NAME_VARIABLE
- See Also:
- Constant Field Values
-
APPLICATION_NAME_TAG
public static final java.lang.String APPLICATION_NAME_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the Metric name associated with this MetricID- Returns:
- the Metric name associated with this MetricID
-
getTags
public java.util.Map<java.lang.String,java.lang.String> getTags()
Returns the underlying map containing the tags.- Returns:
- a
Map
of tags
-
getTagsAsString
public java.lang.String getTagsAsString()
Gets the list of tags as a single String in the format 'key="value",key2="value2",...'- Returns:
- a String containing the tags
-
getTagsAsList
public java.util.List<Tag> getTagsAsList()
Gets the list of tags as a list ofTag
objects- Returns:
- a a list of Tag objects
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(MetricID other)
Compares two MetricID objects through the following steps:
- Compares the names of the two MetricIDs lexicographically.
- If the names are equal: Compare the number of tags.
-
If the tag lengths are equal: Compare the Tags (sorted by the Tag's key value)
- a) Compare the Tag names/keys lexicographically
- b) If keys are equal, compare the Tag values lexicographically
- Specified by:
compareTo
in interfacejava.lang.Comparable<MetricID>
- Parameters:
other
- the other MetricID
-
-