Package org.apache.solr.metrics
Class SolrMetricsContext
- java.lang.Object
-
- org.apache.solr.metrics.SolrMetricsContext
-
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.
-
-
Field Summary
Fields Modifier and Type Field Description SolrMetricManagermetricManagerStringregistryStringtag
-
Constructor Summary
Constructors Constructor Description SolrMetricsContext(SolrMetricManager metricManager, String registry, String tag)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.codahale.metrics.Countercounter(SolrInfoBean info, String metricName, String... metricPath)Convenience method forSolrMetricManager.counter(SolrInfoBean, String, String, String...).voidgauge(SolrInfoBean info, com.codahale.metrics.Gauge<?> gauge, boolean force, String metricName, String... metricPath)Convenience method forSolrMetricManager.registerGauge(SolrInfoBean, String, Gauge, String, boolean, String, String...).SolrMetricsContextgetChildContext(Object child)Get a context with the same registry name but a tag that represents a parent-child relationship.com.codahale.metrics.MetricRegistrygetMetricRegistry()Get the MetricRegistry instance that is used for registering metrics in this context.StringgetTag()Metrics tag that represents objects with the same life-cycle.com.codahale.metrics.Histogramhistogram(SolrInfoBean info, String metricName, String... metricPath)Convenience method forSolrMetricManager.histogram(SolrInfoBean, String, String, String...).com.codahale.metrics.Metermeter(SolrInfoBean info, String metricName, String... metricPath)Convenience method forSolrMetricManager.meter(SolrInfoBean, String, String, String...).com.codahale.metrics.Timertimer(SolrInfoBean info, String metricName, String... metricPath)Convenience method forSolrMetricManager.meter(SolrInfoBean, String, String, String...).voidunregister()Unregister allGaugemetrics that use this context's tag.
-
-
-
Field Detail
-
registry
public final String registry
-
metricManager
public final SolrMetricManager metricManager
-
tag
public final String tag
-
-
Constructor Detail
-
SolrMetricsContext
public SolrMetricsContext(SolrMetricManager metricManager, String registry, String tag)
-
-
Method Detail
-
getTag
public String getTag()
Metrics tag that represents objects with the same life-cycle.
-
unregister
public void unregister()
Unregister allGaugemetrics 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.
-
meter
public com.codahale.metrics.Meter meter(SolrInfoBean info, String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrInfoBean, String, String, String...).
-
counter
public com.codahale.metrics.Counter counter(SolrInfoBean info, String metricName, String... metricPath)
Convenience method forSolrMetricManager.counter(SolrInfoBean, String, String, String...).
-
gauge
public void gauge(SolrInfoBean info, com.codahale.metrics.Gauge<?> gauge, boolean force, String metricName, String... metricPath)
Convenience method forSolrMetricManager.registerGauge(SolrInfoBean, String, Gauge, String, boolean, String, String...).
-
timer
public com.codahale.metrics.Timer timer(SolrInfoBean info, String metricName, String... metricPath)
Convenience method forSolrMetricManager.meter(SolrInfoBean, String, String, String...).
-
histogram
public com.codahale.metrics.Histogram histogram(SolrInfoBean info, String metricName, String... metricPath)
Convenience method forSolrMetricManager.histogram(SolrInfoBean, String, String, String...).
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
Get the MetricRegistry instance that is used for registering metrics in this context.
-
-