You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/11/17 21:31:18 UTC

[GitHub] [solr] dsmiley commented on a diff in pull request #1168: SOLR-16532 New OTEL module with OTLP trace exporter

dsmiley commented on code in PR #1168:
URL: https://github.com/apache/solr/pull/1168#discussion_r1025744026


##########
solr/modules/opentelemetry/src/java/org/apache/solr/opentelemetry/OtelTracerConfigurator.java:
##########
@@ -0,0 +1,29 @@
+package org.apache.solr.opentelemetry;
+
+import io.opentelemetry.opentracingshim.OpenTracingShim;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+import io.opentracing.Tracer;
+import org.apache.solr.core.TracerConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.invoke.MethodHandles;
+
+public class OtelTracerConfigurator extends TracerConfigurator {
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  @Override
+  public Tracer getTracer() {
+    // TODO: Find better way to set defaults
+    System.setProperty("OTEL_SERVICE_NAME", "solr");
+    System.setProperty("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc");
+    System.setProperty("OTEL_TRACES_SAMPLER", "parentbased_always_on");
+    System.setProperty("OTEL_TRACES_EXPORTER", "otlp");
+    // Need to disable the exporters for metrics and logs
+    System.setProperty("OTEL_METRICS_EXPORTER", "none");
+    System.setProperty("OTEL_LOGS_EXPORTER", "none");
+    log.info("Configuring tracer {}...", getClass().getName());

Review Comment:
   This line looks generic; could be called by Solr once instead of each impl doing this.



##########
solr/modules/opentelemetry/src/java/org/apache/solr/opentelemetry/OtelTracerConfigurator.java:
##########
@@ -0,0 +1,29 @@
+package org.apache.solr.opentelemetry;
+
+import io.opentelemetry.opentracingshim.OpenTracingShim;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
+import io.opentracing.Tracer;
+import org.apache.solr.core.TracerConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.invoke.MethodHandles;
+
+public class OtelTracerConfigurator extends TracerConfigurator {
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  @Override
+  public Tracer getTracer() {
+    // TODO: Find better way to set defaults
+    System.setProperty("OTEL_SERVICE_NAME", "solr");
+    System.setProperty("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc");
+    System.setProperty("OTEL_TRACES_SAMPLER", "parentbased_always_on");
+    System.setProperty("OTEL_TRACES_EXPORTER", "otlp");
+    // Need to disable the exporters for metrics and logs
+    System.setProperty("OTEL_METRICS_EXPORTER", "none");
+    System.setProperty("OTEL_LOGS_EXPORTER", "none");

Review Comment:
   A utility method that sets it if it's not set would be good.  Also check ENV vars which probably already work. 



##########
solr/modules/opentelemetry/build.gradle:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+apply plugin: 'java-library'
+
+description = 'Open Telemetry (OTEL) tracer'
+
+dependencies {
+  implementation project(':solr:core')
+
+  // TODO: Prune down dependencies to the absolute necessary
+
+  implementation platform('io.opentelemetry:opentelemetry-bom-alpha')
+
+  implementation 'io.opentelemetry:opentelemetry-sdk-trace'
+  implementation 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure'
+  implementation 'io.opentelemetry:opentelemetry-opentracing-shim'
+  implementation 'io.opentelemetry:opentelemetry-semconv'
+  implementation 'io.opentelemetry:opentelemetry-exporter-otlp'
+  implementation 'io.opentelemetry:opentelemetry-exporter-jaeger'
+  implementation 'io.opentelemetry:opentelemetry-exporter-zipkin'
+
+  // gRPC transport via netty - since we already ship netty this is more lightweight than netty-shaded
+  runtimeOnly 'io.grpc:grpc-netty'
+  implementation 'io.grpc:grpc-protobuf'
+  implementation 'io.grpc:grpc-stub'
+  implementation 'io.grpc:grpc-context'
+  // See https://issues.apache.org/jira/browse/LOG4J2-3609 due to needing these annotations
+  compileOnly 'org.apache.tomcat:annotations-api'
+
+  // TODO: Both this and jaegertracer-configurator pull in com.squareup.okhttp3:okhttp HTTP client and kotlin stdlib. They get duplicated in each module, so consider declaring these explicitly on solr-core

Review Comment:
   Pointing out this is okay but I think adding to solr-core just because 2 modules use them is not the right direction.  I'd rather see another approach or just accept it.  The jaeger one is going away.



##########
solr/modules/opentelemetry/build.gradle:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+apply plugin: 'java-library'
+
+description = 'Open Telemetry (OTEL) tracer'
+
+dependencies {
+  implementation project(':solr:core')
+
+  // TODO: Prune down dependencies to the absolute necessary
+
+  implementation platform('io.opentelemetry:opentelemetry-bom-alpha')
+
+  implementation 'io.opentelemetry:opentelemetry-sdk-trace'
+  implementation 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure'
+  implementation 'io.opentelemetry:opentelemetry-opentracing-shim'
+  implementation 'io.opentelemetry:opentelemetry-semconv'
+  implementation 'io.opentelemetry:opentelemetry-exporter-otlp'

Review Comment:
   if the industry is standardizing on otlp, then it's reasonable to not include the other 2 if they add more transitive dependencies.  Users can add them if they wish.



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

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

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


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