Cleaning-up decorator
The SpringDataDecorator is really for Spring transactions including non-DB related transactions.
The SpringDataDecorator never really implemented DB or ORM support anyway, since most of the methods just returned null.
Changing the decorator to just extend ClientDecorator instead.  Also rename to reflect its true purpose.
DELETE
dd-java-agent/instrumentation/spring-data/src/main/java/datadog/trace/instrumentation/springdata/SpringDataDecorator.java
-package datadog.trace.instrumentation.springdata;
-
-import datadog.trace.agent.decorator.OrmClientDecorator;
-import io.opentracing.Span;
-import java.lang.reflect.Method;
-
-public class SpringDataDecorator extends OrmClientDecorator {
- public static final SpringDataDecorator DECORATOR = new SpringDataDecorator();
-
- @Override
- protected String service() {
- return "spring-data";
- }
-
- @Override
- protected String[] instrumentationNames() {
- return new String[] {"spring-data"};
- }
-
- @Override
- protected String spanType() {
- return null;
- }
-
- @Override
- protected String component() {
- return "spring-data";
- }
-
- @Override
- protected String dbType() {
- return null;
- }
-
- @Override
- protected String dbUser(final Object o) {
- return null;
- }
-
- @Override
- protected String dbInstance(final Object o) {
- return null;
- }
-
- @Override
- public String entityName(final Object entity) {
- String name = null;
-
- if (entity instanceof Method) {
- final Method method = (Method) entity;
- final Class<?> clazz = method.getDeclaringClass();
- final String methodName = method.getName();
- final String className = clazz.getSimpleName();
- name = className + "." + methodName;
- }
-
- return name;
- }
-
- @Override
- public Span onOperation(final Span span, final Object entity) {
-
- assert span != null;
- if (entity != null) {
- final String name = entityName(entity);
- if (name != null) {
- span.setOperationName(name);
- }
- }
- return span;
- }
-}

ADD
dd-java-agent/instrumentation/spring-data/src/main/java/datadog/trace/instrumentation/springdata/SpringTransactionDecorator.java
+package datadog.trace.instrumentation.springdata;
+
+import datadog.trace.agent.decorator.ClientDecorator;
+import datadog.trace.agent.decorator.OrmClientDecorator;
+import io.opentracing.Span;
+import java.lang.reflect.Method;
+
+public final class SpringTransactionDecorator extends ClientDecorator {
+ public static final SpringTransactionDecorator DECORATOR = new SpringTransactionDecorator();
+
+ private SpringTransactionDecorator() {}
+
+ @Override
+ protected String service() {
+ return "spring-data";
+ }
+
+ @Override
+ protected String[] instrumentationNames() {
+ return new String[] {"spring-data"};
+ }
+
+ @Override
+ protected String spanType() {
+ return null;
+ }
+
+ @Override
+ protected String component() {
+ return "spring-data";
+ }
+
+ public Span onOperation(final Span span, final Method transactionalMethod) {
+ assert span != null;
+ assert transactionalMethod != null;
+
+ if (transactionalMethod != null) {
+ final Class<?> clazz = transactionalMethod.getDeclaringClass();
+ final String methodName = transactionalMethod.getName();
+ final String className = clazz.getSimpleName();
+ final String operationName = className + "." + methodName;
+
+ span.setOperationName(operationName);
+ }
+ return span;
+ }
+}

MODIFY
dd-java-agent/instrumentation/spring-data/src/main/java/datadog/trace/instrumentation/springdata/SpringTransactionInstrumentation.java
dd-java-agent/instrumentation/spring-data/src/main/java/datadog/trace/instrumentation/springdata/SpringTransactionInstrumentation.java
package datadog.trace.instrumentation.springdata;
-import static datadog.trace.instrumentation.springdata.SpringDataDecorator.DECORATOR;
+import static datadog.trace.instrumentation.springdata.SpringTransactionDecorator.DECORATOR;
import static net.bytebuddy.matcher.ElementMatchers.*;
import com.google.auto.service.AutoService;
@@ -35,9 +35,7 @@ public final class SpringTransactionInstrumentation extends Instrumenter.Default
return new String[] {
"datadog.trace.agent.decorator.BaseDecorator",
"datadog.trace.agent.decorator.ClientDecorator",
- "datadog.trace.agent.decorator.DatabaseClientDecorator",
- "datadog.trace.agent.decorator.OrmClientDecorator",
- packageName + ".SpringDataDecorator"
+ packageName + ".SpringTransactionDecorator"
};
}
@@ -59,7 +57,7 @@ public final class SpringTransactionInstrumentation extends Instrumenter.Default
final Method invokedMethod = methodInvocation.getMethod();
final Class<?> clazz = invokedMethod.getDeclaringClass();
- final Scope scope = GlobalTracer.get().buildSpan("repository.query").startActive(true);
+ final Scope scope = GlobalTracer.get().buildSpan("transactional.operation").startActive(true);
final Span span = scope.span();
DECORATOR.afterStart(span);
DECORATOR.onOperation(span, invokedMethod);

Cleaning-up decorator

The SpringDataDecorator is really for Spring transactions including non-DB related transactions.

The SpringDataDecorator never really implemented DB or ORM support anyway, since most of the methods just returned null.

Changing the decorator to just extend ClientDecorator instead.  Also rename to reflect its true purpose.