Class SolrCoreMetricManager

java.lang.Object
org.apache.solr.metrics.SolrCoreMetricManager
All Implemented Interfaces:
Closeable, AutoCloseable

public class SolrCoreMetricManager extends Object implements Closeable
Helper class for managing registration of SolrMetricProducer's specific to a SolrCore instance.
  • Field Details

    • COLLECTION_ATTR

      public static final io.opentelemetry.api.common.AttributeKey<String> COLLECTION_ATTR
    • CORE_ATTR

      public static final io.opentelemetry.api.common.AttributeKey<String> CORE_ATTR
    • SHARD_ATTR

      public static final io.opentelemetry.api.common.AttributeKey<String> SHARD_ATTR
    • REPLICA_TYPE_ATTR

      public static final io.opentelemetry.api.common.AttributeKey<String> REPLICA_TYPE_ATTR
  • Constructor Details

    • SolrCoreMetricManager

      public SolrCoreMetricManager(SolrCore core)
      Constructs a metric manager.
      Parameters:
      core - the metric manager's core
  • Method Details

    • reregisterCoreMetrics

      public void reregisterCoreMetrics()
      Re-register all metric producers associated with this core. This recreates the metric registry resetting its state and recreating its attributes for all tracked registered producers.
    • registerMetricProducer

      public void registerMetricProducer(SolrMetricProducer producer, io.opentelemetry.api.common.Attributes attributes)
      Registers a mapping of name/metric's with the manager's metric registry and creates the base set of attributes for core level metrics. All metric producers are tracked for re-registering in the case of core swapping/renaming
      Parameters:
      producer - producer of metrics to be registered
    • 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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      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 required solr.core prefix). However, if this is a SolrCloud collection my_collection then the registry name will become solr.core.my_collection.shard1_1.replica1.

      Returns:
      the metric registry name of the manager.
    • 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 by CoreContainer.rename(String, String).
      Parameters:
      aCore - existing core with old name
      coreName - new name
      Returns:
      new registry name