Object
Labels
- All Implemented Interfaces:
Comparable<Labels>,Iterable<Label>
Immutable set of name/value pairs, sorted by name.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCreate a new Labels instance containing the labels of this and the label passed as name and value.static Labels.Builderbuilder()intbooleanTest if these labels contain a specific label name.booleanGet the label value for a given label name.getName(int i) getPrometheusName(int i) LikegetName(int), but dots are replaced with underscores.getValue(int i) inthashCode()booleanhasSameNames(Labels other) booleanhasSameValues(Labels other) booleanisEmpty()iterator()Create a new Labels instance containing the labels of this and the labels of other.Create a new Labels instance containing the labels of this and the labels passed as names and values.static LabelsCreate a new Labels instance.static LabelsCreate a new Labels instance.static LabelsCreate a new Labels instance.intsize()stream()toString()This must not be used in Prometheus exposition formats because names may contain dots.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EMPTY
-
-
Method Details
-
isEmpty
-
of
Create a new Labels instance. You can either create Labels with one of the staticLabels.of(...)methods, or you can use thebuilder().- Parameters:
keyValuePairs- as in{name1, value1, name2, value2}. Length must be even.PrometheusNaming.isValidLabelName(String)must be true for each name. UsePrometheusNaming.sanitizeLabelName(String)to convert arbitrary strings to valid label names. Label names must be unique (no duplicate label names).
-
of
Create a new Labels instance. You can either create Labels with one of the staticLabels.of(...)methods, or you can use thebuilder().- Parameters:
names- label names.PrometheusNaming.isValidLabelName(String)must be true for each name. UsePrometheusNaming.sanitizeLabelName(String)to convert arbitrary strings to valid label names. Label names must be unique (no duplicate label names).values- label values.names.size()must be equal tovalues.size().
-
of
Create a new Labels instance. You can either create Labels with one of the staticLabels.of(...)methods, or you can use thebuilder().- Parameters:
names- label names.PrometheusNaming.isValidLabelName(String)must be true for each name. UsePrometheusNaming.sanitizeLabelName(String)to convert arbitrary strings to valid label names. Label names must be unique (no duplicate label names).values- label values.names.lengthmust be equal tovalues.length.
-
contains
Test if these labels contain a specific label name.Dots are treated as underscores, so
contains("my.label")andcontains("my_label")are the same. -
get
Get the label value for a given label name.Returns
nullif thelabelNameis not found.Dots are treated as underscores, so
get("my.label")andget("my_label")are the same. -
iterator
-
stream
-
size
-
getName
-
getPrometheusName
LikegetName(int), but dots are replaced with underscores.This is used by Prometheus exposition formats.
-
getValue
-
merge
Create a new Labels instance containing the labels of this and the labels of other. This and other must not contain the same label name. -
add
Create a new Labels instance containing the labels of this and the label passed as name and value. The label name must not already be contained in this Labels instance. -
merge
Create a new Labels instance containing the labels of this and the labels passed as names and values. The new label names must not already be contained in this Labels instance. -
hasSameNames
-
hasSameValues
-
compareTo
- Specified by:
compareToin interfaceComparable<Labels>
-
toString
This must not be used in Prometheus exposition formats because names may contain dots.However, for debugging it's better to show the original names rather than the Prometheus names.
-
equals
-
hashCode
-
builder
-