[core] compatibility for sql.query tags

This commit is contained in:
Guillaume Polaert 2017-08-01 11:37:11 +02:00 committed by Emanuele Palazzetti
parent b3c21aa124
commit e93adf9f8f
4 changed files with 17 additions and 1 deletions

View File

@ -6,4 +6,5 @@ public class DDTags {
public static final String RESOURCE_NAME = "resource-name"; public static final String RESOURCE_NAME = "resource-name";
public static final String THREAD_NAME = "thread-name"; public static final String THREAD_NAME = "thread-name";
public static final String THREAD_ID = "thread-id"; public static final String THREAD_ID = "thread-id";
public static final String DB_STATEMENT = "sql.query";
} }

View File

@ -1,5 +1,6 @@
package com.datadoghq.trace.integration; package com.datadoghq.trace.integration;
import com.datadoghq.trace.DDSpanContext;
import com.datadoghq.trace.DDTags; import com.datadoghq.trace.DDTags;
import io.opentracing.tag.Tags; import io.opentracing.tag.Tags;
@ -10,4 +11,17 @@ public class DBStatementAsResourceName extends AbstractDecorator {
this.setMatchingTag(Tags.DB_STATEMENT.getKey()); this.setMatchingTag(Tags.DB_STATEMENT.getKey());
this.setSetTag(DDTags.RESOURCE_NAME); 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;
}
} }

View File

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

View File

@ -9,4 +9,5 @@ decorators:
setValue: aws-client setValue: aws-client
- type: ErrorFlag - type: ErrorFlag
- type: DBTypeDecorator - type: DBTypeDecorator
- type: DBStatementAsResourceName
- type: OperationDecorator - type: OperationDecorator