diff --git a/README.md b/README.md index 8aa74d58b..64319bcea 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,6 @@ System property values take priority over corresponding environment variables. ### Splunk distribution configuration | System property | Environment variable | Default value | Notes | | -------------------------------------------------- | ------------------------------------------------- | --------------| --------------------------------------------------------------------------------------------------------------------------------------------- | -| splunk.otel.config.span.processor.instrlib.enabled | SPLUNK_OTEL_CONFIG_SPAN_PROCESSOR_INSTRLIB_ENABLED| `false` | Enables span processing adding library instrumentation properties. Deprecated feature for customers not on the newest OpenTelemetry Collector | | splunk.jdbc.low.cardinality.span.name.enabled | SPLUNK_JDBC_LOW_CARDINALITY_SPAN_NAME_ENABLED | `true` | Enables low cardinality span names for spans generated by the JDBC auto-instrumentation. By default JDBC spans use full SQL queries as their names; when this property is on just the SQL statement type should be used (e.g. `SELECT`, `INSERT`). | ## Manually instrument a Java application diff --git a/custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessor.java b/custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessor.java deleted file mode 100644 index 1c6619803..000000000 --- a/custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright Splunk Inc. - * - * Licensed 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 com.splunk.opentelemetry; - -import io.opentelemetry.context.Context; -import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; -import io.opentelemetry.sdk.trace.ReadWriteSpan; -import io.opentelemetry.sdk.trace.ReadableSpan; -import io.opentelemetry.sdk.trace.SpanProcessor; - -/** - * Until all Splunk customers migrate to OTLP, we add our own custom span attributes to signal - * instrumentation library name and version. - * - *
As a side note, official OTLP->Zipkin and OTLP->Jaeger translations already specify similar
- * conversion, see
- * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md#instrumentationlibrary
- * and
- * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/jaeger.md#instrumentationlibrary
- * such translations are not released yet to the Collector. When they reach main branch, this
- * processor can be deprecated.
- */
-public class InstrumentationLibrarySpanProcessor implements SpanProcessor {
- @Override
- public void onStart(Context parentContext, ReadWriteSpan span) {
- InstrumentationLibraryInfo libraryInfo = span.getInstrumentationLibraryInfo();
-
- span.setAttribute("splunk.instrumentation_library.name", libraryInfo.getName());
- if (libraryInfo.getVersion() != null) {
- span.setAttribute("splunk.instrumentation_library.version", libraryInfo.getVersion());
- }
- }
-
- @Override
- public boolean isStartRequired() {
- return true;
- }
-
- @Override
- public void onEnd(ReadableSpan span) {}
-
- @Override
- public boolean isEndRequired() {
- return false;
- }
-
- @Override
- public CompletableResultCode shutdown() {
- return CompletableResultCode.ofSuccess();
- }
-
- @Override
- public CompletableResultCode forceFlush() {
- return CompletableResultCode.ofSuccess();
- }
-}
diff --git a/custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibraryTracerCustomizer.java b/custom/src/main/java/com/splunk/opentelemetry/SplunkTracerCustomizer.java
similarity index 69%
rename from custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibraryTracerCustomizer.java
rename to custom/src/main/java/com/splunk/opentelemetry/SplunkTracerCustomizer.java
index 2c02fa6e3..3a053d856 100644
--- a/custom/src/main/java/com/splunk/opentelemetry/InstrumentationLibraryTracerCustomizer.java
+++ b/custom/src/main/java/com/splunk/opentelemetry/SplunkTracerCustomizer.java
@@ -19,10 +19,7 @@
import io.opentelemetry.javaagent.spi.TracerCustomizer;
import io.opentelemetry.sdk.trace.TracerSdkManagement;
-public class InstrumentationLibraryTracerCustomizer implements TracerCustomizer {
-
- static final String PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED =
- "splunk.otel.config.span.processor.instrlib.enabled";
+public class SplunkTracerCustomizer implements TracerCustomizer {
static final String ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY =
"splunk.jdbc.low.cardinality.span.name.enabled";
@@ -31,14 +28,6 @@ private static String propertyToEnv(String property) {
return property.replace(".", "_").toUpperCase();
}
- private static boolean spanProcessorInstrumentationLibraryEnabled() {
- String value = System.getProperty(PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED);
- if (value == null) {
- value = System.getenv(propertyToEnv(PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED));
- }
- return Boolean.parseBoolean(value);
- }
-
private static boolean jdbcSpanLowCardinalityNameEnabled() {
String value = System.getProperty(ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY);
if (value == null) {
@@ -50,9 +39,6 @@ private static boolean jdbcSpanLowCardinalityNameEnabled() {
@Override
public void configure(TracerSdkManagement tracerManagement) {
- if (spanProcessorInstrumentationLibraryEnabled()) {
- tracerManagement.addSpanProcessor(new InstrumentationLibrarySpanProcessor());
- }
if (jdbcSpanLowCardinalityNameEnabled()) {
tracerManagement.addSpanProcessor(new JdbcSpanRenamingProcessor());
}
diff --git a/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.spi.TracerCustomizer b/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.spi.TracerCustomizer
index 087d71b5d..889c95d20 100644
--- a/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.spi.TracerCustomizer
+++ b/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.spi.TracerCustomizer
@@ -1 +1 @@
-com.splunk.opentelemetry.InstrumentationLibraryTracerCustomizer
\ No newline at end of file
+com.splunk.opentelemetry.SplunkTracerCustomizer
\ No newline at end of file
diff --git a/custom/src/test/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessorTest.java b/custom/src/test/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessorTest.java
deleted file mode 100644
index f3ffa0eed..000000000
--- a/custom/src/test/java/com/splunk/opentelemetry/InstrumentationLibrarySpanProcessorTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright Splunk Inc.
- *
- * Licensed 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 com.splunk.opentelemetry;
-
-import io.opentelemetry.api.common.AttributeKey;
-import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.trace.Span;
-import io.opentelemetry.api.trace.SpanContext;
-import io.opentelemetry.api.trace.StatusCode;
-import io.opentelemetry.context.Context;
-import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
-import io.opentelemetry.sdk.trace.ReadWriteSpan;
-import io.opentelemetry.sdk.trace.data.SpanData;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-class InstrumentationLibrarySpanProcessorTest {
-
- @Test
- void shouldAddInstrumentationLibrary() {
- ReadWriteSpanWithLibrary span = new ReadWriteSpanWithLibrary();
- InstrumentationLibrarySpanProcessor processor = new InstrumentationLibrarySpanProcessor();
- processor.onStart(Context.root(), span);
-
- Assertions.assertEquals(
- "com.splunk.test",
- span.attributes.get(AttributeKey.stringKey("splunk.instrumentation_library.name")));
- Assertions.assertEquals(
- "1.2.3",
- span.attributes.get(AttributeKey.stringKey("splunk.instrumentation_library.version")));
- }
-
- private static class ReadWriteSpanWithLibrary implements ReadWriteSpan {
-
- private Attributes attributes = Attributes.empty();
-
- @Override
- public SpanContext getSpanContext() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public SpanData toSpanData() {
- return null;
- }
-
- @Override
- public InstrumentationLibraryInfo getInstrumentationLibraryInfo() {
- return InstrumentationLibraryInfo.create("com.splunk.test", "1.2.3");
- }
-
- @Override
- public boolean hasEnded() {
- return false;
- }
-
- @Override
- public long getLatencyNanos() {
- return 0;
- }
-
- @Override
- public Span setAttribute(String s, String s1) {
- attributes = attributes.toBuilder().put(s, s1).build();
- return this;
- }
-
- @Override
- public Span setAttribute(String s, long l) {
- return this;
- }
-
- @Override
- public Span setAttribute(String s, double v) {
- return this;
- }
-
- @Override
- public Span setAttribute(String s, boolean b) {
- return this;
- }
-
- @Override
- public