Interface MetricsSystem
- All Superinterfaces:
BesuService
An interface for creating various Metrics components.
-
Method Summary
Modifier and TypeMethodDescriptiondefault CountercreateCounter(MetricCategory category, String name, String help) Creates a Counter.default voidcreateCounter(MetricCategory category, String name, String help, DoubleSupplier valueSupplier) Creates a Counter that gets its value from the specified supplier.default voidcreateGauge(MetricCategory category, String name, String help, DoubleSupplier valueSupplier) Creates a gauge for displaying double vales.voidcreateGuavaCacheCollector(MetricCategory category, String name, com.google.common.cache.Cache<?, ?> cache) Collect metrics from Guava cache.default HistogramcreateHistogram(MetricCategory category, String name, String help, double[] buckets) Creates a histogramdefault voidcreateIntegerGauge(MetricCategory category, String name, String help, IntSupplier valueSupplier) Creates a gauge for displaying integer values.createLabelledCounter(MetricCategory category, String name, String help, String... labelNames) Creates a Counter with assigned labels.createLabelledHistogram(MetricCategory category, String name, String help, double[] buckets, String... labelNames) Creates a histogram with assigned labelscreateLabelledSuppliedCounter(MetricCategory category, String name, String help, String... labelNames) Creates a Counter with assigned labels, that gets its values from suppliers.createLabelledSuppliedGauge(MetricCategory category, String name, String help, String... labelNames) Creates a Gauge with assigned labels, that gets its values from suppliers.createLabelledSuppliedSummary(MetricCategory category, String name, String help, String... labelNames) Create a summary with assigned labels, that is computed externally to this metric system.createLabelledTimer(MetricCategory category, String name, String help, String... labelNames) Creates a Timer with assigned labels.default voidcreateLongGauge(MetricCategory category, String name, String help, LongSupplier valueSupplier) Creates a gauge for displaying long values.createSimpleLabelledTimer(MetricCategory category, String name, String help, String... labelNames) Creates a simple Timer with assigned labels.default OperationTimercreateSimpleTimer(MetricCategory category, String name, String help) Creates a simple Timer.default voidcreateSummary(MetricCategory category, String name, String help, Supplier<ExternalSummary> summarySupplier) Create a summary that is computed externally to this metric system.default OperationTimercreateTimer(MetricCategory category, String name, String help) Creates a Timer.Provides an immutable view into the metric categories enabled for metric collection.default booleanisCategoryEnabled(MetricCategory category) Checks if a particular category of metrics is enabled.
-
Method Details
-
createCounter
Creates a Counter.- Parameters:
category- TheMetricCategorythis counter is assigned to.name- A name for this metric.help- A human readable description of the metric.- Returns:
- The created Counter instance.
-
createCounter
default void createCounter(MetricCategory category, String name, String help, DoubleSupplier valueSupplier) Creates a Counter that gets its value from the specified supplier. To be used when the value of the counter is calculated outside the metric system.- Parameters:
category- TheMetricCategorythis counter is assigned to.name- A name for this metric.help- A human readable description of the metric.valueSupplier- The supplier of the value.
-
createLabelledCounter
LabelledMetric<Counter> createLabelledCounter(MetricCategory category, String name, String help, String... labelNames) Creates a Counter with assigned labels.- Parameters:
category- TheMetricCategorythis counter is assigned to.name- A name for this metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the Counter.- Returns:
- The created LabelledMetric instance.
-
createLabelledSuppliedCounter
LabelledSuppliedMetric createLabelledSuppliedCounter(MetricCategory category, String name, String help, String... labelNames) Creates a Counter with assigned labels, that gets its values from suppliers. To be used when the values of the counter are calculated outside the metric system.- Parameters:
category- TheMetricCategorythis counter is assigned to.name- A name for this metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the Counter.- Returns:
- The created LabelledSupplierMetric instance.
-
createLabelledSuppliedGauge
LabelledSuppliedMetric createLabelledSuppliedGauge(MetricCategory category, String name, String help, String... labelNames) Creates a Gauge with assigned labels, that gets its values from suppliers. To be used when the values of the gauge are calculated outside the metric system.- Parameters:
category- TheMetricCategorythis gauge is assigned to.name- A name for this metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the Gauge.- Returns:
- The created LabelledGauge instance.
-
createTimer
Creates a Timer.- Parameters:
category- TheMetricCategorythis timer is assigned to.name- A name for this metric.help- A human readable description of the metric.- Returns:
- The created Timer instance.
-
createLabelledTimer
LabelledMetric<OperationTimer> createLabelledTimer(MetricCategory category, String name, String help, String... labelNames) Creates a Timer with assigned labels.- Parameters:
category- TheMetricCategorythis timer is assigned to.name- A name for this metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the Timer.- Returns:
- The created LabelledMetric instance.
-
createSimpleTimer
Creates a simple Timer.- Parameters:
category- TheMetricCategorythis timer is assigned to.name- A name for this metric.help- A human readable description of the metric.- Returns:
- The created Timer instance.
-
createSimpleLabelledTimer
LabelledMetric<OperationTimer> createSimpleLabelledTimer(MetricCategory category, String name, String help, String... labelNames) Creates a simple Timer with assigned labels.- Parameters:
category- TheMetricCategorythis timer is assigned to.name- A name for this metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the Timer.- Returns:
- The created Timer instance.
-
createGauge
default void createGauge(MetricCategory category, String name, String help, DoubleSupplier valueSupplier) Creates a gauge for displaying double vales. A gauge is a metric to report the current value. The metric value may go up or down.- Parameters:
category- TheMetricCategorythis gauge is assigned to.name- A name for this metric.help- A human readable description of the metric.valueSupplier- A supplier for the double value to be presented.
-
createIntegerGauge
default void createIntegerGauge(MetricCategory category, String name, String help, IntSupplier valueSupplier) Creates a gauge for displaying integer values.- Parameters:
category- TheMetricCategorythis gauge is assigned to.name- A name for this metric.help- A human readable description of the metric.valueSupplier- A supplier for the integer value to be presented.
-
createLongGauge
default void createLongGauge(MetricCategory category, String name, String help, LongSupplier valueSupplier) Creates a gauge for displaying long values.- Parameters:
category- TheMetricCategorythis gauge is assigned to.name- A name for this metric.help- A human readable description of the metric.valueSupplier- A supplier for the long value to be presented.
-
createLabelledHistogram
LabelledMetric<Histogram> createLabelledHistogram(MetricCategory category, String name, String help, double[] buckets, String... labelNames) Creates a histogram with assigned labels- Parameters:
category- TheMetricCategorythis histogram is assigned to.name- A name for this metric.help- A human-readable description of the metric.buckets- An array of buckets to assign to the histogramlabelNames- An array of labels to assign to the histogram.- Returns:
- The labelled histogram.
-
createHistogram
default Histogram createHistogram(MetricCategory category, String name, String help, double[] buckets) Creates a histogram- Parameters:
category- TheMetricCategorythis histogram is assigned to.name- A name for this metric.help- A human-readable description of the metric.buckets- An array of buckets to assign to the histogram- Returns:
- The labelled histogram.
-
createLabelledSuppliedSummary
LabelledSuppliedSummary createLabelledSuppliedSummary(MetricCategory category, String name, String help, String... labelNames) Create a summary with assigned labels, that is computed externally to this metric system. Useful when existing libraries calculate the summary data on their own, and we want to export that summary via the configured metric system. A notable example are RocksDB statistics.- Parameters:
category- TheMetricCategorythis external summary is assigned to.name- A name for the metric.help- A human readable description of the metric.labelNames- An array of labels to assign to the supplier summary.- Returns:
- The created labelled supplied summary
-
createSummary
default void createSummary(MetricCategory category, String name, String help, Supplier<ExternalSummary> summarySupplier) Create a summary that is computed externally to this metric system. Useful when existing libraries calculate the summary data on their own, and we want to export that summary via the configured metric system. A notable example are RocksDB statistics.- Parameters:
category- TheMetricCategorythis external summary is assigned to.name- A name for the metric.help- A human readable description of the metric.summarySupplier- A supplier to retrieve the summary data when needed.
-
createGuavaCacheCollector
void createGuavaCacheCollector(MetricCategory category, String name, com.google.common.cache.Cache<?, ?> cache) Collect metrics from Guava cache.- Parameters:
category- TheMetricCategorythis Guava cache is assigned to.name- the name to identify this Guava cache, must be unique.cache- the Guava cache
-
getEnabledCategories
Set<MetricCategory> getEnabledCategories()Provides an immutable view into the metric categories enabled for metric collection.- Returns:
- the set of enabled metric categories.
-
isCategoryEnabled
Checks if a particular category of metrics is enabled.- Parameters:
category- the category to check- Returns:
- true if the category is enabled, false otherwise
-