Apache Solr open-source search software
Coordinator node does not have correct collection tagged for TracingSpan (#1962)
Noble Paul03f656f0a63c
diff --git a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.javaindex 82664b23623..aa4a0e2fd75 100644--- a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java+++ b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java@@ -47,6 +47,15 @@ import org.apache.solr.response.SolrQueryResponse;import org.slf4j.Logger;import org.slf4j.LoggerFactory;+/**+ * A coordinator node can serve requests as if it hosts all collections in the cluster. it does so+ * by hosting a synthetic replica for each configset used in the cluster.+ *+ * <p>This class is responsible for forwarding the requests to the right core when the node is+ * acting as a Coordinator The responsibilities also involve creating a synthetic collection or+ * replica if they do not exist. It also sets the right threadlocal variables which reflects the+ * current collection being served.+ */public class CoordinatorHttpSolrCall extends HttpSolrCall {public static final String SYNTHETIC_COLL_PREFIX =Assign.SYSTEM_COLL_PREFIX + "COORDINATOR-COLL-";@@ -277,6 +286,11 @@ public class CoordinatorHttpSolrCall extends HttpSolrCall {}}+ @Override+ protected String getCoreOrColName() {+ return collectionName;+ }+public static SolrQueryRequest wrappedReq(SolrQueryRequest delegate, String collectionName, HttpSolrCall httpSolrCall) {Properties p = new Properties();diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.javaindex 9137f3ded4e..ce9b1f8e6be 100644--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java@@ -637,10 +637,7 @@ public class HttpSolrCall {// called after init().protected void populateTracingSpan(Span span) {// Set db.instance- String coreOrColName = HttpSolrCall.this.origCorename;- if (coreOrColName == null && getCore() != null) {- coreOrColName = getCore().getName();- }+ String coreOrColName = getCoreOrColName();TraceUtils.setDbInstance(span, coreOrColName);// Set operation name.@@ -658,6 +655,14 @@ public class HttpSolrCall {span.updateName(verb + ":" + path);}+ protected String getCoreOrColName() {+ String coreOrColName = HttpSolrCall.this.origCorename;+ if (coreOrColName == null && getCore() != null) {+ coreOrColName = getCore().getName();+ }+ return coreOrColName;+ }+public boolean shouldAudit() {return shouldAudit(cores);}