You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2019/05/23 15:43:57 UTC
[lucene-solr] branch jira/SOLR-13434 created (now 7e98146)
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a change to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.
at 7e98146 SOLR-13434: Remove .DS_Store
This branch includes the following new commits:
new b90883e SOLR-13434: Initial commit
new a341ee3 SOLR-13434: Remove unnecessary file
new ff59746 SOLR-13434: Upgrade README for Jaeger contrib module
new 67d587e SOLR-13434: Add back JavaagentTracerConfigurator
new 7e98146 SOLR-13434: Remove .DS_Store
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[lucene-solr] 02/05: SOLR-13434: Remove unnecessary file
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a commit to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit a341ee35ff6a5122059f5251d6af5f6a3a53fd8b
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Thu May 23 15:58:50 2019 +0100
SOLR-13434: Remove unnecessary file
---
solr/contrib/jaegertracer-configurator/src/test-files/solr/temp.xml | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/solr/contrib/jaegertracer-configurator/src/test-files/solr/temp.xml b/solr/contrib/jaegertracer-configurator/src/test-files/solr/temp.xml
deleted file mode 100644
index e69de29..0000000
[lucene-solr] 03/05: SOLR-13434: Upgrade README for Jaeger contrib
module
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a commit to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit ff59746decd9a0f03763b438a460198847759c86
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Thu May 23 16:39:15 2019 +0100
SOLR-13434: Upgrade README for Jaeger contrib module
---
solr/contrib/jaegertracer-configurator/README.txt | 30 ++++++++++++++++++++++
.../org/apache/solr/JaegerTracerConfigurator.java | 8 +++---
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/solr/contrib/jaegertracer-configurator/README.txt b/solr/contrib/jaegertracer-configurator/README.txt
new file mode 100644
index 0000000..ed3978c
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/README.txt
@@ -0,0 +1,30 @@
+Welcome to Apache Solr Prometheus Exporter
+========
+
+Apache Solr Jaeger Tracer Configurator (solr-jaeger-tracer) provides a way for you to expose Solr's tracing to Jaeger.
+
+# Setup Jaeger Tracer Configurator
+
+Note that all library of solr-jaeger-tracer must be included in the classpath of all nodes then Jaeger tracer can be setup in `solr.xml` like this:
+
+```
+<tracerConfig name="tracerConfig" class="org.apache.solr.JaegerTracerConfigurator">
+ <double name="sampleRate">100.0</double>
+ <str name="agentHost">localhost</str>
+ <int name="agentPort">5775</int>
+ <bool name="logSpans">true</bool>
+ <int name="flushInterval">1000</int>
+ <int name="maxQueueSize">10000</int>
+ </tracerConfig>
+```
+
+List of parameters for JaegerTracerConfigurator include:
+|Parameter|Type|Required|Default|Description|
+|---------|----|--------|-------|-----------|
+|agentHost|string|Yes||The host of Jaeger backend|
+|agentPort|int|Yes||The port of Jaeger port|
+|logsSpans|bool|No|true|Whether the tracer should also log the spans|
+|flushInterval|int|No|5000|The tracer's flush interval (ms)|
+|maxQueueSize|int|No|10000|The tracer's maximum queue size|
+
+Other parameters which are not listed above can be configured using System Properties or Environment Variables. The full list are listed at [Jaeger-README](https://github.com/jaegertracing/jaeger-client-java/blob/master/jaeger-core/README.md).
\ No newline at end of file
diff --git a/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java b/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java
index 5548b75..95a59cf 100644
--- a/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java
+++ b/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java
@@ -61,7 +61,7 @@ public class JaegerTracerConfigurator extends TracerConfigurator {
if (flushIntervalArg != null && !(flushIntervalArg instanceof Integer)) {
throw new IllegalArgumentException("Expected a required int for param '" + FLUSH_INTERVAL +"'");
}
- int flushInterval = flushIntervalArg == null ? 1000 : (Integer) flushIntervalArg;
+ int flushInterval = flushIntervalArg == null ? 5000 : (Integer) flushIntervalArg;
Object maxQueueArgs = args.get(MAX_QUEUE_SIZE);
if (maxQueueArgs != null && !(maxQueueArgs instanceof Integer)) {
@@ -72,11 +72,13 @@ public class JaegerTracerConfigurator extends TracerConfigurator {
Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration()
.withType(ConstSampler.TYPE)
.withParam(1);
- Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration()
+
+ Configuration envConfig = Configuration.fromEnv();
+ Configuration.SenderConfiguration senderConfig = envConfig.getReporter().getSenderConfiguration()
.withAgentHost(host.toString())
.withAgentPort(port);
- Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration()
+ Configuration.ReporterConfiguration reporterConfig = envConfig.getReporter()
.withLogSpans(logSpans)
.withFlushInterval(flushInterval)
.withMaxQueueSize(maxQueue)
[lucene-solr] 04/05: SOLR-13434: Add back
JavaagentTracerConfigurator
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a commit to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 67d587e7f673f7212ff81d1d0b9007b44eebdfd4
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Thu May 23 16:41:55 2019 +0100
SOLR-13434: Add back JavaagentTracerConfigurator
---
.../solr/core/JavaagentTracerConfigurator.java | 78 +++++++++++-----------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java b/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java
index 74912bf..ab2c2de 100644
--- a/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java
+++ b/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java
@@ -1,39 +1,39 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one or more
-// * contributor license agreements. See the NOTICE file distributed with
-// * this work for additional information regarding copyright ownership.
-// * The ASF licenses this file to You under the Apache License, Version 2.0
-// * (the "License"); you may not use this file except in compliance with
-// * the License. You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-// */
-//
-//package org.apache.solr.core;
-//
-//import io.opentracing.Tracer;
-//import io.opentracing.noop.NoopTracerFactory;
-//import io.opentracing.util.GlobalTracer;
-//import org.apache.solr.common.util.NamedList;
-//
-//public class JavaagentTracerConfigurator extends TracerConfigurator {
-//
-// @Override
-// public Tracer getTracer() {
-// if (GlobalTracer.get() != null) {
-// return GlobalTracer.get();
-// }
-// return NoopTracerFactory.create();
-// }
-//
-// @Override
-// public void init(NamedList args) {
-//
-// }
-//}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import io.opentracing.Tracer;
+import io.opentracing.noop.NoopTracerFactory;
+import io.opentracing.util.GlobalTracer;
+import org.apache.solr.common.util.NamedList;
+
+public class JavaagentTracerConfigurator extends TracerConfigurator {
+
+ @Override
+ public Tracer getTracer() {
+ if (GlobalTracer.get() != null) {
+ return GlobalTracer.get();
+ }
+ return NoopTracerFactory.create();
+ }
+
+ @Override
+ public void init(NamedList args) {
+
+ }
+}
[lucene-solr] 05/05: SOLR-13434: Remove .DS_Store
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a commit to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 7e981464efd0bf9884681d63eea58cb296986047
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Thu May 23 16:43:40 2019 +0100
SOLR-13434: Remove .DS_Store
---
solr/core/src/test-files/solr/configsets/.DS_Store | Bin 6148 -> 0 bytes
.../solr/configsets/cloud-minimal-tracing/.DS_Store | Bin 6148 -> 0 bytes
.../test-files/solr/configsets/cloud-minimal/.DS_Store | Bin 6148 -> 0 bytes
3 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/solr/core/src/test-files/solr/configsets/.DS_Store b/solr/core/src/test-files/solr/configsets/.DS_Store
deleted file mode 100644
index 31cc654..0000000
Binary files a/solr/core/src/test-files/solr/configsets/.DS_Store and /dev/null differ
diff --git a/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store b/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store
deleted file mode 100644
index 1bb1d1e..0000000
Binary files a/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store and /dev/null differ
diff --git a/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store b/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store
deleted file mode 100644
index 1bb1d1e..0000000
Binary files a/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store and /dev/null differ
[lucene-solr] 01/05: SOLR-13434: Initial commit
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
datcm pushed a commit to branch jira/SOLR-13434
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit b90883e58860c903bdbd43c18fecef9da96fe467
Author: Cao Manh Dat <da...@apache.org>
AuthorDate: Thu May 23 15:48:32 2019 +0100
SOLR-13434: Initial commit
---
.../Solr_jaeger_tracer_configurator_library.xml | 10 ++
dev-tools/idea/.idea/modules.xml | 1 +
.../jaegertracer-configurator.iml | 37 +++++++
.../solr/test-framework/solr-test-framework.iml | 1 +
.../jaegertracer-configurator/pom.xml.template | 80 ++++++++++++++
lucene/ivy-versions.properties | 12 +++
solr/contrib/jaegertracer-configurator/build.xml | 34 ++++++
solr/contrib/jaegertracer-configurator/ivy.xml | 32 ++++++
.../org/apache/solr/JaegerTracerConfigurator.java | 91 ++++++++++++++++
.../test-files/solr/collection1/conf/schema.xml | 29 +++++
.../solr/collection1/conf/solrconfig.xml | 51 +++++++++
.../src/test-files/solr/solr.xml | 32 ++++++
.../src/test-files/solr/temp.xml | 0
.../org/apache/solr/TestJaegerConfigurator.java | 113 ++++++++++++++++++++
solr/core/ivy.xml | 4 +
.../java/org/apache/solr/core/CoreContainer.java | 1 +
.../solr/core/JavaagentTracerConfigurator.java | 39 +++++++
.../src/java/org/apache/solr/core/NodeConfig.java | 17 ++-
.../java/org/apache/solr/core/SolrXmlConfig.java | 6 ++
.../org/apache/solr/core/TracerConfigurator.java | 45 ++++++++
.../solr/handler/component/HttpShardHandler.java | 13 +++
.../apache/solr/servlet/SolrDispatchFilter.java | 41 +++++++-
.../apache/solr/servlet/SolrRequestParsers.java | 4 +
.../java/org/apache/solr/transport/Transport.java | 56 ++++++++++
.../org/apache/solr/update/SolrCmdDistributor.java | 15 +++
.../org/apache/solr/util/tracing/GlobalTracer.java | 82 +++++++++++++++
.../solr/util/tracing/HttpServletCarrier.java | 90 ++++++++++++++++
.../solr/util/tracing/SolrRequestCarrier.java | 43 ++++++++
.../org/apache/solr/util/tracing/package-info.java | 23 ++++
solr/core/src/test-files/solr/configsets/.DS_Store | Bin 0 -> 6148 bytes
.../configsets/cloud-minimal-tracing/.DS_Store | Bin 0 -> 6148 bytes
.../solr/configsets/cloud-minimal/.DS_Store | Bin 0 -> 6148 bytes
solr/core/src/test-files/solr/solr-tracing.xml | 58 ++++++++++
.../org/apache/solr/cloud/TestCloudRecovery.java | 106 ++++++++++---------
.../apache/solr/cloud/TestDistributedTracing.java | 117 +++++++++++++++++++++
solr/server/ivy.xml | 2 +
.../org/apache/solr/client/solrj/SolrRequest.java | 14 +++
.../solr/client/solrj/impl/Http2SolrClient.java | 24 +++--
.../solr/client/solrj/impl/HttpSolrClient.java | 7 ++
solr/test-framework/ivy.xml | 1 +
.../apache/solr/core/MockTracerConfigurator.java | 35 ++++++
41 files changed, 1302 insertions(+), 64 deletions(-)
diff --git a/dev-tools/idea/.idea/libraries/Solr_jaeger_tracer_configurator_library.xml b/dev-tools/idea/.idea/libraries/Solr_jaeger_tracer_configurator_library.xml
new file mode 100644
index 0000000..f365d75
--- /dev/null
+++ b/dev-tools/idea/.idea/libraries/Solr_jaeger_tracer_configurator_library.xml
@@ -0,0 +1,10 @@
+<component name="libraryTable">
+ <library name="Solr jaeger tracer configurator library">
+ <CLASSES>
+ <root url="file://$PROJECT_DIR$/solr/contrib/jaegertracer-configurator/lib" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ <jarDirectory url="file://$PROJECT_DIR$/solr/contrib/jaegertracer-configurator/lib" recursive="false" />
+ </library>
+</component>
\ No newline at end of file
diff --git a/dev-tools/idea/.idea/modules.xml b/dev-tools/idea/.idea/modules.xml
index 4974f19..9f8221c 100644
--- a/dev-tools/idea/.idea/modules.xml
+++ b/dev-tools/idea/.idea/modules.xml
@@ -59,6 +59,7 @@
<module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/langid/langid.iml" />
<module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/ltr/ltr.iml" />
<module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/prometheus-exporter/prometheus-exporter.iml" />
+ <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/jaegertracer-configurator/jaegertracer-configurator.iml" />
<module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/velocity/velocity.iml" />
</modules>
</component>
diff --git a/dev-tools/idea/solr/contrib/jaegertracer-configurator/jaegertracer-configurator.iml b/dev-tools/idea/solr/contrib/jaegertracer-configurator/jaegertracer-configurator.iml
new file mode 100644
index 0000000..7efc6a8
--- /dev/null
+++ b/dev-tools/idea/solr/contrib/jaegertracer-configurator/jaegertracer-configurator.iml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../../idea-build/solr/contrib/jaegertracer-configurator/classes/java" />
+ <output-test url="file://$MODULE_DIR$/../../../idea-build/solr/contrib/jaegertracer-configurator/classes/test" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test-files" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" scope="TEST" name="JUnit" level="project" />
+ <orderEntry type="library" name="Solr core library" level="project" />
+ <orderEntry type="library" name="Solrj library" level="project" />
+ <orderEntry type="module-library" scope="TEST">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/lib" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ <jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
+ </library>
+ </orderEntry>
+ <orderEntry type="module" scope="TEST" module-name="lucene-test-framework" />
+ <orderEntry type="module" scope="TEST" module-name="solr-test-framework" />
+ <orderEntry type="library" name="Solr core library" level="project" />
+ <orderEntry type="library" name="Solrj library" level="project" />
+ <orderEntry type="library" name="Solr jaeger tracer configurator library" level="project" />
+ <orderEntry type="module" module-name="lucene-core" />
+ <orderEntry type="module" module-name="solr-core" />
+ <orderEntry type="module" module-name="solrj" />
+ <orderEntry type="module" module-name="analysis-common" />
+ </component>
+</module>
diff --git a/dev-tools/idea/solr/test-framework/solr-test-framework.iml b/dev-tools/idea/solr/test-framework/solr-test-framework.iml
index b990f7a..c3da2c9 100644
--- a/dev-tools/idea/solr/test-framework/solr-test-framework.iml
+++ b/dev-tools/idea/solr/test-framework/solr-test-framework.iml
@@ -16,6 +16,7 @@
<orderEntry type="library" name="Solr core library" level="project" />
<orderEntry type="library" name="Solr example library" level="project" />
<orderEntry type="library" name="Solrj library" level="project" />
+ <orderEntry type="library" name="Solr test framework library" level="project" />
<orderEntry type="module" module-name="lucene-test-framework" />
<orderEntry type="module" module-name="analysis-common" />
<orderEntry type="module" module-name="solrj" />
diff --git a/dev-tools/maven/solr/contrib/jaegertracer-configurator/pom.xml.template b/dev-tools/maven/solr/contrib/jaegertracer-configurator/pom.xml.template
new file mode 100644
index 0000000..7234185
--- /dev/null
+++ b/dev-tools/maven/solr/contrib/jaegertracer-configurator/pom.xml.template
@@ -0,0 +1,80 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-parent</artifactId>
+ <version>@version@</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-jaegertracer-configurator</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Solr Jaeger Tracer Configurator Package</name>
+ <description>
+ Apache Solr Jaeger Tracer Configurator Package
+ </description>
+ <properties>
+ <module-directory>solr/contrib/jaegertracer-configurator</module-directory>
+ <relative-top-level>../../../..</relative-top-level>
+ <module-path>${relative-top-level}/${module-directory}</module-path>
+ </properties>
+ <scm>
+ <connection>scm:git:${vc-anonymous-base-url}</connection>
+ <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+ <url>${vc-browse-base-url};f=${module-directory}</url>
+ </scm>
+ <dependencies>
+ <dependency>
+ <!-- lucene-test-framework dependency must be declared before lucene-core -->
+ <!-- This dependency cannot be put into solr-parent, because local -->
+ <!-- dependencies are always ordered before inherited dependencies. -->
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-test-framework</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-test-framework</artifactId>
+ <scope>test</scope>
+ </dependency>
+ @solr-jaegertracer-configurator.internal.dependencies@
+ @solr-jaegertracer-configurator.external.dependencies@
+ @solr-jaegertracer-configurator.internal.test.dependencies@
+ @solr-jaegertracer-configurator.external.test.dependencies@
+ </dependencies>
+ <build>
+ <sourceDirectory>${module-path}/src/java</sourceDirectory>
+ <testSourceDirectory>${module-path}/src/test</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>${module-path}/src/test-files</directory>
+ </testResource>
+ <testResource>
+ <directory>${top-level}/dev-tools/maven/solr</directory>
+ <includes>
+ <include>maven.testlogging.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
+ </build>
+</project>
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index 98c94d7..921e2ec 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -66,9 +66,18 @@ io.dropwizard.metrics.version = 4.0.5
/io.dropwizard.metrics/metrics-jmx = ${io.dropwizard.metrics.version}
/io.dropwizard.metrics/metrics-jvm = ${io.dropwizard.metrics.version}
+io.jaegertracing.version = 0.27.0
+/io.jaegertracing/jaeger-core = ${io.jaegertracing.version}
+/io.jaegertracing/jaeger-thrift = ${io.jaegertracing.version}
+
io.netty.netty-all.version = 4.0.52.Final
/io.netty/netty-all = ${io.netty.netty-all.version}
+io.opentracing.version = 0.31.0
+/io.opentracing/opentracing-api = ${io.opentracing.version}
+/io.opentracing/opentracing-noop = ${io.opentracing.version}
+/io.opentracing/opentracing-util = ${io.opentracing.version}
+
io.prometheus.version = 0.2.0
/io.prometheus/simpleclient = ${io.prometheus.version}
/io.prometheus/simpleclient_common = ${io.prometheus.version}
@@ -182,6 +191,9 @@ org.apache.poi.version = 4.0.0
/org.apache.poi/poi-ooxml-schemas = ${org.apache.poi.version}
/org.apache.poi/poi-scratchpad = ${org.apache.poi.version}
+org.apache.thrift.version = 0.9.2
+/org.apache.thrift/libthrift = ${org.apache.thrift.version}
+
org.apache.tika.version = 1.19.1
/org.apache.tika/tika-core = ${org.apache.tika.version}
/org.apache.tika/tika-java7 = ${org.apache.tika.version}
diff --git a/solr/contrib/jaegertracer-configurator/build.xml b/solr/contrib/jaegertracer-configurator/build.xml
new file mode 100644
index 0000000..c61cb53
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/build.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<project name="solr-jaeger-tracer-configurator" default="default">
+
+ <description>
+ Jaeger tracer configurator for tracing Solr using OpenTracing with Jaeger backend.
+ </description>
+
+ <import file="../contrib-build.xml"/>
+
+ <path id="classpath">
+ <path refid="solr.base.classpath"/>
+ </path>
+
+ <target name="compile-core" depends="solr-contrib-build.compile-core"/>
+
+</project>
diff --git a/solr/contrib/jaegertracer-configurator/ivy.xml b/solr/contrib/jaegertracer-configurator/ivy.xml
new file mode 100644
index 0000000..601fbcd
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/ivy.xml
@@ -0,0 +1,32 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ivy-module version="2.0">
+ <info organisation="org.apache.solr" module="prometheus"/>
+ <configurations defaultconfmapping="compile->master;test->master">
+ <conf name="compile" transitive="false"/>
+ <conf name="test" transitive="false"/>
+ </configurations>
+ <dependencies>
+ <dependency org="io.jaegertracing" name="jaeger-core" rev="${/io.jaegertracing/jaeger-core}" conf="compile"/>
+ <dependency org="io.jaegertracing" name="jaeger-thrift" rev="${/io.jaegertracing/jaeger-thrift}" conf="compile"/>
+ <dependency org="org.apache.thrift" name="libthrift" rev="${/org.apache.thrift/libthrift}" conf="compile"/>
+
+ <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
+ </dependencies>
+</ivy-module>
diff --git a/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java b/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java
new file mode 100644
index 0000000..5548b75
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/src/java/org/apache/solr/JaegerTracerConfigurator.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr;
+
+import io.jaegertracing.Configuration;
+import io.jaegertracing.samplers.ConstSampler;
+import io.opentracing.Tracer;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.TracerConfigurator;
+
+import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
+
+public class JaegerTracerConfigurator extends TracerConfigurator {
+ public static final String AGENT_HOST = "agentHost";
+ public static final String AGENT_PORT = "agentPort";
+ public static final String LOG_SPANS = "logSpans";
+ public static final String FLUSH_INTERVAL = "flushInterval";
+ public static final String MAX_QUEUE_SIZE = "maxQueueSize";
+
+ private volatile Tracer tracer;
+
+ @Override
+ public Tracer getTracer() {
+ return tracer;
+ }
+
+ @Override
+ public void init(NamedList args) {
+ Object host = args.get(AGENT_HOST);
+ if (!(host instanceof String)) {
+ throw new IllegalArgumentException("Expected a required string for param '" + AGENT_HOST + "'");
+ }
+
+ Object portArg = args.get(AGENT_PORT);
+ if (!(portArg instanceof Integer)) {
+ throw new IllegalArgumentException("Expected a required int for param '" + AGENT_PORT + "'");
+ }
+ int port = (Integer) portArg;
+
+ Boolean logSpans = args.getBooleanArg(LOG_SPANS);
+ if (logSpans == null)
+ logSpans = true;
+
+ Object flushIntervalArg = args.get(FLUSH_INTERVAL);
+ if (flushIntervalArg != null && !(flushIntervalArg instanceof Integer)) {
+ throw new IllegalArgumentException("Expected a required int for param '" + FLUSH_INTERVAL +"'");
+ }
+ int flushInterval = flushIntervalArg == null ? 1000 : (Integer) flushIntervalArg;
+
+ Object maxQueueArgs = args.get(MAX_QUEUE_SIZE);
+ if (maxQueueArgs != null && !(maxQueueArgs instanceof Integer)) {
+ throw new IllegalArgumentException("Expected a required int for param '" + MAX_QUEUE_SIZE +"'");
+ }
+ int maxQueue = maxQueueArgs == null ? 10000 : (Integer) maxQueueArgs;
+
+ Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration()
+ .withType(ConstSampler.TYPE)
+ .withParam(1);
+ Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration()
+ .withAgentHost(host.toString())
+ .withAgentPort(port);
+
+ Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration()
+ .withLogSpans(logSpans)
+ .withFlushInterval(flushInterval)
+ .withMaxQueueSize(maxQueue)
+ .withSender(senderConfig);
+ tracer = new Configuration("solr")
+ .withSampler(samplerConfig)
+ .withReporter(reporterConfig)
+ .getTracer();
+ }
+
+
+}
diff --git a/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/schema.xml b/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/schema.xml
new file mode 100644
index 0000000..4124fea
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/schema.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<schema name="minimal" version="1.1">
+ <fieldType name="string" class="solr.StrField"/>
+ <fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+ <fieldType name="long" class="${solr.tests.LongFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
+ <dynamicField name="*" type="string" indexed="true" stored="true"/>
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="id" type="string" indexed="true" stored="true"/>
+ <dynamicField name="*_s" type="string" indexed="true" stored="true" />
+ <uniqueKey>id</uniqueKey>
+</schema>
diff --git a/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/solrconfig.xml b/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/solrconfig.xml
new file mode 100644
index 0000000..853ba65
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/src/test-files/solr/collection1/conf/solrconfig.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${solr.commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <updateLog class="${solr.ulog:solr.UpdateLog}"></updateLog>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+ <indexConfig>
+ <mergeScheduler class="${solr.mscheduler:org.apache.lucene.index.ConcurrentMergeScheduler}"/>
+: </indexConfig>
+</config>
+
diff --git a/solr/contrib/jaegertracer-configurator/src/test-files/solr/solr.xml b/solr/contrib/jaegertracer-configurator/src/test-files/solr/solr.xml
new file mode 100644
index 0000000..2a04bb3
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/src/test-files/solr/solr.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ solr.xml mimicking the old default solr.xml
+-->
+
+<solr>
+ <tracerConfig name="tracerConfig" class="org.apache.solr.JaegerTracerConfigurator">
+ <double name="sampleRate">100.0</double>
+ <str name="agentHost">localhost</str>
+ <int name="agentPort">5775</int>
+ <bool name="logSpans">true</bool>
+ <int name="flushInterval">1000</int>
+ <int name="maxQueueSize">10000</int>
+ </tracerConfig>
+</solr>
\ No newline at end of file
diff --git a/solr/contrib/jaegertracer-configurator/src/test-files/solr/temp.xml b/solr/contrib/jaegertracer-configurator/src/test-files/solr/temp.xml
new file mode 100644
index 0000000..e69de29
diff --git a/solr/contrib/jaegertracer-configurator/src/test/org/apache/solr/TestJaegerConfigurator.java b/solr/contrib/jaegertracer-configurator/src/test/org/apache/solr/TestJaegerConfigurator.java
new file mode 100644
index 0000000..b91a39e
--- /dev/null
+++ b/solr/contrib/jaegertracer-configurator/src/test/org/apache/solr/TestJaegerConfigurator.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.util.tracing.GlobalTracer;
+import org.junit.Test;
+
+import static org.apache.solr.JaegerTracerConfigurator.AGENT_HOST;
+import static org.apache.solr.JaegerTracerConfigurator.AGENT_PORT;
+import static org.apache.solr.JaegerTracerConfigurator.FLUSH_INTERVAL;
+import static org.apache.solr.JaegerTracerConfigurator.LOG_SPANS;
+import static org.apache.solr.JaegerTracerConfigurator.MAX_QUEUE_SIZE;
+
+public class TestJaegerConfigurator extends SolrTestCaseJ4 {
+
+ @Test
+ public void testInjected() throws Exception{
+ File homeDir = createTempDir("inst").toFile();
+ FileUtils.copyFile(getFile("solr/solr.xml"), new File(homeDir, "solr.xml"));
+ JettySolrRunner jetty = new JettySolrRunner(
+ homeDir.toString(), buildJettyConfig("/solr"));
+ jetty.start();
+ assertTrue(GlobalTracer.get() instanceof io.jaegertracing.Tracer);
+ jetty.stop();
+ }
+
+ //TODO add integration test with Jaeger run on a container
+
+ @Test
+ public void testRequiredParameters() throws IOException {
+ JaegerTracerConfigurator configurator = new JaegerTracerConfigurator();
+ NamedList initArgs = new NamedList();
+ IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(AGENT_HOST) || exc.getMessage().contains(AGENT_PORT));
+ initArgs.add(AGENT_HOST, "localhost");
+
+ exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(AGENT_PORT));
+ initArgs.add(AGENT_PORT, 5775);
+
+ // no exception should be thrown
+ configurator.init(initArgs);
+ ((Closeable)configurator.getTracer()).close();
+
+ initArgs.add(LOG_SPANS, true);
+ initArgs.add(FLUSH_INTERVAL, 1000);
+ initArgs.add(MAX_QUEUE_SIZE, 10000);
+ configurator.init(initArgs);
+ ((Closeable)configurator.getTracer()).close();
+ }
+
+ @Test
+ public void testIncorrectFormat() {
+ JaegerTracerConfigurator configurator = new JaegerTracerConfigurator();
+ NamedList initArgs = new NamedList();
+ initArgs.add(AGENT_HOST, 100);
+ initArgs.add(AGENT_PORT, 5775);
+
+ IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(AGENT_HOST));
+
+ initArgs.clear();
+ initArgs.add(AGENT_HOST, "localhost");
+ initArgs.add(AGENT_PORT, "5775");
+ exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(AGENT_PORT));
+
+ initArgs.clear();
+ initArgs.add(AGENT_HOST, "localhost");
+ initArgs.add(AGENT_PORT, 5775);
+ initArgs.add(LOG_SPANS, 10);
+ SolrException solrExc = expectThrows(SolrException.class, () -> configurator.init(initArgs));
+ assertTrue(solrExc.getMessage().contains(LOG_SPANS));
+
+ initArgs.clear();
+ initArgs.add(AGENT_HOST, "localhost");
+ initArgs.add(AGENT_PORT, 5775);
+ initArgs.add(FLUSH_INTERVAL, "10");
+ exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(FLUSH_INTERVAL));
+
+ initArgs.clear();
+ initArgs.add(AGENT_HOST, "localhost");
+ initArgs.add(AGENT_PORT, 5775);
+ initArgs.add(MAX_QUEUE_SIZE, "10");
+ exc = expectThrows(IllegalArgumentException.class, () -> configurator.init(initArgs));
+ assertTrue(exc.getMessage().contains(MAX_QUEUE_SIZE));
+
+ }
+}
diff --git a/solr/core/ivy.xml b/solr/core/ivy.xml
index ce3c356..ca35499 100644
--- a/solr/core/ivy.xml
+++ b/solr/core/ivy.xml
@@ -30,6 +30,10 @@
</configurations>
<dependencies>
+ <dependency org="io.opentracing" name="opentracing-api" rev="${/io.opentracing/opentracing-api}" conf="compile"/>
+ <dependency org="io.opentracing" name="opentracing-noop" rev="${/io.opentracing/opentracing-noop}" conf="compile"/>
+ <dependency org="io.opentracing" name="opentracing-util" rev="${/io.opentracing/opentracing-util}" conf="compile"/>
+
<dependency org="commons-codec" name="commons-codec" rev="${/commons-codec/commons-codec}" conf="compile"/>
<dependency org="commons-io" name="commons-io" rev="${/commons-io/commons-io}" conf="compile"/>
<dependency org="org.apache.commons" name="commons-exec" rev="${/org.apache.commons/commons-exec}" conf="compile"/>
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index abaaf92..131372a 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -579,6 +579,7 @@ public class CoreContainer {
public void load() {
log.debug("Loading cores into CoreContainer [instanceDir={}]", loader.getInstancePath());
+ TracerConfigurator.loadTracer(loader, cfg.getTracerConfiguratorPluginInfo());
// add the sharedLib to the shared resource loader before initializing cfg based plugins
String libDir = cfg.getSharedLibDirectory();
if (libDir != null) {
diff --git a/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java b/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java
new file mode 100644
index 0000000..74912bf
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/core/JavaagentTracerConfigurator.java
@@ -0,0 +1,39 @@
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (the "License"); you may not use this file except in compliance with
+// * the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package org.apache.solr.core;
+//
+//import io.opentracing.Tracer;
+//import io.opentracing.noop.NoopTracerFactory;
+//import io.opentracing.util.GlobalTracer;
+//import org.apache.solr.common.util.NamedList;
+//
+//public class JavaagentTracerConfigurator extends TracerConfigurator {
+//
+// @Override
+// public Tracer getTracer() {
+// if (GlobalTracer.get() != null) {
+// return GlobalTracer.get();
+// }
+// return NoopTracerFactory.create();
+// }
+//
+// @Override
+// public void init(NamedList args) {
+//
+// }
+//}
diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
index 186b8e5..62c2a98 100644
--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
@@ -77,6 +77,8 @@ public class NodeConfig {
private final PluginInfo transientCacheConfig;
+ private final PluginInfo tracerConfig;
+
private NodeConfig(String nodeName, Path coreRootDirectory, Path solrDataHome, Integer booleanQueryMaxClauseCount,
Path configSetBaseDirectory, String sharedLibDirectory,
PluginInfo shardHandlerFactoryConfig, UpdateShardHandlerConfig updateShardHandlerConfig,
@@ -85,7 +87,7 @@ public class NodeConfig {
LogWatcherConfig logWatcherConfig, CloudConfig cloudConfig, Integer coreLoadThreads, int replayUpdatesThreads,
int transientCacheSize, boolean useSchemaCache, String managementPath, SolrResourceLoader loader,
Properties solrProperties, PluginInfo[] backupRepositoryPlugins,
- MetricsConfig metricsConfig, PluginInfo transientCacheConfig) {
+ MetricsConfig metricsConfig, PluginInfo transientCacheConfig, PluginInfo tracerConfig) {
this.nodeName = nodeName;
this.coreRootDirectory = coreRootDirectory;
this.solrDataHome = solrDataHome;
@@ -111,6 +113,7 @@ public class NodeConfig {
this.backupRepositoryPlugins = backupRepositoryPlugins;
this.metricsConfig = metricsConfig;
this.transientCacheConfig = transientCacheConfig;
+ this.tracerConfig = tracerConfig;
if (this.cloudConfig != null && this.getCoreLoadThreadCount(false) < 2) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
@@ -226,6 +229,10 @@ public class NodeConfig {
public PluginInfo getTransientCachePluginInfo() { return transientCacheConfig; }
+ public PluginInfo getTracerConfiguratorPluginInfo() {
+ return tracerConfig;
+ }
+
public static class NodeConfigBuilder {
private Path coreRootDirectory;
@@ -253,6 +260,7 @@ public class NodeConfig {
private PluginInfo[] backupRepositoryPlugins;
private MetricsConfig metricsConfig;
private PluginInfo transientCacheConfig;
+ private PluginInfo tracerConfig;
private final SolrResourceLoader loader;
private final String nodeName;
@@ -410,12 +418,17 @@ public class NodeConfig {
return this;
}
+ public NodeConfigBuilder setTracerConfig(PluginInfo tracerConfig) {
+ this.tracerConfig = tracerConfig;
+ return this;
+ }
+
public NodeConfig build() {
return new NodeConfig(nodeName, coreRootDirectory, solrDataHome, booleanQueryMaxClauseCount,
configSetBaseDirectory, sharedLibDirectory, shardHandlerFactoryConfig,
updateShardHandlerConfig, coreAdminHandlerClass, collectionsAdminHandlerClass, healthCheckHandlerClass, infoHandlerClass, configSetsHandlerClass,
logWatcherConfig, cloudConfig, coreLoadThreads, replayUpdatesThreads, transientCacheSize, useSchemaCache, managementPath, loader, solrProperties,
- backupRepositoryPlugins, metricsConfig, transientCacheConfig);
+ backupRepositoryPlugins, metricsConfig, transientCacheConfig, tracerConfig);
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
index eb81ed9..3be075f 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -100,6 +100,7 @@ public class SolrXmlConfig {
configBuilder.setUpdateShardHandlerConfig(updateConfig);
configBuilder.setShardHandlerFactoryConfig(getShardHandlerFactoryPluginInfo(config));
configBuilder.setSolrCoreCacheFactoryConfig(getTransientCoreCacheFactoryPluginInfo(config));
+ configBuilder.setTracerConfig(getTracerPluginInfo(config));
configBuilder.setLogWatcherConfig(loadLogWatcherConfig(config, "solr/logging/*[@name]", "solr/logging/watcher/*[@name]"));
configBuilder.setSolrProperties(loadProperties(config));
if (cloudConfig != null)
@@ -553,4 +554,9 @@ public class SolrXmlConfig {
Node node = config.getNode("solr/transientCoreCacheFactory", false);
return (node == null) ? null : new PluginInfo(node, "transientCoreCacheFactory", false, true);
}
+
+ private static PluginInfo getTracerPluginInfo(XmlConfigFile config) {
+ Node node = config.getNode("solr/tracerConfig", false);
+ return (node == null) ? null : new PluginInfo(node, "tracerConfig", false, true);
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/core/TracerConfigurator.java b/solr/core/src/java/org/apache/solr/core/TracerConfigurator.java
new file mode 100644
index 0000000..3358e8b
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/core/TracerConfigurator.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import io.opentracing.Tracer;
+import io.opentracing.noop.NoopTracerFactory;
+import org.apache.solr.util.plugin.NamedListInitializedPlugin;
+import org.apache.solr.util.tracing.GlobalTracer;
+
+public abstract class TracerConfigurator implements NamedListInitializedPlugin {
+
+ public abstract Tracer getTracer();
+
+ public static void loadTracer(SolrResourceLoader loader, PluginInfo info) {
+ if (info == null) {
+ GlobalTracer.setup(NoopTracerFactory.create(), 0.0);
+ } else {
+ TracerConfigurator configurator = loader
+ .newInstance(info.className, TracerConfigurator.class);
+ configurator.init(info.initArgs);
+
+ double sampleRate = 1.0;
+ Object sampleRateObj = info.initArgs.get("sampleRate");
+ if (sampleRateObj != null) {
+ sampleRate = Double.parseDouble(sampleRateObj.toString());
+ }
+ GlobalTracer.setup(configurator.getTracer(), sampleRate);
+ }
+ }
+}
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index 3943d28..f71b124 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -33,6 +34,11 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
+
+import io.opentracing.Span;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMap;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
@@ -60,6 +66,8 @@ import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestInfo;
+import org.apache.solr.util.tracing.GlobalTracer;
+import org.apache.solr.util.tracing.SolrRequestCarrier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -147,6 +155,8 @@ public class HttpShardHandler extends ShardHandler {
public void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {
// do this outside of the callable for thread safety reasons
final List<String> urls = getURLs(shard);
+ final Tracer tracer = GlobalTracer.get();
+ final Span span = tracer != null? tracer.activeSpan() : null;
Callable<ShardResponse> task = () -> {
@@ -165,6 +175,9 @@ public class HttpShardHandler extends ShardHandler {
params.remove(CommonParams.VERSION);
QueryRequest req = makeQueryRequest(sreq, params, shard);
+ if (tracer != null && span != null) {
+ tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new SolrRequestCarrier(req));
+ }
req.setMethod(SolrRequest.METHOD.POST);
SolrRequestInfo requestInfo = SolrRequestInfo.getRequestInfo();
if (requestInfo != null) req.setUserPrincipal(requestInfo.getReq().getUserPrincipal());
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 5ebd2ca..3292f34 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.ByteArrayInputStream;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -40,6 +41,8 @@ import java.nio.file.Paths;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
@@ -53,6 +56,12 @@ import com.codahale.metrics.jvm.ClassLoadingGaugeSet;
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
+import io.opentracing.Scope;
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMapExtractAdapter;
+import io.opentracing.tag.Tags;
import org.apache.commons.io.FileCleaningTracker;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
@@ -77,6 +86,7 @@ import org.apache.solr.security.AuthenticationPlugin;
import org.apache.solr.security.PKIAuthenticationPlugin;
import org.apache.solr.security.PublicKeyHandler;
import org.apache.solr.util.SolrFileCleaningTracker;
+import org.apache.solr.util.tracing.GlobalTracer;
import org.apache.solr.util.StartupLoggingUtils;
import org.apache.solr.util.configuration.SSLConfigurationsFactory;
import org.slf4j.Logger;
@@ -336,6 +346,14 @@ public class SolrDispatchFilter extends BaseSolrFilter {
cc.shutdown();
}
}
+
+ if (GlobalTracer.get() instanceof Closeable) {
+ try {
+ ((Closeable) GlobalTracer.get()).close();
+ } catch (IOException e) {
+ log.warn("Exception closing Tracer", e);
+ }
+ }
}
@Override
@@ -347,7 +365,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
if (!(_request instanceof HttpServletRequest)) return;
HttpServletRequest request = closeShield((HttpServletRequest)_request, retry);
HttpServletResponse response = closeShield((HttpServletResponse)_response, retry);
-
+ Scope scope = null;
try {
if (cores == null || cores.isShutDown()) {
@@ -362,9 +380,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}
}
+ String requestPath = request.getServletPath();
// No need to even create the HttpSolrCall object if this path is excluded.
if (excludePatterns != null) {
- String requestPath = request.getServletPath();
String extraPath = request.getPathInfo();
if (extraPath != null) {
// In embedded mode, servlet path is empty - include all post-context path here for testing
@@ -379,6 +397,23 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}
}
+ SpanContext parentSpan = GlobalTracer.extract(request);
+ Tracer tracer = GlobalTracer.get();
+
+ Tracer.SpanBuilder spanBuilder = null;
+ String hostAndPort = request.getServerName() + "_" + request.getServerPort();
+ if (parentSpan == null) {
+ spanBuilder = tracer.buildSpan(request.getMethod() + ":" + hostAndPort);
+ } else {
+ spanBuilder = tracer.buildSpan(request.getMethod() + ":" + hostAndPort)
+ .asChildOf(parentSpan);
+ }
+
+ spanBuilder
+ .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
+ .withTag(Tags.HTTP_URL.getKey(), request.getRequestURL().toString());
+ scope = spanBuilder.startActive(true);
+
AtomicReference<HttpServletRequest> wrappedRequest = new AtomicReference<>();
if (!authenticateRequest(request, response, wrappedRequest)) { // the response and status code have already been sent
return;
@@ -417,6 +452,8 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}
} finally {
consumeInputFully(request);
+ if (scope != null)
+ scope.close();
}
}
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
index 8a664c4..796daac 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
@@ -61,6 +61,7 @@ import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.util.RTimerTree;
import org.apache.solr.util.SolrFileCleaningTracker;
+import org.apache.solr.util.tracing.GlobalTracer;
import static org.apache.solr.common.params.CommonParams.PATH;
@@ -165,6 +166,9 @@ public class SolrRequestParsers
// Pick the parser from the request...
ArrayList<ContentStream> streams = new ArrayList<>(1);
SolrParams params = parser.parseParamsAndFillStreams( req, streams );
+ if (GlobalTracer.tracing()) {
+ GlobalTracer.get().activeSpan().setTag("params", params.toString());
+ }
SolrQueryRequest sreq = buildRequestFrom(core, params, streams, getRequestTimer(req), req);
// Handlers and login will want to know the path. If it contains a ':'
diff --git a/solr/core/src/java/org/apache/solr/transport/Transport.java b/solr/core/src/java/org/apache/solr/transport/Transport.java
new file mode 100644
index 0000000..e8407db
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/transport/Transport.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.transport;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.Http2SolrClient;
+import org.apache.solr.client.solrj.impl.LBHttp2SolrClient;
+import org.apache.solr.client.solrj.impl.LBSolrClient;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.common.util.NamedList;
+
+public class Transport {
+ protected volatile Http2SolrClient defaultClient;
+ private LBHttp2SolrClient loadbalancer;
+ int permittedLoadBalancerRequestsMinimumAbsolute = 0;
+ float permittedLoadBalancerRequestsMaximumFraction = 1.0f;
+
+ public NamedList<Object> request(final String url, SolrRequest solrRequest) throws IOException, SolrServerException {
+ //TODO changes this into a method of http2solrclient
+ solrRequest.setBasePath(url);
+ return defaultClient.request(solrRequest);
+ }
+
+ public LBSolrClient.Rsp request(QueryRequest solrRequest, final List<String> urls) throws IOException, SolrServerException {
+ return loadbalancer.request(newLBHttpSolrClientReq(solrRequest, urls));
+ }
+
+
+
+ protected LBSolrClient.Req newLBHttpSolrClientReq(final QueryRequest req, List<String> urls) {
+ int numServersToTry = (int)Math.floor(urls.size() * this.permittedLoadBalancerRequestsMaximumFraction);
+ if (numServersToTry < this.permittedLoadBalancerRequestsMinimumAbsolute) {
+ numServersToTry = this.permittedLoadBalancerRequestsMinimumAbsolute;
+ }
+ return new LBSolrClient.Req(req, urls, numServersToTry);
+ }
+}
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index 355154b..ce9e41b 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -27,12 +27,18 @@ import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Future;
+import io.opentracing.Span;
+import io.opentracing.Tracer;
+import io.opentracing.propagation.Format;
+import io.opentracing.propagation.TextMap;
import org.apache.http.NoHttpResponseException;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
@@ -50,6 +56,8 @@ import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.apache.solr.update.processor.DistributedUpdateProcessor.LeaderRequestReplicationTracker;
import org.apache.solr.update.processor.DistributedUpdateProcessor.RollupRequestReplicationTracker;
+import org.apache.solr.util.tracing.GlobalTracer;
+import org.apache.solr.util.tracing.SolrRequestCarrier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -285,6 +293,13 @@ public class SolrCmdDistributor implements Closeable {
req.uReq.setUserPrincipal(SolrRequestInfo.getRequestInfo().getReq().getUserPrincipal());
}
+ Tracer tracer = GlobalTracer.get();
+ Span parentSpan = tracer.activeSpan();
+ if (parentSpan != null) {
+ tracer.inject(parentSpan.context(), Format.Builtin.HTTP_HEADERS,
+ new SolrRequestCarrier(req.uReq));
+ }
+
if (req.synchronous) {
blockAndDoRetries();
diff --git a/solr/core/src/java/org/apache/solr/util/tracing/GlobalTracer.java b/solr/core/src/java/org/apache/solr/util/tracing/GlobalTracer.java
new file mode 100644
index 0000000..03fda7f
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/util/tracing/GlobalTracer.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.util.tracing;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Random;
+
+import io.opentracing.SpanContext;
+import io.opentracing.Tracer;
+import io.opentracing.noop.NoopTracerFactory;
+import io.opentracing.propagation.Format;
+
+public class GlobalTracer {
+ private static final Random RANDOM;
+ static {
+ // We try to make things reproducible in the context of our tests by initializing the random instance
+ // based on the current seed
+ String seed = System.getProperty("tests.seed");
+ if (seed == null) {
+ RANDOM = new Random();
+ } else {
+ RANDOM = new Random(seed.hashCode());
+ }
+ }
+
+ private static final Tracer NOOP_TRACER = NoopTracerFactory.create();
+ private static volatile Tracer TRACER = NOOP_TRACER;
+ private static volatile int rate;
+ private final static ThreadLocal<Tracer> threadLocal = new ThreadLocal<>();
+
+ public static void setup(Tracer tracer, double rate) {
+ GlobalTracer.rate = (int) (rate * 10);
+ GlobalTracer.TRACER = tracer;
+ }
+
+ public static boolean tracing() {
+ return threadLocal.get() != null
+ && threadLocal.get() != NOOP_TRACER
+ && threadLocal.get().activeSpan() != null;
+ }
+
+ public static SpanContext extract(HttpServletRequest request) {
+ SpanContext spanContext = TRACER.extract(Format.Builtin.HTTP_HEADERS, new HttpServletCarrier(request));
+ if (spanContext != null) {
+ threadLocal.set(TRACER);
+ }
+ return spanContext;
+ }
+
+ public static Tracer get() {
+ Tracer tracer = threadLocal.get();
+ if (tracer != null)
+ return tracer;
+
+ if (traced()) {
+ threadLocal.set(TRACER);
+ } else {
+ threadLocal.set(NOOP_TRACER);
+ }
+
+ return threadLocal.get();
+ }
+
+ private static boolean traced() {
+ return RANDOM.nextInt(1000) < rate;
+ }
+}
diff --git a/solr/core/src/java/org/apache/solr/util/tracing/HttpServletCarrier.java b/solr/core/src/java/org/apache/solr/util/tracing/HttpServletCarrier.java
new file mode 100644
index 0000000..059683d
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/util/tracing/HttpServletCarrier.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.util.tracing;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import io.opentracing.propagation.TextMap;
+
+public class HttpServletCarrier implements TextMap {
+ private Iterator<Map.Entry<String, String>> it;
+
+ public HttpServletCarrier(HttpServletRequest request) {
+ this.it = new Iterator<>() {
+
+ Enumeration<String> headerNameIt = request.getHeaderNames();
+ String headerName = null;
+ Enumeration<String> headerValue = null;
+
+ @Override
+ public boolean hasNext() {
+ if (headerValue != null && headerValue.hasMoreElements()) {
+ return true;
+ }
+
+ return headerNameIt.hasMoreElements();
+ }
+
+ @Override
+ public Map.Entry<String, String> next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ if (headerValue == null || !headerValue.hasMoreElements()) {
+ headerName = headerNameIt.nextElement();
+ headerValue = request.getHeaders(headerName);
+ }
+
+ String key = headerName;
+ String val = headerValue.nextElement();
+
+ return new Map.Entry<>() {
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public String getValue() {
+ return val;
+ }
+
+ @Override
+ public String setValue(String value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public Iterator<Map.Entry<String, String>> iterator() {
+ return it;
+ }
+
+ @Override
+ public void put(String key, String value) {
+ throw new UnsupportedOperationException("HttpServletCarrier should only be used with Tracer.extract()");
+ }
+}
diff --git a/solr/core/src/java/org/apache/solr/util/tracing/SolrRequestCarrier.java b/solr/core/src/java/org/apache/solr/util/tracing/SolrRequestCarrier.java
new file mode 100644
index 0000000..cab110b
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/util/tracing/SolrRequestCarrier.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.util.tracing;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import io.opentracing.propagation.TextMap;
+import org.apache.solr.client.solrj.SolrRequest;
+
+public class SolrRequestCarrier implements TextMap {
+
+ private final SolrRequest solrRequest;
+
+ public SolrRequestCarrier(SolrRequest solrRequest) {
+ this.solrRequest = solrRequest;
+ }
+
+ @Override
+ public Iterator<Map.Entry<String, String>> iterator() {
+ throw new UnsupportedOperationException("carrier is write-only");
+ }
+
+ @Override
+ public void put(String key, String value) {
+ solrRequest.addHeader(key, value);
+ }
+}
diff --git a/solr/core/src/java/org/apache/solr/util/tracing/package-info.java b/solr/core/src/java/org/apache/solr/util/tracing/package-info.java
new file mode 100644
index 0000000..a616d2b
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/util/tracing/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tracing related utilities
+ */
+package org.apache.solr.util.tracing;
+
+
diff --git a/solr/core/src/test-files/solr/configsets/.DS_Store b/solr/core/src/test-files/solr/configsets/.DS_Store
new file mode 100644
index 0000000..31cc654
Binary files /dev/null and b/solr/core/src/test-files/solr/configsets/.DS_Store differ
diff --git a/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store b/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store
new file mode 100644
index 0000000..1bb1d1e
Binary files /dev/null and b/solr/core/src/test-files/solr/configsets/cloud-minimal-tracing/.DS_Store differ
diff --git a/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store b/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store
new file mode 100644
index 0000000..1bb1d1e
Binary files /dev/null and b/solr/core/src/test-files/solr/configsets/cloud-minimal/.DS_Store differ
diff --git a/solr/core/src/test-files/solr/solr-tracing.xml b/solr/core/src/test-files/solr/solr-tracing.xml
new file mode 100644
index 0000000..9cf871d
--- /dev/null
+++ b/solr/core/src/test-files/solr/solr-tracing.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ All (relative) paths are relative to the installation path
+-->
+<solr>
+
+ <str name="shareSchema">${shareSchema:false}</str>
+ <str name="configSetBaseDir">${configSetBaseDir:configsets}</str>
+ <str name="coreRootDirectory">${coreRootDirectory:.}</str>
+
+ <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
+ <str name="urlScheme">${urlScheme:}</str>
+ <int name="socketTimeout">${socketTimeout:15000}</int>
+ <int name="connTimeout">${connTimeout:15000}</int>
+ <str name="shardsWhitelist">${solr.tests.shardsWhitelist:}</str>
+ </shardHandlerFactory>
+
+ <transientCoreCacheFactory name="transientCoreCacheFactory" class="TransientSolrCoreCacheFactoryDefault">
+ <int name="transientCacheSize">4</int>
+ </transientCoreCacheFactory>
+
+ <tracerConfig name="tracerConfig" class="MockTracerConfigurator">
+ <double name="sampleRate">100.0</double>
+ </tracerConfig>
+
+ <solrcloud>
+ <str name="host">127.0.0.1</str>
+ <int name="hostPort">${hostPort:8983}</int>
+ <str name="hostContext">${hostContext:solr}</str>
+ <int name="zkClientTimeout">${solr.zkclienttimeout:60000}</int> <!-- This should be high by default - dc's are expensive -->
+ <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
+ <int name="leaderVoteWait">${leaderVoteWait:15000}</int> <!-- We are running tests - the default should be low, not like production -->
+ <int name="leaderConflictResolveWait">${leaderConflictResolveWait:45000}</int>
+ <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:5000}</int>
+ <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:30000}</int> <!-- We are running tests - the default should be low, not like production -->
+ <int name="autoReplicaFailoverWaitAfterExpiration">${autoReplicaFailoverWaitAfterExpiration:10000}</int>
+ <int name="autoReplicaFailoverWorkLoopDelay">${autoReplicaFailoverWorkLoopDelay:10000}</int>
+ <int name="autoReplicaFailoverBadNodeExpiration">${autoReplicaFailoverBadNodeExpiration:60000}</int>
+ </solrcloud>
+
+</solr>
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudRecovery.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudRecovery.java
index 6204003..fef7945 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudRecovery.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudRecovery.java
@@ -64,7 +64,7 @@ public class TestCloudRecovery extends SolrCloudTestCase {
@Before
public void beforeTest() throws Exception {
- configureCluster(2)
+ configureCluster(4)
.addConfig("config", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
.configure();
@@ -73,10 +73,9 @@ public class TestCloudRecovery extends SolrCloudTestCase {
tlogReplicas = 0; // onlyLeaderIndexes?2:0; TODO: SOLR-12313 tlog replicas break tests because
// TestInjection#waitForInSyncWithLeader is broken
CollectionAdminRequest
- .createCollection(COLLECTION, "config", 2, nrtReplicas, tlogReplicas, 0)
- .setMaxShardsPerNode(2)
+ .createCollection(COLLECTION, "config", 2, 2)
.process(cluster.getSolrClient());
- cluster.waitForActiveCollection(COLLECTION, 2, 2 * (nrtReplicas + tlogReplicas));
+ cluster.waitForActiveCollection(COLLECTION, 2, 4);
// SOLR-12314 : assert that these values are from the solr.xml file and not UpdateShardHandlerConfig#DEFAULT
for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
@@ -105,58 +104,61 @@ public class TestCloudRecovery extends SolrCloudTestCase {
cloudClient.add(COLLECTION, sdoc("id", "2"));
cloudClient.add(COLLECTION, sdoc("id", "3"));
cloudClient.add(COLLECTION, sdoc("id", "4"));
+ cloudClient.commit(COLLECTION);
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("q", "*:*");
- QueryResponse resp = cloudClient.query(COLLECTION, params);
- assertEquals(0, resp.getResults().getNumFound());
-
- ChaosMonkey.stop(cluster.getJettySolrRunners());
-
-
- for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
- cluster.waitForJettyToStop(jettySolrRunner);
- }
- assertTrue("Timeout waiting for all not live", ClusterStateUtil.waitForAllReplicasNotLive(cloudClient.getZkStateReader(), 45000));
- ChaosMonkey.start(cluster.getJettySolrRunners());
-
- cluster.waitForAllNodes(30);
-
- assertTrue("Timeout waiting for all live and active", ClusterStateUtil.waitForAllActiveAndLiveReplicas(cloudClient.getZkStateReader(), COLLECTION, 120000));
-
- resp = cloudClient.query(COLLECTION, params);
- assertEquals(4, resp.getResults().getNumFound());
- // Make sure all nodes is recover from tlog
- if (onlyLeaderIndexes) {
- // Leader election can be kicked off, so 2 tlog replicas will replay its tlog before becoming new leader
- assertTrue( countReplayLog.get() >=2);
- } else {
- assertEquals(4, countReplayLog.get());
- }
-
- // check metrics
- int replicationCount = 0;
- int errorsCount = 0;
- int skippedCount = 0;
- for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
- SolrMetricManager manager = jetty.getCoreContainer().getMetricManager();
- List<String> registryNames = manager.registryNames().stream()
- .filter(s -> s.startsWith("solr.core.")).collect(Collectors.toList());
- for (String registry : registryNames) {
- Map<String, Metric> metrics = manager.registry(registry).getMetrics();
- Timer timer = (Timer)metrics.get("REPLICATION.peerSync.time");
- Counter counter = (Counter)metrics.get("REPLICATION.peerSync.errors");
- Counter skipped = (Counter)metrics.get("REPLICATION.peerSync.skipped");
- replicationCount += timer.getCount();
- errorsCount += counter.getCount();
- skippedCount += skipped.getCount();
- }
- }
- if (onlyLeaderIndexes) {
- assertTrue(replicationCount >= 2);
- } else {
- assertEquals(2, replicationCount);
+ for (int i = 0; i < 10; i++) {
+ cloudClient.query(COLLECTION, params).getResults();
}
+// assertEquals(0, resp.getResults().getNumFound());
+//
+// ChaosMonkey.stop(cluster.getJettySolrRunners());
+//
+//
+// for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
+// cluster.waitForJettyToStop(jettySolrRunner);
+// }
+// assertTrue("Timeout waiting for all not live", ClusterStateUtil.waitForAllReplicasNotLive(cloudClient.getZkStateReader(), 45000));
+// ChaosMonkey.start(cluster.getJettySolrRunners());
+//
+// cluster.waitForAllNodes(30);
+//
+// assertTrue("Timeout waiting for all live and active", ClusterStateUtil.waitForAllActiveAndLiveReplicas(cloudClient.getZkStateReader(), COLLECTION, 120000));
+//
+// resp = cloudClient.query(COLLECTION, params);
+// assertEquals(4, resp.getResults().getNumFound());
+// // Make sure all nodes is recover from tlog
+// if (onlyLeaderIndexes) {
+// // Leader election can be kicked off, so 2 tlog replicas will replay its tlog before becoming new leader
+// assertTrue( countReplayLog.get() >=2);
+// } else {
+// assertEquals(4, countReplayLog.get());
+// }
+//
+// // check metrics
+// int replicationCount = 0;
+// int errorsCount = 0;
+// int skippedCount = 0;
+// for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
+// SolrMetricManager manager = jetty.getCoreContainer().getMetricManager();
+// List<String> registryNames = manager.registryNames().stream()
+// .filter(s -> s.startsWith("solr.core.")).collect(Collectors.toList());
+// for (String registry : registryNames) {
+// Map<String, Metric> metrics = manager.registry(registry).getMetrics();
+// Timer timer = (Timer)metrics.get("REPLICATION.peerSync.time");
+// Counter counter = (Counter)metrics.get("REPLICATION.peerSync.errors");
+// Counter skipped = (Counter)metrics.get("REPLICATION.peerSync.skipped");
+// replicationCount += timer.getCount();
+// errorsCount += counter.getCount();
+// skippedCount += skipped.getCount();
+// }
+// }
+// if (onlyLeaderIndexes) {
+// assertTrue(replicationCount >= 2);
+// } else {
+// assertEquals(2, replicationCount);
+// }
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestDistributedTracing.java b/solr/core/src/test/org/apache/solr/cloud/TestDistributedTracing.java
new file mode 100644
index 0000000..2e8da39
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/TestDistributedTracing.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.cloud;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import io.opentracing.Span;
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.core.MockTracerConfigurator;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestDistributedTracing extends SolrCloudTestCase {
+ private static final String COLLECTION = "collection1";
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @Before
+ public void beforeTest() throws Exception {
+ configureCluster(4)
+ .addConfig("config", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
+ .withSolrXml(TEST_PATH().resolve("solr-tracing.xml"))
+ .configure();
+ CollectionAdminRequest
+ .createCollection(COLLECTION, "config", 2, 2)
+ .process(cluster.getSolrClient());
+ cluster.waitForActiveCollection(COLLECTION, 2, 4);
+ }
+
+ @Test
+ public void test() throws IOException, SolrServerException {
+ CloudSolrClient cloudClient = cluster.getSolrClient();
+ List<MockSpan> allSpans = MockTracerConfigurator.TRACER.finishedSpans();
+
+ cloudClient.add(COLLECTION, sdoc("id", "1"));
+ List<MockSpan> finishedSpans = getRecentSpans(allSpans);
+ finishedSpans.removeIf(x ->
+ !x.tags().get("http.url").toString().endsWith("/update"));
+ assertEquals(2, finishedSpans.size());
+ assertOneSpanIsChildOfAnother(finishedSpans);
+
+ cloudClient.add(COLLECTION, sdoc("id", "2"));
+ finishedSpans = getRecentSpans(allSpans);
+ finishedSpans.removeIf(x ->
+ !x.tags().get("http.url").toString().endsWith("/update"));
+ assertEquals(2, finishedSpans.size());
+ assertOneSpanIsChildOfAnother(finishedSpans);
+
+ cloudClient.add(COLLECTION, sdoc("id", "3"));
+ cloudClient.add(COLLECTION, sdoc("id", "4"));
+ cloudClient.commit(COLLECTION);
+
+ getRecentSpans(allSpans);
+ cloudClient.query(COLLECTION, new SolrQuery("*:*"));
+ finishedSpans = getRecentSpans(allSpans);
+ finishedSpans.removeIf(x ->
+ !x.tags().get("http.url").toString().endsWith("/select"));
+ // one from client to server, 2 for execute query, 2 for fetching documents
+ assertEquals(5, finishedSpans.size());
+ assertEquals(1, finishedSpans.stream().filter(s -> s.parentId() == 0).count());
+ long parentId = finishedSpans.stream()
+ .filter(s -> s.parentId() == 0)
+ .collect(Collectors.toList())
+ .get(0).context().spanId();
+ for (MockSpan span: finishedSpans) {
+ if (span.parentId() != 0 && parentId != span.parentId()) {
+ fail("All spans must belong to single span, but:"+finishedSpans);
+ }
+ }
+ }
+
+ private void assertOneSpanIsChildOfAnother(List<MockSpan> finishedSpans) {
+ MockSpan child = finishedSpans.get(0);
+ MockSpan parent = finishedSpans.get(1);
+ if (child.parentId() == 0) {
+ MockSpan temp = parent;
+ parent = child;
+ child = temp;
+ }
+
+ assertEquals(child.parentId(), parent.context().spanId());
+ }
+
+ private List<MockSpan> getRecentSpans(List<MockSpan> allSpans) {
+ List<MockSpan> result = new ArrayList<>(MockTracerConfigurator.TRACER.finishedSpans());
+ result.removeAll(allSpans);
+ allSpans.clear();
+ allSpans.addAll(MockTracerConfigurator.TRACER.finishedSpans());
+ return result;
+ }
+}
diff --git a/solr/server/ivy.xml b/solr/server/ivy.xml
index 29a66e9..ade751d 100644
--- a/solr/server/ivy.xml
+++ b/solr/server/ivy.xml
@@ -43,6 +43,8 @@
<dependency org="io.dropwizard.metrics" name="metrics-jvm" rev="${/io.dropwizard.metrics/metrics-jvm}" conf="metrics" />
<dependency org="io.dropwizard.metrics" name="metrics-graphite" rev="${/io.dropwizard.metrics/metrics-graphite}" conf="metrics" />
+ <!--io.jaegertracing:jaeger-thrift:jar:0.27.0:compile-->
+ <!--org.apache.thrift:libthrift:jar:0.9.2:compile-->
<dependency org="org.eclipse.jetty" name="jetty-continuation" rev="${/org.eclipse.jetty/jetty-continuation}" conf="jetty"/>
<dependency org="org.eclipse.jetty" name="jetty-deploy" rev="${/org.eclipse.jetty/jetty-deploy}" conf="jetty"/>
<dependency org="org.eclipse.jetty" name="jetty-http" rev="${/org.eclipse.jetty/jetty-http}" conf="jetty"/>
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
index cc2d381..91a9fda 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
@@ -21,7 +21,9 @@ import java.io.Serializable;
import java.security.Principal;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -63,6 +65,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
private METHOD method = METHOD.GET;
private String path = null;
+ private Map<String,String> headers;
private ResponseParser responseParser;
private StreamingResponseCallback callback;
@@ -237,4 +240,15 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
public String getBasePath() {
return basePath;
}
+
+ public void addHeader(String key, String value) {
+ if (headers == null) {
+ headers = new HashMap<>();
+ }
+ headers.put(key, value);
+ }
+
+ public Map<String, String> getHeaders() {
+ return headers;
+ }
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 580a849..e45fd27 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -31,6 +31,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -320,7 +321,7 @@ public class Http2SolrClient extends SolrClient {
.header("User-Agent", HttpSolrClient.AGENT)
.header("Content-Type", contentType)
.content(provider);
- setListeners(updateRequest, postRequest);
+ decorateRequest(postRequest, updateRequest);
InputStreamResponseListener responseListener = new InputStreamResponseListener();
postRequest.send(responseListener);
@@ -452,16 +453,13 @@ public class Http2SolrClient extends SolrClient {
private Request makeRequest(SolrRequest solrRequest, String collection)
throws SolrServerException, IOException {
Request req = createRequest(solrRequest, collection);
- req.header(HttpHeader.ACCEPT_ENCODING, null);
- setListeners(solrRequest, req);
- if (solrRequest.getUserPrincipal() != null) {
- req.attribute(REQ_PRINCIPAL_KEY, solrRequest.getUserPrincipal());
- }
-
+ decorateRequest(req, solrRequest);
return req;
}
- private void setListeners(SolrRequest solrRequest, Request req) {
+ private void decorateRequest(Request req, SolrRequest solrRequest) {
+ req.header(HttpHeader.ACCEPT_ENCODING, null);
+
setBasicAuthHeader(solrRequest, req);
for (HttpListenerFactory factory : listenerFactory) {
HttpListenerFactory.RequestResponseListener listener = factory.get();
@@ -469,6 +467,16 @@ public class Http2SolrClient extends SolrClient {
req.onRequestBegin(listener);
req.onComplete(listener);
}
+
+ if (solrRequest.getUserPrincipal() != null) {
+ req.attribute(REQ_PRINCIPAL_KEY, solrRequest.getUserPrincipal());
+ }
+ Map<String, String> headers = solrRequest.getHeaders();
+ if (headers != null) {
+ for (Map.Entry<String, String> entry : headers.entrySet()) {
+ req.header(entry.getKey(), entry.getValue());
+ }
+ }
}
private Request createRequest(SolrRequest solrRequest, String collection) throws IOException, SolrServerException {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
index d12093b..75db5a1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
@@ -32,6 +32,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -252,6 +253,12 @@ public class HttpSolrClient extends BaseHttpSolrClient {
throws SolrServerException, IOException {
HttpRequestBase method = createMethod(request, collection);
setBasicAuthHeader(request, method);
+ if (request.getHeaders() != null) {
+ Map<String, String> headers = request.getHeaders();
+ for (Map.Entry<String, String> entry : headers.entrySet()) {
+ method.setHeader(entry.getKey(), entry.getValue());
+ }
+ }
return executeMethod(method, request.getUserPrincipal(), processor, isV2ApiRequest(request));
}
diff --git a/solr/test-framework/ivy.xml b/solr/test-framework/ivy.xml
index 018da5d..2301594 100644
--- a/solr/test-framework/ivy.xml
+++ b/solr/test-framework/ivy.xml
@@ -35,6 +35,7 @@
<dependency org="org.hamcrest" name="hamcrest-core" rev="${/org.hamcrest/hamcrest-core}" conf="compile;junit4-stdalone" />
<dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="${/com.carrotsearch.randomizedtesting/junit4-ant}" conf="compile;junit4-stdalone" />
<dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="${/com.carrotsearch.randomizedtesting/randomizedtesting-runner}" conf="compile;junit4-stdalone" />
+ <dependency org="io.opentracing" name="opentracing-mock" rev="${/io.opentracing/opentracing-api}" conf="compile;junit4-stdalone"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
</dependencies>
diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java b/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java
new file mode 100644
index 0000000..983dcc4
--- /dev/null
+++ b/solr/test-framework/src/java/org/apache/solr/core/MockTracerConfigurator.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import io.opentracing.Tracer;
+import io.opentracing.mock.MockTracer;
+import org.apache.solr.common.util.NamedList;
+
+public class MockTracerConfigurator extends TracerConfigurator {
+ public static final MockTracer TRACER = new MockTracer();
+ @Override
+ public Tracer getTracer() {
+ return TRACER;
+ }
+
+ @Override
+ public void init(NamedList args) {
+
+ }
+}