Package co.elastic.apm.agent.metrics
Class MetricRegistry
- java.lang.Object
-
- co.elastic.apm.agent.metrics.MetricRegistry
-
public class MetricRegistry extends java.lang.ObjectA registry for metrics.Currently only holds gauges. There are plans to add support for histogram-based timers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMetricRegistry.MetricsReporter
-
Constructor Summary
Constructors Constructor Description MetricRegistry(ReporterConfiguration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String name, Labels labels, DoubleSupplier metric)Adds a gauge to the metric registry.voidaddUnlessNan(java.lang.String name, Labels labels, DoubleSupplier metric)Same asadd(String, Labels, DoubleSupplier)but only adds the metric if theDoubleSupplierdoes not returnDouble.NaNvoidaddUnlessNegative(java.lang.String name, Labels labels, DoubleSupplier metric)Same asadd(String, Labels, DoubleSupplier)but only adds the metric if theDoubleSupplierreturns a positive number or zero.voidflipPhaseAndReport(MetricRegistry.MetricsReporter metricsReporter)Executes the following steps within a single read-operation critical section: Switch between active and inactive MetricSet containers Report the inactivated MetricSets (optional) Reset the inactivated MetricSetsDoubleSuppliergetGauge(java.lang.String name, Labels labels)doublegetGaugeValue(java.lang.String name, Labels labels)voidincrementCounter(java.lang.String name, Labels labels)voidremoveGauge(java.lang.String metricName, Labels labels)voidupdateTimer(java.lang.String timerName, Labels labels, long durationUs)voidupdateTimer(java.lang.String timerName, Labels labels, long durationUs, long count)longwriterCriticalSectionEnter()voidwriterCriticalSectionExit(long criticalValueAtEnter)
-
-
-
Constructor Detail
-
MetricRegistry
public MetricRegistry(ReporterConfiguration config)
-
-
Method Detail
-
addUnlessNan
public void addUnlessNan(java.lang.String name, Labels labels, DoubleSupplier metric)Same asadd(String, Labels, DoubleSupplier)but only adds the metric if theDoubleSupplierdoes not returnDouble.NaN- Parameters:
name- the name of the metriclabels- labels for the metric. Tags can be used to create different graphs based for each value of a specific tag name, using a terms aggregation. Note that there will be aMetricSetcreated for each distinct set of labels.metric- this supplier will be called for every reporting cycle (metrics_interval))- See Also:
add(String, Labels, DoubleSupplier)
-
addUnlessNegative
public void addUnlessNegative(java.lang.String name, Labels labels, DoubleSupplier metric)Same asadd(String, Labels, DoubleSupplier)but only adds the metric if theDoubleSupplierreturns a positive number or zero.- Parameters:
name- the name of the metriclabels- labels for the metric. Tags can be used to create different graphs based for each value of a specific tag name, using a terms aggregation. Note that there will be aMetricSetcreated for each distinct set of labels.metric- this supplier will be called for every reporting cycle (metrics_interval))- See Also:
add(String, Labels, DoubleSupplier)
-
add
public void add(java.lang.String name, Labels labels, DoubleSupplier metric)Adds a gauge to the metric registry.- Parameters:
name- the name of the metriclabels- labels for the metric. Tags can be used to create different graphs based for each value of a specific tag name, using a terms aggregation. Note that there will be aMetricSetcreated for each distinct set of labels.metric- this supplier will be called for every reporting cycle (metrics_interval))
-
getGaugeValue
public double getGaugeValue(java.lang.String name, Labels labels)
-
getGauge
@Nullable public DoubleSupplier getGauge(java.lang.String name, Labels labels)
-
flipPhaseAndReport
public void flipPhaseAndReport(@Nullable MetricRegistry.MetricsReporter metricsReporter)Executes the following steps within a single read-operation critical section:- Switch between active and inactive MetricSet containers
- Report the inactivated MetricSets (optional)
- Reset the inactivated MetricSets
- Parameters:
metricsReporter- a reporter to be used for reporting the inactivated MetricSets. May benullif reporting is not required.
-
updateTimer
public void updateTimer(java.lang.String timerName, Labels labels, long durationUs)
-
updateTimer
public void updateTimer(java.lang.String timerName, Labels labels, long durationUs, long count)
-
incrementCounter
public void incrementCounter(java.lang.String name, Labels labels)
-
writerCriticalSectionEnter
public long writerCriticalSectionEnter()
- See Also:
WriterReaderPhaser.writerCriticalSectionEnter()
-
writerCriticalSectionExit
public void writerCriticalSectionExit(long criticalValueAtEnter)
- See Also:
WriterReaderPhaser.writerCriticalSectionExit(long)
-
removeGauge
public void removeGauge(java.lang.String metricName, Labels labels)
-
-