Class MeterRegistryFactory

java.lang.Object
io.helidon.integrations.micrometer.MeterRegistryFactory

@Deprecated(forRemoval=true, since="4.1") public final class MeterRegistryFactory extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Use the Helidon neutral metrics API and unwrap its types to their Micrometer counterparts
Provides access to the MeterRegistry Helidon SE uses to collect meters and report their metrics.

In reality, we use a CompositeMeterRegistry to which we, by default, add a PrometheusMeterRegistry and to which the developer can add, via either configuration or builder, other MeterRegistry instances.

Using the factory

Use this factory in either of two ways:

  1. Access the singleton instance via getInstance() or getInstance(Builder). The factory remembers the factory instance, lazily instantiated by the most recent invocation of either method.
  2. A custom instance via create() or create(Config). Instances of the factory created this way are independent of the singleton created by getInstance() or getInstance(Builder).

Adding developer-requested registries

In Micrometer, different registries report their contents in different formats. Further, there is no common abstract method defined on MeterRegistry which all implementations override; each MeterRegistry has its own particular way of furnishing metrics output.

By default, we use a PrometheusMeterRegistry to support Prometheus/OpenMetrics format. Developers can enroll other registries to support other formats. We need to know which registry to use in response to receiving an HTTP request for Micrometer metrics output.

To allow us to do this, when our code or developer's enrolls a registry, it also passes a function that accepts a ServerRequest and returns an Optional<Handler>. The function is expected to inspect the request, and if it wants to process that request (which means, if that registry should be used to respond to that request), it returns an Optional.of a Handler. The handler uses the registry-specific mechanism for retrieving formatted meter and metrics information and sets and returns the HTTP response. If the function decides that its corresponding meter registry is not suitable for that particular request, it returns an Optional.empty().

When a Micrometer request arrives, the Helidon code invokes the functions associated with all enrolled registries, in the order of enrollment. The first function that returns a non-empty Optional wins and must populate and return the ServerResponse.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Builder for constructing MeterRegistryFactory instances.
    static enum 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Available built-in registry types.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a new Builder for constructing a MeterRegistryFactory.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new factory using default settings (no config).
    create(Config config)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new factory using the specified config.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the singleton instance of the factory.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates and saves as the singleton a new factory.
    io.micrometer.core.instrument.MeterRegistry
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the MeterRegistry associated with this factory instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static MeterRegistryFactory create()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new factory using default settings (no config).
      Returns:
      initialized MeterRegistryFactory
    • create

      public static MeterRegistryFactory create(Config config)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new factory using the specified config.
      Parameters:
      config - the config to use in initializing the factory
      Returns:
      initialized MeterRegistryFactory
    • getInstance

      public static MeterRegistryFactory getInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the singleton instance of the factory.
      Returns:
      factory singleton
    • getInstance

      public static MeterRegistryFactory getInstance(MeterRegistryFactory.Builder builder)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates and saves as the singleton a new factory.
      Parameters:
      builder - the Builder to use in constructing the new singleton instance
      Returns:
      MeterRegistryFactory using the Builder
    • builder

      public static MeterRegistryFactory.Builder builder()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a new Builder for constructing a MeterRegistryFactory.
      Returns:
      initialized builder
    • meterRegistry

      public io.micrometer.core.instrument.MeterRegistry meterRegistry()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the MeterRegistry associated with this factory instance.
      Returns:
      the meter registry