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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to