Skip to content

Commit

Permalink
Remove obsolete splunk.instrumentation_library.XXX attributes (#34)
Browse files Browse the repository at this point in the history
* Remove obsolete splunk.instrumentation_library.XXX attributes

* Format
  • Loading branch information
iNikem authored Nov 10, 2020
1 parent a09092e commit e9c8857
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 281 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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) {
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
com.splunk.opentelemetry.InstrumentationLibraryTracerCustomizer
com.splunk.opentelemetry.SplunkTracerCustomizer

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package com.splunk.opentelemetry;

import static com.splunk.opentelemetry.InstrumentationLibraryTracerCustomizer.ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY;
import static com.splunk.opentelemetry.InstrumentationLibraryTracerCustomizer.PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED;
import static com.splunk.opentelemetry.SplunkTracerCustomizer.ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.never;

import io.opentelemetry.sdk.trace.TracerSdkProvider;
import org.junit.jupiter.api.Test;
Expand All @@ -29,24 +27,20 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class InstrumentationLibraryTracerCustomizerTest {
public class SplunkTracerCustomizerTest {
@Mock private TracerSdkProvider tracerSdkProvider;

@Test
public void shouldAddSpanProcessorsIfPropertiesAreSetToTrue() {

// given
InstrumentationLibraryTracerCustomizer underTest = new InstrumentationLibraryTracerCustomizer();
System.setProperty(PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED, "true");
SplunkTracerCustomizer underTest = new SplunkTracerCustomizer();
System.setProperty(ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY, "true");

// when
underTest.configure(tracerSdkProvider);

// then
then(tracerSdkProvider)
.should()
.addSpanProcessor(isA(InstrumentationLibrarySpanProcessor.class));
then(tracerSdkProvider).should().addSpanProcessor(isA(JdbcSpanRenamingProcessor.class));
then(tracerSdkProvider).shouldHaveNoMoreInteractions();
}
Expand All @@ -55,8 +49,7 @@ public void shouldAddSpanProcessorsIfPropertiesAreSetToTrue() {
public void shouldNotAddSpanProcessorsIfPropertiesAreSetToAnythingElse() {

// given
InstrumentationLibraryTracerCustomizer underTest = new InstrumentationLibraryTracerCustomizer();
System.setProperty(PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED, "enabled");
SplunkTracerCustomizer underTest = new SplunkTracerCustomizer();
System.setProperty(ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY, "whatever");

// when
Expand All @@ -70,17 +63,13 @@ public void shouldNotAddSpanProcessorsIfPropertiesAreSetToAnythingElse() {
public void shouldConfigureTracerSdkForDefaultValues() {

// given
InstrumentationLibraryTracerCustomizer underTest = new InstrumentationLibraryTracerCustomizer();
System.clearProperty(PROPERTY_SPAN_PROCESSOR_INSTR_LIB_ENABLED);
SplunkTracerCustomizer underTest = new SplunkTracerCustomizer();
System.clearProperty(ENABLE_JDBC_SPAN_LOW_CARDINALITY_NAME_PROPERTY);

// when
underTest.configure(tracerSdkProvider);

// then
then(tracerSdkProvider)
.should(never())
.addSpanProcessor(isA(InstrumentationLibrarySpanProcessor.class));
then(tracerSdkProvider).should().addSpanProcessor(isA(JdbcSpanRenamingProcessor.class));
then(tracerSdkProvider).shouldHaveNoMoreInteractions();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import okhttp3.Request;
Expand All @@ -34,11 +33,6 @@ protected String getTargetImage(int jdk) {
return "open-telemetry-docker-dev.bintray.io/java/smoke-springboot-jdk" + jdk + ":latest";
}

@Override
protected Map<String, String> getExtraEnv() {
return Map.of("SPLUNK_OTEL_CONFIG_SPAN_PROCESSOR_INSTRLIB_ENABLED", "true");
}

@ParameterizedTest(name = "{index} => SpringBoot SmokeTest On JDK{0}.")
@ValueSource(ints = {8, 11, 15})
public void springBootSmokeTestOnJDK(int jdk) throws IOException, InterruptedException {
Expand Down Expand Up @@ -68,14 +62,6 @@ public void springBootSmokeTestOnJDK(int jdk) throws IOException, InterruptedExc
.map(a -> a.getValue().getStringValue())
.filter(s -> s.equals(currentAgentVersion))
.count());
Assertions.assertEquals(
3,
getSpanStream(traces)
.flatMap(s -> s.getAttributesList().stream())
.filter(a -> a.getKey().equals("splunk.instrumentation_library.version"))
.map(a -> a.getValue().getStringValue())
.filter(s -> s.equals(currentAgentVersion))
.count());

stopTarget();
}
Expand Down

0 comments on commit e9c8857

Please sign in to comment.