public class Enumeration extends SimpleCollector<Enumeration.Child> implements Collector.Describable
Example enumeration:
class YourClass {
static final Enumeration taskState = Enumeration.build()
.name("task_state").help("State of the task.")
.states("stopped", "starting", "running")
.register();
void stop() {
// Your code here.
taskState.state("stopped")
}
}
You can also use a Java Enum:
class YourClass {
public enum yourEnum {
STOPPED,
STARTING,
RUNNING,
}
static final Enumeration taskState = Enumeration.build()
.name("task_state").help("State of the task.")
.states(yourEnum.class)
.register();
void stop() {
// Your code here.
taskState.state(yourEnum.STOPPED)
}
}
}
| Modifier and Type | Class and Description |
|---|---|
static class |
Enumeration.Builder |
static class |
Enumeration.Child
The value of a single Enumeration.
|
Collector.Describable, Collector.MetricFamilySamples, Collector.Typechildren, fullname, help, labelNames, noLabelsChild, unitMILLISECONDS_PER_SECOND, NANOSECONDS_PER_SECOND| Modifier and Type | Method and Description |
|---|---|
static Enumeration.Builder |
build()
Return a Builder to allow configuration of a new Enumeration.
|
static Enumeration.Builder |
build(String name,
String help)
Return a Builder to allow configuration of a new Enumeration.
|
List<Collector.MetricFamilySamples> |
collect()
Return all of the metrics of this Collector.
|
List<Collector.MetricFamilySamples> |
describe()
Provide a list of metric families this Collector is expected to return.
|
String |
get()
Get the value of the Enumeration.
|
protected Enumeration.Child |
newChild()
Return a new child, workaround for Java generics limitations.
|
void |
state(Enum e)
Set the state on the enum with no labels.
|
void |
state(String s)
Set the state on the enum with no labels.
|
clear, familySamplesList, initializeNoLabelsChild, labels, remove, setChildcheckMetricLabelName, checkMetricName, doubleToGoString, register, register, sanitizeMetricNamepublic static Enumeration.Builder build(String name, String help)
name - The name of the metrichelp - The help string of the metricpublic static Enumeration.Builder build()
protected Enumeration.Child newChild()
SimpleCollectornewChild in class SimpleCollector<Enumeration.Child>public List<Collector.MetricFamilySamples> collect()
Collectorpublic List<Collector.MetricFamilySamples> describe()
Collector.Describablecollect will be called at registration time instead of
describe. If this could cause problems, either implement a proper
describe, or if that's not practical have describe return an empty
list.describe in interface Collector.DescribableCopyright © 2021. All rights reserved.