You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "mlbiscoc (via GitHub)" <gi...@apache.org> on 2025/09/17 18:15:10 UTC

[PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

mlbiscoc opened a new pull request, #3668:
URL: https://github.com/apache/solr/pull/3668

   https://issues.apache.org/jira/browse/SOLR-17806
   
   Migrate metrics from suggest component and cross-dc


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3668:
URL: https://github.com/apache/solr/pull/3668#discussion_r2359211840


##########
solr/core/src/java/org/apache/solr/handler/component/SuggestComponent.java:
##########
@@ -519,6 +518,12 @@ private SuggesterResult toSuggesterResult(
     return result;
   }
 
+  @Override
+  public void close() throws IOException {
+    super.close();
+    IOUtils.closeQuietly(toClose);

Review Comment:
   nit: normally you close down yourself first, then what's beneath you.  Reverse order of construction.



##########
solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java:
##########
@@ -16,72 +16,114 @@
  */
 package org.apache.solr.crossdc.update.processor;
 
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Histogram;
+import static org.apache.solr.metrics.SolrCoreMetricManager.COLLECTION_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.CORE_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.REPLICA_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.SHARD_ATTR;
+import static org.apache.solr.metrics.SolrMetricProducer.TYPE_ATTR;
+
+import io.opentelemetry.api.common.Attributes;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.metrics.SolrMetricsContext;
+import org.apache.solr.metrics.otel.OtelUnit;
+import org.apache.solr.metrics.otel.instruments.AttributedLongCounter;
+import org.apache.solr.metrics.otel.instruments.AttributedLongHistogram;
 
 /** Metrics presented for each SolrCore using `crossdc.producer.` path. */
 public class ProducerMetrics {
 
-  private final Counter local;
-  private final Counter localError;
-  private final Counter submitted;
-  private final Counter submitError;
-  private final Histogram documentSize;
-  private final Counter documentTooLarge;
+  private final AttributedLongCounter local;
+  private final AttributedLongCounter localError;
+  private final AttributedLongCounter submitted;
+  private final AttributedLongCounter submitError;
+  private final AttributedLongHistogram documentSize;
+  private final AttributedLongCounter documentTooLarge;
 
   public ProducerMetrics(SolrMetricsContext solrMetricsContext, SolrCore solrCore) {
+    CoreDescriptor coreDescriptor = solrCore.getCoreDescriptor();
+    CloudDescriptor cloudDescriptor =
+        (coreDescriptor != null) ? coreDescriptor.getCloudDescriptor() : null;
+    var attributesBuilder = Attributes.builder().put(CORE_ATTR, solrCore.getName());
+    if (cloudDescriptor != null) {
+      attributesBuilder
+          .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+          .put(SHARD_ATTR, cloudDescriptor.getShardId())
+          .put(
+              REPLICA_ATTR,
+              Utils.parseMetricsReplicaName(
+                  coreDescriptor.getCollectionName(), solrCore.getName()));

Review Comment:
   it looks suspicious to parse the replica name out of the core name in a context where we have access to many Solr internals.  CC @HoustonPutman do you know how to get the replica name here?  Would it really be necessary to go look up the Replica (in cluster state)?  How awkward if so



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3668:
URL: https://github.com/apache/solr/pull/3668#discussion_r2361126458


##########
solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java:
##########
@@ -16,72 +16,114 @@
  */
 package org.apache.solr.crossdc.update.processor;
 
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Histogram;
+import static org.apache.solr.metrics.SolrCoreMetricManager.COLLECTION_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.CORE_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.REPLICA_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.SHARD_ATTR;
+import static org.apache.solr.metrics.SolrMetricProducer.TYPE_ATTR;
+
+import io.opentelemetry.api.common.Attributes;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.metrics.SolrMetricsContext;
+import org.apache.solr.metrics.otel.OtelUnit;
+import org.apache.solr.metrics.otel.instruments.AttributedLongCounter;
+import org.apache.solr.metrics.otel.instruments.AttributedLongHistogram;
 
 /** Metrics presented for each SolrCore using `crossdc.producer.` path. */
 public class ProducerMetrics {
 
-  private final Counter local;
-  private final Counter localError;
-  private final Counter submitted;
-  private final Counter submitError;
-  private final Histogram documentSize;
-  private final Counter documentTooLarge;
+  private final AttributedLongCounter local;
+  private final AttributedLongCounter localError;
+  private final AttributedLongCounter submitted;
+  private final AttributedLongCounter submitError;
+  private final AttributedLongHistogram documentSize;
+  private final AttributedLongCounter documentTooLarge;
 
   public ProducerMetrics(SolrMetricsContext solrMetricsContext, SolrCore solrCore) {
+    CoreDescriptor coreDescriptor = solrCore.getCoreDescriptor();
+    CloudDescriptor cloudDescriptor =
+        (coreDescriptor != null) ? coreDescriptor.getCloudDescriptor() : null;
+    var attributesBuilder = Attributes.builder().put(CORE_ATTR, solrCore.getName());
+    if (cloudDescriptor != null) {
+      attributesBuilder
+          .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+          .put(SHARD_ATTR, cloudDescriptor.getShardId())
+          .put(
+              REPLICA_ATTR,
+              Utils.parseMetricsReplicaName(
+                  coreDescriptor.getCollectionName(), solrCore.getName()));

Review Comment:
   Many places were doing it like this so was assuming this was the normal way. But honestly do we need this replica name as an attribute? Personally I aggregate on all these core attributes except for replica. I kept it because it was on the prometheus exporter. What if we change this to replica type instead (NRT/TLOG/PULL)? I would find that useful to aggregate on.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3668:
URL: https://github.com/apache/solr/pull/3668#discussion_r2373304037


##########
solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java:
##########
@@ -16,72 +16,114 @@
  */
 package org.apache.solr.crossdc.update.processor;
 
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Histogram;
+import static org.apache.solr.metrics.SolrCoreMetricManager.COLLECTION_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.CORE_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.REPLICA_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.SHARD_ATTR;
+import static org.apache.solr.metrics.SolrMetricProducer.TYPE_ATTR;
+
+import io.opentelemetry.api.common.Attributes;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.metrics.SolrMetricsContext;
+import org.apache.solr.metrics.otel.OtelUnit;
+import org.apache.solr.metrics.otel.instruments.AttributedLongCounter;
+import org.apache.solr.metrics.otel.instruments.AttributedLongHistogram;
 
 /** Metrics presented for each SolrCore using `crossdc.producer.` path. */
 public class ProducerMetrics {
 
-  private final Counter local;
-  private final Counter localError;
-  private final Counter submitted;
-  private final Counter submitError;
-  private final Histogram documentSize;
-  private final Counter documentTooLarge;
+  private final AttributedLongCounter local;
+  private final AttributedLongCounter localError;
+  private final AttributedLongCounter submitted;
+  private final AttributedLongCounter submitError;
+  private final AttributedLongHistogram documentSize;
+  private final AttributedLongCounter documentTooLarge;
 
   public ProducerMetrics(SolrMetricsContext solrMetricsContext, SolrCore solrCore) {
+    CoreDescriptor coreDescriptor = solrCore.getCoreDescriptor();
+    CloudDescriptor cloudDescriptor =
+        (coreDescriptor != null) ? coreDescriptor.getCloudDescriptor() : null;
+    var attributesBuilder = Attributes.builder().put(CORE_ATTR, solrCore.getName());
+    if (cloudDescriptor != null) {
+      attributesBuilder
+          .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+          .put(SHARD_ATTR, cloudDescriptor.getShardId())
+          .put(
+              REPLICA_ATTR,
+              Utils.parseMetricsReplicaName(
+                  coreDescriptor.getCollectionName(), solrCore.getName()));

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc merged PR #3668:
URL: https://github.com/apache/solr/pull/3668


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17806: Migrate suggest component and cross-dc metrics to OTEL [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3668:
URL: https://github.com/apache/solr/pull/3668#discussion_r2364501233


##########
solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java:
##########
@@ -16,72 +16,114 @@
  */
 package org.apache.solr.crossdc.update.processor;
 
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Histogram;
+import static org.apache.solr.metrics.SolrCoreMetricManager.COLLECTION_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.CORE_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.REPLICA_ATTR;
+import static org.apache.solr.metrics.SolrCoreMetricManager.SHARD_ATTR;
+import static org.apache.solr.metrics.SolrMetricProducer.TYPE_ATTR;
+
+import io.opentelemetry.api.common.Attributes;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.metrics.SolrMetricsContext;
+import org.apache.solr.metrics.otel.OtelUnit;
+import org.apache.solr.metrics.otel.instruments.AttributedLongCounter;
+import org.apache.solr.metrics.otel.instruments.AttributedLongHistogram;
 
 /** Metrics presented for each SolrCore using `crossdc.producer.` path. */
 public class ProducerMetrics {
 
-  private final Counter local;
-  private final Counter localError;
-  private final Counter submitted;
-  private final Counter submitError;
-  private final Histogram documentSize;
-  private final Counter documentTooLarge;
+  private final AttributedLongCounter local;
+  private final AttributedLongCounter localError;
+  private final AttributedLongCounter submitted;
+  private final AttributedLongCounter submitError;
+  private final AttributedLongHistogram documentSize;
+  private final AttributedLongCounter documentTooLarge;
 
   public ProducerMetrics(SolrMetricsContext solrMetricsContext, SolrCore solrCore) {
+    CoreDescriptor coreDescriptor = solrCore.getCoreDescriptor();
+    CloudDescriptor cloudDescriptor =
+        (coreDescriptor != null) ? coreDescriptor.getCloudDescriptor() : null;
+    var attributesBuilder = Attributes.builder().put(CORE_ATTR, solrCore.getName());
+    if (cloudDescriptor != null) {
+      attributesBuilder
+          .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+          .put(SHARD_ATTR, cloudDescriptor.getShardId())
+          .put(
+              REPLICA_ATTR,
+              Utils.parseMetricsReplicaName(
+                  coreDescriptor.getCollectionName(), solrCore.getName()));

Review Comment:
   Those are two separate points.  +1 to drop replica; we can add it later if someone wants it.  +1 to add the replica type



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org