Package io.prometheus.client.exemplars
Class Exemplar
- java.lang.Object
-
- io.prometheus.client.exemplars.Exemplar
-
public class Exemplar extends java.lang.Object
Immutable data class holding an Exemplar.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.Pattern
labelNameRegex
private java.lang.String[]
labels
private java.lang.Long
timestampMs
private double
value
-
Constructor Summary
Constructors Constructor Description Exemplar(double value, java.lang.Long timestampMs, java.lang.String... labels)
Create an ExemplarExemplar(double value, java.lang.Long timestampMs, java.util.Map<java.lang.String,java.lang.String> labels)
Create an ExemplarExemplar(double value, java.lang.String... labels)
Create an Exemplar without a timestampExemplar(double value, java.util.Map<java.lang.String,java.lang.String> labels)
Create an Exemplar
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.lang.String
getLabelName(int i)
Get the label name at indexi
.java.lang.String
getLabelValue(int i)
Get the label value at indexi
.int
getNumberOfLabels()
java.lang.Long
getTimestampMs()
double
getValue()
int
hashCode()
static java.lang.String[]
mapToArray(java.util.Map<java.lang.String,java.lang.String> labelMap)
Convert the map to an array[key1, value1, key2, value2, ...]
.private java.lang.String[]
sortedCopy(java.lang.String... labels)
-
-
-
Constructor Detail
-
Exemplar
public Exemplar(double value, java.lang.String... labels)
Create an Exemplar without a timestamp- Parameters:
value
- the observed valuelabels
- name/value pairs. Expecting an even number of strings. The combined length of the label names and values must not exceed 128 UTF-8 characters. Neither a label name nor a label value may be null.
-
Exemplar
public Exemplar(double value, java.lang.Long timestampMs, java.lang.String... labels)
Create an Exemplar- Parameters:
value
- the observed valuetimestampMs
- as inSystem.currentTimeMillis()
labels
- name/value pairs. Expecting an even number of strings. The combined length of the label names and values must not exceed 128 UTF-8 characters. Neither a label name nor a label value may be null.
-
Exemplar
public Exemplar(double value, java.util.Map<java.lang.String,java.lang.String> labels)
Create an Exemplar- Parameters:
value
- the observed valuelabels
- the labels. Must not be null. The combined length of the label names and values must not exceed 128 UTF-8 characters. Neither a label name nor a label value may be null.
-
Exemplar
public Exemplar(double value, java.lang.Long timestampMs, java.util.Map<java.lang.String,java.lang.String> labels)
Create an Exemplar- Parameters:
value
- the observed valuetimestampMs
- as inSystem.currentTimeMillis()
labels
- the labels. Must not be null. The combined length of the label names and values must not exceed 128 UTF-8 characters. Neither a label name nor a label value may be null.
-
-
Method Detail
-
getNumberOfLabels
public int getNumberOfLabels()
-
getLabelName
public java.lang.String getLabelName(int i)
Get the label name at indexi
.- Parameters:
i
- the index, must be >= 0 and <getNumberOfLabels()
.- Returns:
- the label name at index
i
-
getLabelValue
public java.lang.String getLabelValue(int i)
Get the label value at indexi
.- Parameters:
i
- the index, must be >= 0 and <getNumberOfLabels()
.- Returns:
- the label value at index
i
-
getValue
public double getValue()
-
getTimestampMs
public java.lang.Long getTimestampMs()
- Returns:
- Unix timestamp or
null
if no timestamp is present.
-
sortedCopy
private java.lang.String[] sortedCopy(java.lang.String... labels)
-
mapToArray
public static java.lang.String[] mapToArray(java.util.Map<java.lang.String,java.lang.String> labelMap)
Convert the map to an array[key1, value1, key2, value2, ...]
.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-