Add support for SignalFx and AppOptics tracing annotations
MODIFY
instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/traceannotation/TraceAnnotationsInstrumentation.java
instrumentation/trace-annotation/src/main/java/io/opentelemetry/auto/instrumentation/traceannotation/TraceAnnotationsInstrumentation.java
@@ -52,8 +52,11 @@ public final class TraceAnnotationsInstrumentation extends Instrumenter.Default
new String[] {
"com.newrelic.api.agent.Trace",
"kamon.annotation.Trace",
+ "kamon.annotation.api.Trace",
"com.tracelytics.api.ext.LogMethod",
+ "com.appoptics.api.ext.LogMethod",
"io.opentracing.contrib.dropwizard.Trace",
+ "com.signalfx.tracing.api.Trace",
"org.springframework.cloud.sleuth.annotation.NewSpan"
};

MODIFY
instrumentation/trace-annotation/src/test/groovy/ConfiguredTraceAnnotationsTest.groovy
instrumentation/trace-annotation/src/test/groovy/ConfiguredTraceAnnotationsTest.groovy
@@ -34,7 +34,7 @@ class ConfiguredTraceAnnotationsTest extends AgentTestRunner {
System.clearProperty("ota.trace.annotations")
}
- def "test disabled nr annotation"() {
+ def "method with disabled NewRelic annotation should be ignored"() {
setup:
SayTracedHello.fromCallableWhenDisabled()
@@ -42,7 +42,7 @@ class ConfiguredTraceAnnotationsTest extends AgentTestRunner {
TEST_WRITER.traces == []
}
- def "test custom annotation based trace"() {
+ def "method with custom annotation should be traced"() {
expect:
new AnnotationTracedCallable().call() == "Hello!"

ADD
instrumentation/trace-annotation/src/test/groovy/TraceProvidersTest.groovy
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * 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.
+ */
+import io.opentelemetry.auto.test.AgentTestRunner
+import io.opentelemetry.auto.test.utils.ConfigUtils
+import io.opentelemetry.test.annotation.SayTracedHello
+
+/**
+ * This test verifies that Otel supports various 3rd-party trace annotations
+ */
+class TraceProvidersTest extends AgentTestRunner {
+
+ static {
+ ConfigUtils.updateConfig {
+ System.clearProperty("ota.trace.annotations")
+ System.setProperty("ota.trace.classes.exclude", TraceProvidersTest.name + "*")
+ }
+ }
+
+ def specCleanup() {
+ ConfigUtils.updateConfig {
+ System.clearProperty("ota.trace.classes.exclude")
+ }
+ }
+
+ def "should support #provider"(String provider) {
+ setup:
+ new SayTracedHello()."${provider.toLowerCase()}"()
+
+ expect:
+ assertTraces(1) {
+ trace(0, 1) {
+ span(0) {
+ operationName "SayTracedHello.${provider.toLowerCase()}"
+ parent()
+ errored false
+ tags {
+ "providerAttr" provider
+ }
+ }
+ }
+ }
+
+ where:
+ provider << ["Dropwizard", "NewRelic", "SignalFx", "KamonOld", "KamonNew", "AppOptics", "Tracelytics", "Sleuth"]
+ }
+
+}

MODIFY
instrumentation/trace-annotation/src/test/java/io/opentelemetry/test/annotation/SayTracedHello.java
instrumentation/trace-annotation/src/test/java/io/opentelemetry/test/annotation/SayTracedHello.java
@@ -17,7 +17,6 @@ package io.opentelemetry.test.annotation;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.trace.Tracer;
-import io.opentracing.contrib.dropwizard.Trace;
import java.util.concurrent.Callable;
public class SayTracedHello {
@@ -25,19 +24,67 @@ public class SayTracedHello {
private static final Tracer TRACER =
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
- @Trace
+ @io.opentracing.contrib.dropwizard.Trace
+ public String dropwizard() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "Dropwizard");
+ return "hello!";
+ }
+
+ @com.newrelic.api.agent.Trace
+ public String newrelic() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "NewRelic");
+ return "hello!";
+ }
+
+ @kamon.annotation.Trace("spanName")
+ public String kamonold() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "KamonOld");
+ return "hello!";
+ }
+
+ @kamon.annotation.api.Trace
+ public String kamonnew() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "KamonNew");
+ return "hello!";
+ }
+
+ @com.appoptics.api.ext.LogMethod
+ public String appoptics() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "AppOptics");
+ return "hello!";
+ }
+
+ @com.tracelytics.api.ext.LogMethod
+ public String tracelytics() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "Tracelytics");
+ return "hello!";
+ }
+
+ @com.signalfx.tracing.api.Trace
+ public String signalfx() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "SignalFx");
+ return "hello!";
+ }
+
+ @org.springframework.cloud.sleuth.annotation.NewSpan
+ public String sleuth() {
+ TRACER.getCurrentSpan().setAttribute("providerAttr", "Sleuth");
+ return "hello!";
+ }
+
+ @io.opentracing.contrib.dropwizard.Trace
public static String sayHello() {
TRACER.getCurrentSpan().setAttribute("myattr", "test");
return "hello!";
}
- @Trace
+ @io.opentracing.contrib.dropwizard.Trace
public static String sayHELLOsayHA() {
TRACER.getCurrentSpan().setAttribute("myattr", "test2");
return sayHello() + sayHello();
}
- @Trace
+ @io.opentracing.contrib.dropwizard.Trace
public static String sayERROR() {
throw new RuntimeException();
}

MODIFY
instrumentation/trace-annotation/trace-annotation.gradle
instrumentation/trace-annotation/trace-annotation.gradle
@@ -10,5 +10,18 @@ muzzle {
dependencies {
testCompile group: 'com.newrelic.agent.java', name: 'newrelic-api', version: '+'
- testCompile group: 'io.opentracing.contrib.dropwizard', name: 'dropwizard-opentracing', version: '0.2.2'
+ testCompile(group: 'io.opentracing.contrib.dropwizard', name: 'dropwizard-opentracing', version: '0.2.2') {
+ transitive = false
+ }
+ testCompile group: 'com.signalfx.public', name: 'signalfx-trace-api', version: '+'
+ //Old and new versions of kamon use different packages for Trace annotation
+ testCompile(group: 'io.kamon', name: 'kamon-annotation_2.11', version: '0.6.7') {
+ transitive = false
+ }
+ testCompile group: 'io.kamon', name: 'kamon-annotation-api', version: '+'
+ testCompile group: 'com.appoptics.agent.java', name: 'appoptics-sdk', version: '+'
+ testCompile group: 'com.tracelytics.agent.java', name: 'tracelytics-api', version: '+'
+ testCompile(group: 'org.springframework.cloud', name: 'spring-cloud-sleuth-core', version: '+') {
+ transitive = false
+ }
}

Add support for SignalFx and AppOptics tracing annotations (#345)