Move and JDBC instrumentation to individual modules
ADD
dd-java-agent/integrations/jdbc/jdbc.gradle
+apply from: "${rootDir}/gradle/java.gradle"
+
+dependencies {
+ compile project(':dd-trace')
+ compile project(':dd-java-agent:tooling')
+
+ compile deps.bytebuddy
+ compile deps.opentracing
+ compile deps.autoservice
+}

RENAME
dd-java-agent/src/main/java/com/datadoghq/agent/instrumentation/jdbc/ConnectionInstrumentation.java
dd-java-agent/integrations/jdbc/src/main/java/dd/trace/instrumentation/jdbc/ConnectionInstrumentation.java
-package com.datadoghq.agent.instrumentation.jdbc;
+package dd.trace.instrumentation.jdbc;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
@@ -64,7 +64,7 @@ public final class ConnectionInstrumentation implements Instrumenter {
}
connectionInfo.put(connection, new DBInfo(sanitizedURL, type, user));
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
// object may not be fully initialized.
// calling constructor will populate map
}

RENAME
dd-java-agent/src/main/java/com/datadoghq/agent/instrumentation/jdbc/PreparedStatementInstrumentation.java
dd-java-agent/integrations/jdbc/src/main/java/dd/trace/instrumentation/jdbc/PreparedStatementInstrumentation.java
-package com.datadoghq.agent.instrumentation.jdbc;
+package dd.trace.instrumentation.jdbc;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;

RENAME
dd-java-agent/src/main/java/com/datadoghq/agent/instrumentation/jdbc/StatementInstrumentation.java
dd-java-agent/integrations/jdbc/src/main/java/dd/trace/instrumentation/jdbc/StatementInstrumentation.java
-package com.datadoghq.agent.instrumentation.jdbc;
+package dd.trace.instrumentation.jdbc;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;

RENAME
dd-java-agent/src/main/java/com/datadoghq/agent/instrumentation/annotation/TraceAnnotationInstrumentation.java
dd-java-agent/integrations/trace-annotation/src/main/java/dd/trace/instrumentation/trace_annotation/TraceAnnotationInstrumentation.java
-package com.datadoghq.agent.instrumentation.annotation;
+package dd.trace.instrumentation.trace_annotation;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
@@ -37,7 +37,7 @@ public final class TraceAnnotationInstrumentation implements Instrumenter {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static ActiveSpan startSpan(@Advice.Origin final Method method) {
final Trace trace = method.getAnnotation(Trace.class);
- String operationName = trace.operationName();
+ String operationName = trace == null ? null : trace.operationName();
if (operationName == null || operationName.isEmpty()) {
operationName = method.getDeclaringClass().getName() + "." + method.getName();
}

ADD
dd-java-agent/integrations/trace-annotation/trace-annotation.gradle
+apply from: "${rootDir}/gradle/java.gradle"
+
+dependencies {
+ compile project(':dd-trace')
+ compile project(':dd-trace-annotations')
+ compile project(':dd-java-agent:tooling')
+
+ compile deps.bytebuddy
+ compile deps.opentracing
+ compile deps.autoservice
+}

MODIFY
settings.gradle
settings.gradle
@@ -18,6 +18,7 @@ include ':dd-trace-annotations'
include ':dd-java-agent:integrations:apache-httpclient-4.3'
include ':dd-java-agent:integrations:aws-sdk'
include ':dd-java-agent:integrations:datastax-cassandra-3.2'
+include ':dd-java-agent:integrations:jdbc'
include ':dd-java-agent:integrations:jms-1'
include ':dd-java-agent:integrations:jms-2'
include ':dd-java-agent:integrations:mongo-3.1'
@@ -26,6 +27,7 @@ include ':dd-java-agent:integrations:okhttp-3'
include ':dd-java-agent:integrations:servlet-2'
include ':dd-java-agent:integrations:servlet-3'
include ':dd-java-agent:integrations:spring-web'
+include ':dd-java-agent:integrations:trace-annotation'
def setBuildFile(project) {
project.buildFileName = "${project.name}.gradle"

Move @Trace and JDBC instrumentation to individual modules