Package org.apache.solr.metrics
Class SolrMetricsContext
- java.lang.Object
-
- org.apache.solr.metrics.SolrMetricsContext
-
- Direct Known Subclasses:
SolrDelegateRegistryMetricsContext
public class SolrMetricsContext extends Object
This class represents a metrics context that ties together components with the same life-cycle and provides convenient access to the metric registry.Additionally it's used for registering and reporting metrics specific to the components that use the same instance of context.
-
-
Constructor Summary
Constructors Constructor Description SolrMetricsContext(SolrMetricManager metricManager, String registryName, String tag)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.codahale.metrics.Counter
counter(String metricName, String... metricPath)
Convenience method forSolrMetricManager.counter(SolrMetricsContext, String, String, String...)
.void
gauge(com.codahale.metrics.Gauge<?> gauge, boolean force, String metricName, String... metricPath)
SolrMetricsContext
getChildContext(Object child)
Get a context with the same registry name but a tag that represents a parent-child relationship.SolrMetricManager
getMetricManager()
Return the instance ofSolrMetricManager
used in this context.Set<String>
getMetricNames()
Return a modifiable set of metric names that this component registers.com.codahale.metrics.MetricRegistry
getMetricRegistry()
Get theMetricRegistry
instance that is used for registering metrics in this context.Map<String,Object>
getMetricsSnapshot()
Return a snapshot of metric values that this component reports.String
getRegistryName()
Return metric registry name used in this context.String
getTag()
Metrics tag that represents objects with the same life-cycle.com.codahale.metrics.Histogram
histogram(String metricName, String... metricPath)
Convenience method forSolrMetricManager.histogram(SolrMetricsContext, String, String, String...)
.com.codahale.metrics.Meter
meter(String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrMetricsContext, String, String, String...)
.Object
notANumber()
Object
nullNumber()
Object
nullObject()
Object
nullString()
void
registerMetricName(String name)
Register a metric name that this component reports.com.codahale.metrics.Timer
timer(String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrMetricsContext, String, String, String...)
.void
unregister()
Unregister allGauge
metrics that use this context's tag.
-
-
-
Constructor Detail
-
SolrMetricsContext
public SolrMetricsContext(SolrMetricManager metricManager, String registryName, String tag)
-
-
Method Detail
-
nullNumber
public Object nullNumber()
-
notANumber
public Object notANumber()
-
nullString
public Object nullString()
-
nullObject
public Object nullObject()
-
getTag
public String getTag()
Metrics tag that represents objects with the same life-cycle.
-
getRegistryName
public String getRegistryName()
Return metric registry name used in this context.
-
getMetricManager
public SolrMetricManager getMetricManager()
Return the instance ofSolrMetricManager
used in this context.
-
getMetricNames
public Set<String> getMetricNames()
Return a modifiable set of metric names that this component registers.
-
unregister
public void unregister()
Unregister allGauge
metrics that use this context's tag.NOTE: This method MUST be called at the end of a life-cycle (typically in
close()
) of components that register gauge metrics with references to the current object's instance. Failure to do so may result in hard-to-debug memory leaks.
-
getChildContext
public SolrMetricsContext getChildContext(Object child)
Get a context with the same registry name but a tag that represents a parent-child relationship. Since it's a different tag than the parent's context it is assumed that the life-cycle of the parent and child are different.- Parameters:
child
- child object that produces metrics with a different life-cycle than the parent.
-
registerMetricName
public void registerMetricName(String name)
Register a metric name that this component reports. This method is called by various metric registration methods inSolrMetricManager
in order to capture what metric names are reported from this component (which in turn is called fromSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
).
-
getMetricsSnapshot
public Map<String,Object> getMetricsSnapshot()
Return a snapshot of metric values that this component reports.
-
meter
public com.codahale.metrics.Meter meter(String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrMetricsContext, String, String, String...)
.
-
counter
public com.codahale.metrics.Counter counter(String metricName, String... metricPath)
Convenience method forSolrMetricManager.counter(SolrMetricsContext, String, String, String...)
.
-
gauge
public void gauge(com.codahale.metrics.Gauge<?> gauge, boolean force, String metricName, String... metricPath)
-
timer
public com.codahale.metrics.Timer timer(String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrMetricsContext, String, String, String...)
.
-
histogram
public com.codahale.metrics.Histogram histogram(String metricName, String... metricPath)
Convenience method forSolrMetricManager.histogram(SolrMetricsContext, String, String, String...)
.
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
Get theMetricRegistry
instance that is used for registering metrics in this context.
-
-