Class AbstractMeterRegistry

  • All Implemented Interfaces:
    MeterRegistry
    Direct Known Subclasses:
    DropwizardMeterRegistry

    public abstract class AbstractMeterRegistry
    extends Object
    implements MeterRegistry
    Creates and manages your application's set of meters. Exporters use the meter registry to iterate over the set of meters instrumenting your application, and then further iterate over each meter's metrics, generally resulting in a time series in the metrics backend for each combination of metrics and dimensions.

    MeterRegistry may be used in a reactive context. As such, implementations must not negatively impact the calling thread, e.g. it should respond immediately by avoiding IO call, deep stack recursion or any coordination.

    ForgeRock changes:

    • Split this abstract class from the MeterRegister interface
    • Fix checkstyle errors
    • Constructor Detail

      • AbstractMeterRegistry

        protected AbstractMeterRegistry​(Clock clock)
        Creates an abstract meter registry.
        Parameters:
        clock - the clock to use for this meter registry
    • Method Detail

      • newGauge

        protected abstract <T> Gauge newGauge​(Meter.Id id,
                                              @Nullable
                                              T obj,
                                              ToDoubleFunction<T> valueFunction)
        Build a new gauge to be added to the registry. This is guaranteed to only be called if the gauge doesn't already exist.
        Type Parameters:
        T - The type of the state object from which the gauge value is extracted.
        Parameters:
        id - The id that uniquely identifies the gauge.
        obj - State object used to compute a value.
        valueFunction - Function that is applied on the value for the number.
        Returns:
        A new gauge.
      • newCounter

        protected abstract Counter newCounter​(Meter.Id id)
        Build a new counter to be added to the registry. This is guaranteed to only be called if the counter doesn't already exist.
        Parameters:
        id - The id that uniquely identifies the counter.
        Returns:
        A new counter.
      • newTimer

        protected abstract Timer newTimer​(Meter.Id id,
                                          HistogramConfig histogramConfig,
                                          PauseDetector pauseDetector)
        Build a new timer to be added to the registry. This is guaranteed to only be called if the timer doesn't already exist.
        Parameters:
        id - The id that uniquely identifies the timer.
        histogramConfig - the configuration for the histogram.
        pauseDetector - the pause detector.
        Returns:
        A new timer.
      • newDistributionSummary

        protected abstract DistributionSummary newDistributionSummary​(Meter.Id id,
                                                                      HistogramConfig histogramConfig)
        Build a new distribution summary to be added to the registry. This is guaranteed to only be called if the distribution summary doesn't already exist.
        Parameters:
        id - The id that uniquely identifies the distribution summary.
        histogramConfig - the configuration for the histogram.
        Returns:
        A new distribution summary.
      • newMeter

        protected abstract Meter newMeter​(Meter.Id id,
                                          Meter.Type type,
                                          Iterable<Measurement> measurements)
        Build a new custom meter to be added to the registry. This is guaranteed to only be called if the custom meter doesn't already exist.
        Parameters:
        id - The id that uniquely identifies the custom meter.
        type - The type of meter.
        measurements - the measurements.
        Returns:
        A new custom meter.
      • newTimeGauge

        protected <T> TimeGauge newTimeGauge​(Meter.Id id,
                                             T obj,
                                             TimeUnit valueFunctionUnit,
                                             ToDoubleFunction<T> valueFunction)
        Build a new time gauge to be added to the registry. This is guaranteed to only be called if the time gauge doesn't already exist.
        Type Parameters:
        T - The type of the state object from which the gauge value is extracted.
        Parameters:
        id - The id that uniquely identifies the time gauge.
        obj - State object used to compute a value.
        valueFunction - Function that is applied on the value for the number.
        valueFunctionUnit - the time unit of the value returned by the value function.
        Returns:
        A new time gauge.
      • getBaseTimeUnit

        protected abstract TimeUnit getBaseTimeUnit()
        The registry's base TimeUnit.
        Returns:
        the non-null registry's base TimeUnit.
      • defaultHistogramConfig

        protected abstract HistogramConfig defaultHistogramConfig()
        Every custom registry implementation should define a default histogram expiry.
         histogramConfig.builder().histogramExpiry(defaultStep).build().merge(HistogramConfig.DEFAULT);
         
        Returns:
        the configuration for the histogram.
      • register

        public Meter register​(Meter.Id id,
                              Meter.Type type,
                              Iterable<Measurement> measurements)
        Description copied from interface: MeterRegistry
        Register a custom meter type.
        Specified by:
        register in interface MeterRegistry
        Parameters:
        id - Id of the meter being registered.
        type - Meter type, which may be used by naming conventions to normalize the name.
        measurements - A sequence of measurements describing how to sample the meter.
        Returns:
        The registry.
      • deregisterMatching

        public void deregisterMatching​(MeterFilter filter)
        Description copied from interface: MeterRegistry
        Deregister meters matching the provided filter.
        Specified by:
        deregisterMatching in interface MeterRegistry
        Parameters:
        filter - a non-null meter filter
      • more

        public MeterRegistry.More more()
        Description copied from interface: MeterRegistry
        Access to less frequently used meter types and patterns.
        Specified by:
        more in interface MeterRegistry
        Returns:
        Access to additional meter types and patterns.