Package org.eclipse.microprofile.metrics
Class MetricID
java.lang.Object
org.eclipse.microprofile.metrics.MetricID
- All Implemented Interfaces:
Comparable<MetricID>
A unique identifier for
Metric and Metadata that are registered in the MetricRegistry
The MetricID contains:
Name: (Required) The name of the metric.Tags: (Optional) The tags (represented byTagobjects) of the metric. 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompares 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 lexicographicallybooleangetName()Returns the Metric name associated with this MetricIDgetTags()Returns the underlying map containing the tags.Tag[]Gets the list of tags as an array ofTagobjects.Gets the list of tags as a list ofTagobjectsGets the list of tags as a single String in the format 'key="value",key2="value2",...'inthashCode()toString()
-
Constructor Details
-
MetricID
Constructs a MetricID with the given metric name and no tags. If global tags are available then they will be appended to this MetricID.- Parameters:
name- the name of the metric
-
MetricID
Constructs a MetricID with the given metric name andTags. If global tags are available then they will be appended to this MetricID- Parameters:
name- the name of the metrictags- the tags associated with this metric
-
-
Method Details
-
getName
Returns the Metric name associated with this MetricID- Returns:
- the Metric name associated with this MetricID
-
getTags
Returns the underlying map containing the tags.- Returns:
- a
Mapof tags
-
getTagsAsString
Gets the list of tags as a single String in the format 'key="value",key2="value2",...'- Returns:
- a String containing the tags
-
getTagsAsList
Gets the list of tags as a list ofTagobjects- Returns:
- a a list of Tag objects
-
getTagsAsArray
Gets the list of tags as an array ofTagobjects.- Returns:
- An array of tags
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
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:
compareToin interfaceComparable<MetricID>- Parameters:
other- the other MetricID
-