Class Registry

java.lang.Object
io.helidon.metrics.api.AbstractRegistry<io.helidon.metrics.HelidonMetric>
io.helidon.metrics.Registry
All Implemented Interfaces:
MetricRegistry

public class Registry extends AbstractRegistry<io.helidon.metrics.HelidonMetric>
Metrics registry.
  • Constructor Details

    • Registry

      protected Registry(MetricRegistry.Type type, RegistrySettings registrySettings)
      Creates a new instance.
      Parameters:
      type - registry type for the new registry
      registrySettings - registry settings to influence the created registry
  • Method Details

    • create

      public static Registry create(MetricRegistry.Type type, RegistrySettings registrySettings)
      Create a registry of a certain type.
      Parameters:
      type - Registry type.
      registrySettings - Registry settings to use in creating the registry.
      Returns:
      The newly created registry.
    • update

      public void update(RegistrySettings registrySettings)
      Description copied from class: AbstractRegistry
      Update the registry settings for this registry.
      Overrides:
      update in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Parameters:
      registrySettings - new settings to use going forward
    • isMetricEnabled

      protected boolean isMetricEnabled(String metricName)
      Description copied from class: AbstractRegistry
      Indicates whether the specified metric name is enabled or not.

      Concrete implementations of this method should account for registry settings that might have disabled the specified metric or the registry as a whole. They do not need to check whether metrics in its entirety is enabled.

      Specified by:
      isMetricEnabled in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Parameters:
      metricName - name of the metric to check
      Returns:
      true if the metric is enabled; false otherwise
    • toImpl

      protected <T extends Metric> io.helidon.metrics.HelidonMetric toImpl(Metadata metadata, T metric)
      Description copied from class: AbstractRegistry
      Creates a new instance of an implementation wrapper around the indicated metric.
      Specified by:
      toImpl in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Type Parameters:
      T - specific type of Metric provided and wrapped
      Parameters:
      metadata - Metadata for the metric
      metric - the existing metric to be wrapped by the impl
      Returns:
      new wrapper implementation around the specified metric instance
    • prepareMetricToTypeMap

      protected Map<Class<? extends io.helidon.metrics.HelidonMetric>,MetricType> prepareMetricToTypeMap()
      Description copied from class: AbstractRegistry
      Prepares the map from Java types of implementation metrics to the corresponding MetricType.
      Specified by:
      prepareMetricToTypeMap in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Returns:
      prepared map for a given metrics implementation
    • createGauge

      protected <R extends Number> Gauge<R> createGauge(Metadata metadata, Supplier<R> supplier)
      Description copied from class: AbstractRegistry
      Creates a gauge instance according to the specified supplier which returns the gauge value.
      Specified by:
      createGauge in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Type Parameters:
      R - specific Number subtype the supplier returns
      Parameters:
      metadata - metadata to use in creating the gauge
      supplier - gauge-value-returning supplier
      Returns:
      new gauge
    • prepareMetricFactories

      protected Map<MetricType,BiFunction<String,Metadata,io.helidon.metrics.HelidonMetric>> prepareMetricFactories()
      Description copied from class: AbstractRegistry
      Provides a map from MicroProfile metric type to a factory which creates a concrete metric instance of the MP metric type which also extends the implementation metric base class for the concrete implementation (e.g., no-op or full-featured).
      Specified by:
      prepareMetricFactories in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Returns:
      map from each MicroProfile metric type to the correspondingfactory method
    • createGauge

      protected <T, R extends Number> Gauge<R> createGauge(Metadata metadata, T object, Function<T,R> func)
      Description copied from class: AbstractRegistry
      Creates a gauge instance according to the provided metadata such that retrievals of the gauge value trigger an invocation of the provided function, passing the indicated object.

      This default implementation uses a capturing lambda for retrieving the value. Concrete subclasses can override this implementation if capturing lambda behavior might become a performance issue.

      Overrides:
      createGauge in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Type Parameters:
      T - Java type of the function parameter (and the object to pass to it)
      R - specific Number subtype the gauge reports
      Parameters:
      metadata - metadata to use in creating the gauge
      object - object to pass to the value-returning function
      func - gauge-value-returning function
      Returns:
      new gauge
    • getOptionalMetricEntry

      protected Optional<Map.Entry<MetricID,io.helidon.metrics.HelidonMetric>> getOptionalMetricEntry(String metricName)
      Description copied from class: AbstractRegistry
      Returns an Optional for an entry containing a metric ID and the corresponding metric matching the specified metric name.

      If multiple metrics match the name (because of tags), the returned metric is, preferentially, the one (if any) with no tags. If all metrics registered under the specified name have tags, then the method returns the metric which was registered earliest

      Overrides:
      getOptionalMetricEntry in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Parameters:
      metricName - name of the metric of interest
      Returns:
      Optional of a map entry containing the metric ID and the metric selected
    • metricFactories

      protected Map<MetricType,BiFunction<String,Metadata,io.helidon.metrics.HelidonMetric>> metricFactories()
      Description copied from class: AbstractRegistry
      For testing.
      Overrides:
      metricFactories in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Returns:
      map from MicroProfile metric type to factory functions.
    • stream

      protected Stream<Map.Entry<MetricID,io.helidon.metrics.HelidonMetric>> stream()
      Description copied from class: AbstractRegistry
      Returns a stream of Map.Entry for this registry for enabled metrics.
      Overrides:
      stream in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Returns:
      Stream of Map.Entry
    • metricIDsForName

      protected List<MetricID> metricIDsForName(String metricName)
      Description copied from class: AbstractRegistry
      Returns a list of metric IDs given a metric name.
      Overrides:
      metricIDsForName in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Parameters:
      metricName - name of the metric of interest
      Returns:
      list of metric IDs for metrics with the specified name; empty if no matches
    • getMetricsByName

      protected List<Map.Entry<MetricID,io.helidon.metrics.HelidonMetric>> getMetricsByName(String metricName)
      Description copied from class: AbstractRegistry
      Returns a list of metric ID/metric pairs which match the provided metric name.
      Overrides:
      getMetricsByName in class AbstractRegistry<io.helidon.metrics.HelidonMetric>
      Parameters:
      metricName - name of the metric of interest
      Returns:
      List of entries indicating metrics with the specified name; empty of no matches