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 Modifier and Type Interface Description static class
MetricsContext.DetailLevel
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MetricsContext
getContext(String name)
Returns a sub context.Counter
getCounter(String name)
Returns a counter.CounterSet
getCounterSet(String name)
Returns the CounterSet identified by the given name Null name is not allowedSummary
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 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 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.
-
getCounterSet
CounterSet getCounterSet(String name)
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
void registerGauge(String name, Gauge gauge)
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
void unregisterGauge(String name)
Unregisters the user providedGauge
bound to the given name.- Parameters:
name
- unique name of the Gauge in this context
-
registerGaugeSet
void registerGaugeSet(String name, GaugeSet gaugeSet)
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
void unregisterGaugeSet(String name)
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
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.
-
-