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

org.apache.zookeeper.metrics

## Interface MetricsContext

- All Known Implementing Classes:
    NullMetricsProvider.NullMetricsContext

      public interface MetricsContext

  A MetricsContext is like a namespace for metrics. Each component/submodule will have its own MetricsContext.

  In some cases it is possible to have a separate MetricsContext for each instance of a component, for instance on the server side a possible usecase it to gather metrics for every other peer.

  Contexts are organized in a hierarchy.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `MetricsContext.DetailLevel`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `MetricsContext` | `getContext(String name)` Returns a sub context.
    `Counter` | `getCounter(String name)` Returns a counter.
    `Summary` | `getSummary(String name, MetricsContext.DetailLevel detailLevel)` Returns a summary.
    `SummarySet` | `getSummarySet(String name, MetricsContext.DetailLevel detailLevel)` Returns a set of summaries.
    `void` | `registerGauge(String name, Gauge gauge)` Registers an user provided `Gauge` which will be called by the MetricsProvider in order to sample an integer value.
    `void` | `unregisterGauge(String name)` Unregisters the user provided `Gauge` bound to the given name.

- - ### Method Detail

    - #### getContext

          MetricsContext getContext(String name)

      Returns a sub context.
      Parameters:
        `name` - the name of the subcontext
      Returns:
        a new metrics context.

    - #### getCounter

          Counter getCounter(String name)

      Returns a counter.
      Parameters:
        `name` -
      Returns:
        the counter identified by name in this context.

    - #### registerGauge

          void registerGauge(String name,
                             Gauge gauge)

      Registers an user provided `Gauge` which will be called by the MetricsProvider in order to sample an integer value. If another Gauge was already registered the new one will take its place. Registering a null callback is not allowed.
      Parameters:
        `name` - unique name of the Gauge in this context
        `gauge` - the implementation of the Gauge

    - #### unregisterGauge

          void unregisterGauge(String name)

      Unregisters the user provided `Gauge` bound to the given name.
      Parameters:
        `name` - unique name of the Gauge in this context

    - #### getSummary

          Summary getSummary(String name,
                             MetricsContext.DetailLevel detailLevel)

      Returns a summary.
      Parameters:
        `name` -
        `detailLevel` -
      Returns:
        the summary identified by name in this context.

    - #### getSummarySet

          SummarySet getSummarySet(String name,
                                   MetricsContext.DetailLevel detailLevel)

      Returns a set of summaries.
      Parameters:
        `name` -
        `detailLevel` -
      Returns:
        the summary identified by name in this context.

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