Class MetricRegistry


  • public class MetricRegistry
    extends java.lang.Object
    A registry for metrics.

    Currently only holds gauges. There are plans to add support for histogram-based timers.

    • Method Detail

      • 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 metric
        labels - 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 a MetricSet created 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)
      • 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 be null if 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)