Package org.apache.solr.metrics
Class SolrCoreMetricManager
- java.lang.Object
-
- org.apache.solr.metrics.SolrCoreMetricManager
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class SolrCoreMetricManager extends Object implements Closeable
Responsible for collecting metrics fromSolrMetricProducer
's and exposing metrics toSolrMetricReporter
's.
-
-
Constructor Summary
Constructors Constructor Description SolrCoreMetricManager(SolrCore core)
Constructs a metric manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCoreSetName()
Make sure that metrics already collected that correspond to the old core name are carried over and will be used under the new core name.void
close()
Closes reporters specific to this core and unregisters gauges with this core's instance tag.static String
createLeaderRegistryName(boolean cloud, String collectionName, String shardName)
static String
createRegistryName(boolean cloud, String collectionName, String shardName, String replicaName, String coreName)
static String
createRegistryName(SolrCore aCore, String coreName)
This method is used byCoreContainer.rename(String, String)
.SolrCore
getCore()
String
getLeaderRegistryName()
Metric registry name for leader metrics.com.codahale.metrics.MetricRegistry
getRegistry()
Return the registry used by this SolrCore.String
getRegistryName()
Metric registry name of the manager.SolrMetricsContext
getSolrMetricsContext()
String
getTag()
Return a tag specific to this instance.void
loadReporters()
Load reporters configured globally and specific toSolrInfoBean.Group.core
group or with a registry name specific to this core.void
registerMetricProducer(String scope, SolrMetricProducer producer)
Registers a mapping of name/metric's with the manager's metric registry.
-
-
-
Constructor Detail
-
SolrCoreMetricManager
public SolrCoreMetricManager(SolrCore core)
Constructs a metric manager.- Parameters:
core
- the metric manager's core
-
-
Method Detail
-
loadReporters
public void loadReporters()
Load reporters configured globally and specific toSolrInfoBean.Group.core
group or with a registry name specific to this core.
-
afterCoreSetName
public void afterCoreSetName()
Make sure that metrics already collected that correspond to the old core name are carried over and will be used under the new core name. This method also reloads reporters so that they use the new core name.
-
registerMetricProducer
public void registerMetricProducer(String scope, SolrMetricProducer producer)
Registers a mapping of name/metric's with the manager's metric registry.- Parameters:
scope
- the scope of the metrics to be registered (e.g. `/admin/ping`)producer
- producer of metrics to be registered
-
getRegistry
public com.codahale.metrics.MetricRegistry getRegistry()
Return the registry used by this SolrCore.
-
close
public void close() throws IOException
Closes reporters specific to this core and unregisters gauges with this core's instance tag.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
-
getCore
public SolrCore getCore()
-
getRegistryName
public String getRegistryName()
Metric registry name of the manager. In order to make it easier for reporting tools to aggregate metrics from different cores that logically belong to a single collection we convert the core name into a dot-separated hierarchy of: collection name, shard name (with optional split) and replica name.For example, when the core name looks like this but it's NOT a SolrCloud collection:
my_collection_shard1_1_replica1
then this will be used as the registry name (plus the requiredsolr.core
prefix). However, if this is a SolrCloud collectionmy_collection
then the registry name will becomesolr.core.my_collection.shard1_1.replica1
.- Returns:
- the metric registry name of the manager.
-
getLeaderRegistryName
public String getLeaderRegistryName()
Metric registry name for leader metrics. This is null if not in cloud mode.- Returns:
- metric registry name for leader metrics
-
getTag
public String getTag()
Return a tag specific to this instance.
-
createRegistryName
public static String createRegistryName(boolean cloud, String collectionName, String shardName, String replicaName, String coreName)
-
createRegistryName
public static String createRegistryName(SolrCore aCore, String coreName)
This method is used byCoreContainer.rename(String, String)
.- Parameters:
aCore
- existing core with old namecoreName
- new name- Returns:
- new registry name
-
-