[core] compatibility for sql.query tags
MODIFY
dd-trace/src/main/java/com/datadoghq/trace/DDTags.java
dd-trace/src/main/java/com/datadoghq/trace/DDTags.java
@@ -6,4 +6,5 @@ public class DDTags {
public static final String RESOURCE_NAME = "resource-name";
public static final String THREAD_NAME = "thread-name";
public static final String THREAD_ID = "thread-id";
+ public static final String DB_STATEMENT = "sql.query";
}

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/integration/DBStatementAsResourceName.java
dd-trace/src/main/java/com/datadoghq/trace/integration/DBStatementAsResourceName.java
package com.datadoghq.trace.integration;
+import com.datadoghq.trace.DDSpanContext;
import com.datadoghq.trace.DDTags;
import io.opentracing.tag.Tags;
@@ -10,4 +11,17 @@ public class DBStatementAsResourceName extends AbstractDecorator {
this.setMatchingTag(Tags.DB_STATEMENT.getKey());
this.setSetTag(DDTags.RESOURCE_NAME);
}
+
+
+ @Override
+ public boolean afterSetTag(final DDSpanContext context, final String tag, final Object value) {
+ //Assign service name
+ if (super.afterSetTag(context, tag, value)) {
+ // Replace the OT db.statement by the DD sql.query
+ context.setTag(DDTags.DB_STATEMENT, value);
+ context.getTags().remove(Tags.DB_STATEMENT.getKey());
+ return true;
+ }
+ return false;
+ }
}

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/integration/DBTypeDecorator.java
dd-trace/src/main/java/com/datadoghq/trace/integration/DBTypeDecorator.java
@@ -21,7 +21,7 @@ public class DBTypeDecorator extends AbstractDecorator {
//Assign service name
if (super.afterSetTag(context, tag, value)) {
//Assign span type to DB
- context.setSpanType("db");
+ context.setSpanType("sql");
// Works for: mongo, cassandra, jdbc
context.setOperationName(String.valueOf(value) + ".query");
return true;

MODIFY
dd-trace/src/main/resources/dd-trace-decorators.yaml
dd-trace/src/main/resources/dd-trace-decorators.yaml
@@ -9,4 +9,5 @@ decorators:
setValue: aws-client
- type: ErrorFlag
- type: DBTypeDecorator
+ - type: DBStatementAsResourceName
- type: OperationDecorator

[core] compatibility for sql.query tags