Class MetricsContainer
-
- All Implemented Interfaces:
public class MetricsContainerMetricsContainergathers and exports metrics from Jitsi components.
-
-
Field Summary
Fields Modifier and Type Field Description private BooleancheckForNameConflictsprivate final StringjsonStringprivate final CollectorRegistryregistryprivate final Stringnamespace
-
Constructor Summary
Constructors Constructor Description MetricsContainer(CollectorRegistry registry, String namespace)MetricsContainer(CollectorRegistry registry)MetricsContainer()
-
Method Summary
Modifier and Type Method Description final BooleangetCheckForNameConflicts()Defines the behavior when registering a metric with a name in use by an existing metric. final UnitsetCheckForNameConflicts(Boolean checkForNameConflicts)Defines the behavior when registering a metric with a name in use by an existing metric. StringgetJsonString()final CollectorRegistrygetRegistry()the registry used to register metrics final StringgetNamespace()Namespace prefix added to all metrics. StringgetPrometheusMetrics(String contentType)Returns the metrics in this instance in the Prometheus text-based format. final BooleanMetricregisterBooleanMetric(String name, String help, Boolean initialValue)Creates and registers a BooleanMetric with the given name, help string and optional initialValue. final BooleanMetricregisterBooleanMetric(String name, String help)Creates and registers a BooleanMetric with the given name, help string and optional initialValue. final CounterMetricregisterCounter(String name, String help, Long initialValue)Creates and registers a CounterMetric with the given name, help string and optional initialValue. final CounterMetricregisterCounter(String name, String help)Creates and registers a CounterMetric with the given name, help string and optional initialValue. final LongGaugeMetricregisterLongGauge(String name, String help, Long initialValue)Creates and registers a LongGaugeMetric with the given name, help string and optional initialValue. final LongGaugeMetricregisterLongGauge(String name, String help)Creates and registers a LongGaugeMetric with the given name, help string and optional initialValue. final DoubleGaugeMetricregisterDoubleGauge(String name, String help, Double initialValue)Creates and registers a DoubleGaugeMetric with the given name, help string and optional initialValue. final DoubleGaugeMetricregisterDoubleGauge(String name, String help)Creates and registers a DoubleGaugeMetric with the given name, help string and optional initialValue. final InfoMetricregisterInfo(String name, String help, String value)Creates and registers an InfoMetric with the given name, help string and value. final HistogramMetricregisterHistogram(String name, String help, Double buckets)final UnitresetAll()Resets all metrics in this container to their default values. -
-
Constructor Detail
-
MetricsContainer
MetricsContainer(CollectorRegistry registry, String namespace)
-
MetricsContainer
MetricsContainer(CollectorRegistry registry)
-
MetricsContainer
MetricsContainer()
-
-
Method Detail
-
getCheckForNameConflicts
final Boolean getCheckForNameConflicts()
Defines the behavior when registering a metric with a name in use by an existing metric. Useful for testing. Defaults to
true.If
true, throws an exception if a metric with a given name already exists. Iffalse, attempts to return the existing metric, throwing an exception if there is a type mismatch.
-
setCheckForNameConflicts
final Unit setCheckForNameConflicts(Boolean checkForNameConflicts)
Defines the behavior when registering a metric with a name in use by an existing metric. Useful for testing. Defaults to
true.If
true, throws an exception if a metric with a given name already exists. Iffalse, attempts to return the existing metric, throwing an exception if there is a type mismatch.
-
getJsonString
String getJsonString()
-
getRegistry
final CollectorRegistry getRegistry()
the registry used to register metrics
-
getNamespace
final String getNamespace()
Namespace prefix added to all metrics.
-
getPrometheusMetrics
String getPrometheusMetrics(String contentType)
Returns the metrics in this instance in the Prometheus text-based format. See Formats.
- Parameters:
contentType- the Content-Type header string- Returns:
the metrics in this instance in the Prometheus text-based format
-
registerBooleanMetric
@JvmOverloads() final BooleanMetric registerBooleanMetric(String name, String help, Boolean initialValue)
Creates and registers a BooleanMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerBooleanMetric
@JvmOverloads() final BooleanMetric registerBooleanMetric(String name, String help)
Creates and registers a BooleanMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerCounter
@JvmOverloads() final CounterMetric registerCounter(String name, String help, Long initialValue)
Creates and registers a CounterMetric with the given name, help string and optional initialValue. If omitted, a "_total" suffix is added to the metric name to ensure consistent (Counter) metric naming.
Throws an exception if a metric with the same name but a different type exists.
-
registerCounter
@JvmOverloads() final CounterMetric registerCounter(String name, String help)
Creates and registers a CounterMetric with the given name, help string and optional initialValue. If omitted, a "_total" suffix is added to the metric name to ensure consistent (Counter) metric naming.
Throws an exception if a metric with the same name but a different type exists.
-
registerLongGauge
@JvmOverloads() final LongGaugeMetric registerLongGauge(String name, String help, Long initialValue)
Creates and registers a LongGaugeMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerLongGauge
@JvmOverloads() final LongGaugeMetric registerLongGauge(String name, String help)
Creates and registers a LongGaugeMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerDoubleGauge
@JvmOverloads() final DoubleGaugeMetric registerDoubleGauge(String name, String help, Double initialValue)
Creates and registers a DoubleGaugeMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerDoubleGauge
@JvmOverloads() final DoubleGaugeMetric registerDoubleGauge(String name, String help)
Creates and registers a DoubleGaugeMetric with the given name, help string and optional initialValue.
Throws an exception if a metric with the same name but a different type exists.
-
registerInfo
final InfoMetric registerInfo(String name, String help, String value)
Creates and registers an InfoMetric with the given name, help string and value.
Throws an exception if a metric with the same name but a different type exists.
-
registerHistogram
final HistogramMetric registerHistogram(String name, String help, Double buckets)
-
-
-
-