DDActiveSpan made closeable + Improvements & tests of the TracedClient
MODIFY
dd-java-agent/src/main/java/io/opentracing/contrib/agent/TraceAnnotationsManager.java
dd-java-agent/src/main/java/io/opentracing/contrib/agent/TraceAnnotationsManager.java
@@ -217,7 +217,7 @@ public class TraceAnnotationsManager {
RuleScript ruleScript = new RuleScript(
ruleNamePrefix+loc+" "+javassistMethod.getLongName(),
- "^"+cc.getName(),
+ cc.getName(),
false,
false,
javassistMethod.getName() + Descriptor.toString(javassistMethod.getSignature()),

MODIFY
dd-trace-examples/dropwizard-mongo-client/src/main/java/com/example/helloworld/client/TracedClient.java
dd-trace-examples/dropwizard-mongo-client/src/main/java/com/example/helloworld/client/TracedClient.java
@@ -2,6 +2,7 @@ package com.example.helloworld.client;
import java.io.IOException;
+import io.opentracing.contrib.agent.Trace;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -14,7 +15,14 @@ import okhttp3.Response;
*/
public class TracedClient {
+
public static void main(String[] args) throws Exception{
+ executeCall();
+ System.out.println("After execute");
+ }
+
+ @Trace(tagsKV={"service-name","TracedClient"})
+ private static void executeCall() throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()

MODIFY
dd-trace-examples/dropwizard-mongo-client/src/main/resources/dd-trace.yaml
dd-trace-examples/dropwizard-mongo-client/src/main/resources/dd-trace.yaml
@@ -22,8 +22,8 @@ sampler:
# Skip some traces if the root span tag values matches some regexp patterns
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
-# Enable custom tracing (Custom annotations for now)
-enableCustomTracing: true
+# Enable custom annotation tracing over a selected set of packages
+enableCustomAnnotationTracingOver: ["com.example"]
# Disable some instrumentations
# disabledInstrumentations: ["apache http", "mongo", "jetty", "tomcat", ...]
\ No newline at end of file

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/DDActiveSpan.java
dd-trace/src/main/java/com/datadoghq/trace/DDActiveSpan.java
@@ -72,4 +72,9 @@ public class DDActiveSpan extends DDBaseSpan<ActiveSpan> implements ActiveSpan{
}
}
+
+ @Override
+ public void close() {
+ deactivate();
+ }
}

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/DDBaseSpan.java
dd-trace/src/main/java/com/datadoghq/trace/DDBaseSpan.java
@@ -93,13 +93,6 @@ public abstract class DDBaseSpan<S extends BaseSpan> implements BaseSpan<S> {
}
}
- /* (non-Javadoc)
- * @see io.opentracing.Span#close()
- */
- public final void close() {
- this.finish();
- }
-
/**
* Check if the span is the root parent. It means that the traceId is the same as the spanId
*

DDActiveSpan made closeable + Improvements & tests of the TracedClient