java.lang.Object
io.prometheus.metrics.core.metrics.Metric
io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
io.prometheus.metrics.core.metrics.StatefulMetric<StateSetDataPoint,io.prometheus.metrics.core.metrics.StateSet.DataPoint>
io.prometheus.metrics.core.metrics.StateSet
- All Implemented Interfaces:
DataPoint,StateSetDataPoint,io.prometheus.metrics.model.registry.Collector
public class StateSet
extends StatefulMetric<StateSetDataPoint,io.prometheus.metrics.core.metrics.StateSet.DataPoint>
implements StateSetDataPoint
StateSet metric. Example:
public enum Feature {
FEATURE_1("feature1"),
FEATURE_2("feature2");
private final String name;
Feature(String name) {
this.name = name;
}
// Override
public String toString() {
return name;
}
}
public static void main(String[] args) {
StateSet stateSet = StateSet.builder()
.name("feature_flags")
.help("Feature flags")
.labelNames("env")
.states(Feature.class)
.register();
stateSet.labelValues("dev").setFalse(FEATURE_1);
stateSet.labelValues("dev").setTrue(FEATURE_2);
}
The example above shows how to use a StateSet with an enum. You don't have to use enum, you can
use regular strings as well.-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
labelNamesFields inherited from class io.prometheus.metrics.core.metrics.Metric
constLabels -
Method Summary
Modifier and TypeMethodDescriptionstatic StateSet.Builderbuilder()static StateSet.Builderbuilder(io.prometheus.metrics.config.PrometheusProperties config) io.prometheus.metrics.model.snapshots.StateSetSnapshotcollect()protected io.prometheus.metrics.model.snapshots.StateSetSnapshotcollect(List<io.prometheus.metrics.model.snapshots.Labels> labels, List<io.prometheus.metrics.core.metrics.StateSet.DataPoint> metricDataList) labels and metricData have the same size. labels.get(i) are the labels for metricData.get(i).protected io.prometheus.metrics.core.metrics.StateSet.DataPointvoidstatemust be one of the states from when theStateSetwas created withStateSet.Builder.states(String...).voidstatemust be one of the states from when theStateSetwas created withStateSet.Builder.states(String...).Methods inherited from class io.prometheus.metrics.core.metrics.StatefulMetric
clear, getConfigProperty, getMetricProperties, getNoLabels, initLabelValues, labelValues, remove, removeIfMethods inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata
getMetadata, getPrometheusNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.prometheus.metrics.model.registry.Collector
collect, collect, collectMethods inherited from interface io.prometheus.metrics.core.datapoints.StateSetDataPoint
setFalse, setTrue
-
Method Details
-
collect
public io.prometheus.metrics.model.snapshots.StateSetSnapshot collect()- Specified by:
collectin interfaceio.prometheus.metrics.model.registry.Collector- Overrides:
collectin classStatefulMetric<StateSetDataPoint,io.prometheus.metrics.core.metrics.StateSet.DataPoint>
-
collect
protected io.prometheus.metrics.model.snapshots.StateSetSnapshot collect(List<io.prometheus.metrics.model.snapshots.Labels> labels, List<io.prometheus.metrics.core.metrics.StateSet.DataPoint> metricDataList) Description copied from class:StatefulMetriclabels and metricData have the same size. labels.get(i) are the labels for metricData.get(i).- Specified by:
collectin classStatefulMetric<StateSetDataPoint,io.prometheus.metrics.core.metrics.StateSet.DataPoint>
-
setTrue
Description copied from interface:StateSetDataPointstatemust be one of the states from when theStateSetwas created withStateSet.Builder.states(String...).- Specified by:
setTruein interfaceStateSetDataPoint
-
setFalse
Description copied from interface:StateSetDataPointstatemust be one of the states from when theStateSetwas created withStateSet.Builder.states(String...).- Specified by:
setFalsein interfaceStateSetDataPoint
-
newDataPoint
protected io.prometheus.metrics.core.metrics.StateSet.DataPoint newDataPoint()- Specified by:
newDataPointin classStatefulMetric<StateSetDataPoint,io.prometheus.metrics.core.metrics.StateSet.DataPoint>
-
builder
-
builder
-