Package 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 -
Method Summary
Modifier and TypeMethodDescriptiongetContext
(String name) Returns a sub context.getCounter
(String name) Returns a counter.getCounterSet
(String name) Returns the CounterSet identified by the given name Null name is not allowedgetSummary
(String name, MetricsContext.DetailLevel detailLevel) Returns a summary.getSummarySet
(String name, MetricsContext.DetailLevel detailLevel) Returns a set of summaries.void
registerGauge
(String name, Gauge gauge) Registers an user providedGauge
which will be called by the MetricsProvider in order to sample an integer value.void
registerGaugeSet
(String name, GaugeSet gaugeSet) Registers a user providedGaugeSet
which will be called by the MetricsProvider in order to sample number values.void
unregisterGauge
(String name) Unregisters the user providedGauge
bound to the given name.void
unregisterGaugeSet
(String name) Unregisters the user providedGaugeSet
bound to the given name.
-
Method Details
-
getContext
Returns a sub context.- Parameters:
name
- the name of the subcontext- Returns:
- a new metrics context.
-
getCounter
Returns a counter.- Parameters:
name
-- Returns:
- the counter identified by name in this context.
-
getCounterSet
Returns the CounterSet identified by the given name Null name is not allowed- Parameters:
name
-- Returns:
- CounterSet identified by the name in this context.
-
registerGauge
Registers an user providedGauge
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 contextgauge
- the implementation of the Gauge
-
unregisterGauge
Unregisters the user providedGauge
bound to the given name.- Parameters:
name
- unique name of the Gauge in this context
-
registerGaugeSet
Registers a user providedGaugeSet
which will be called by the MetricsProvider in order to sample number values. If another GaugeSet was already registered, the new one will take its place. Registering with a null name or null callback is not allowed.- Parameters:
name
- unique name of the GaugeSet in this contextgaugeSet
- the implementation of the GaugeSet
-
unregisterGaugeSet
Unregisters the user providedGaugeSet
bound to the given name. Unregistering with a null name is not allowed.- Parameters:
name
- unique name of the GaugeSet in this context
-
getSummary
Returns a summary.- Parameters:
name
-detailLevel
-- Returns:
- the summary identified by name in this context.
-
getSummarySet
Returns a set of summaries.- Parameters:
name
-detailLevel
-- Returns:
- the summary identified by name in this context.
-