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

    Modifier and Type
    Method
    Description
    void
    configure(Properties configuration)
    Configure the provider.
    void
    Dumps all metrics as a key-value pair.
    Provides access to the root context.
    void
    Reset all values.
    void
    Start the provider.
    void
    Releases resources held by the provider.
    This method must not throw exceptions.
    This method can be called more than once.
  • Method Details

    • configure

      void configure(Properties configuration) throws MetricsProviderLifeCycleException
      Configure the provider.
      Parameters:
      configuration - the configuration.
      Throws:
      MetricsProviderLifeCycleException - in case of invalid configuration.
    • start

      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.