MetricsProvider (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.metrics

## Interface MetricsProvider

- All Known Implementing Classes:
    DefaultMetricsProvider, NullMetricsProvider

      public interface MetricsProvider

  A MetricsProvider is a system which collects Metrics and publishes current values to external facilities. The system will create an instance of the configured class using the default constructor, which must be public.
  After the instantiation of the provider, the system will call `configure(java.util.Properties)` in order to provide configuration, and then when the system is ready to work it will call `start()`.
  Providers can be used both on ZooKeeper servers and on ZooKeeper clients.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `configure(Properties configuration)` Configure the provider.
    `void` | `dump(BiConsumer<String,Object> sink)` Dumps all metrics as a key-value pair.
    `MetricsContext` | `getRootContext()` Provides access to the root context.
    `void` | `resetAllValues()` Reset all values.
    `void` | `start()` Start the provider.
    `void` | `stop()` Releases resources held by the provider. This method must not throw exceptions. This method can be called more than once.

- - ### Method Detail

    - #### configure

          void configure(Properties configuration)
                  throws MetricsProviderLifeCycleException

      Configure the provider.
      Parameters:
        `configuration` - the configuration.
      Throws:
        `MetricsProviderLifeCycleException` - in case of invalid configuration.

    - #### start

          void start()
              throws MetricsProviderLifeCycleException

      Start the provider. For instance such method will start a network endpoint.
      Throws:
        `MetricsProviderLifeCycleException` - in case of failure

    - #### getRootContext

          MetricsContext getRootContext()

      Provides access to the root context.
      Returns:
        the root context

    - #### stop

          void stop()

      Releases resources held by the provider.
      This method must not throw exceptions.
      This method can be called more than once.

    - #### dump

          void dump(BiConsumer<String,Object> sink)

      Dumps all metrics as a key-value pair. This method will be used in legacy monitor command.
      Parameters:
        `sink` - the receiver of all of the current values.

    - #### resetAllValues

          void resetAllValues()

      Reset all values. This method is optional and can be noop, depending on the underlying implementation.

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.