Skip to content

Commit

Permalink
Remove operation name decorators (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Dec 9, 2019
1 parent 7f2b478 commit 38a916f
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public AmazonWebServiceRequest beforeMarshalling(final AmazonWebServiceRequest r

@Override
public void beforeRequest(final Request<?> request) {
final AgentSpan span = startSpan("aws.command");
final AgentSpan span = startSpan("aws.http");
DECORATE.afterStart(span);
DECORATE.onRequest(span, request);
request.addHandlerContext(SCOPE_CONTEXT_KEY, activateSpan(span, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class TracingExecutionInterceptor implements ExecutionInterceptor {
@Override
public void beforeExecution(
final Context.BeforeExecution context, final ExecutionAttributes executionAttributes) {
final AgentSpan span = startSpan("aws.command");
final AgentSpan span = startSpan("aws.http");
try (final AgentScope scope = activateSpan(span, false)) {
DECORATE.afterStart(span);
executionAttributes.putAttribute(SPAN_ATTRIBUTE, span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void run() {
}

private AgentScope startSpanWithScope(final String query) {
final AgentSpan span = startSpan("cassandra.execute");
final AgentSpan span = startSpan("cassandra.query");
DECORATE.afterStart(span);
DECORATE.onConnection(span, session);
DECORATE.onStatement(span, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SlickTest extends AgentTestRunner {
}
}
span(1) {
operationName "${SlickUtils.Driver()}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -231,7 +231,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -284,7 +284,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -337,7 +337,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -390,7 +390,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -446,7 +446,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -515,7 +515,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
operationName "${driver}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
childOf span(0)
errored false
Expand Down Expand Up @@ -592,7 +592,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
assertTraces(5) {
trace(0, 1) {
span(0) {
operationName "${dbType}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
errored false
tags {
Expand All @@ -612,7 +612,7 @@ class JDBCInstrumentationTest extends AgentTestRunner {
for (int i = 1; i < numQueries; ++i) {
trace(i, 1) {
span(0) {
operationName "${dbType}.query"
operationName "database.query"
spanType DDSpanTypes.SQL
errored false
tags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static class JedisAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope onEnter(@Advice.Argument(1) final Command command) {
final AgentSpan span = startSpan("redis.command");
final AgentSpan span = startSpan("redis.query");
DECORATE.afterStart(span);
DECORATE.onStatement(span, command.name());
return activateSpan(span, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public boolean shouldSetTag(final DDSpanContext context, final String tag, final
} else {
context.setSpanType(DDSpanTypes.SQL);
}
// Works for: mongo, cassandra, jdbc
context.setOperationName(String.valueOf(value) + ".query");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ public class DDDecoratorsFactory {
public static List<AbstractDecorator> createBuiltinDecorators() {

return Arrays.asList(
new DBTypeDecorator(),
new ErrorFlag(),
new OperationDecorator(),
new SpanTypeDecorator(),
new Status5XXDecorator());
new DBTypeDecorator(), new ErrorFlag(), new SpanTypeDecorator(), new Status5XXDecorator());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ class SpanDecoratorTest extends DDSpecification {
span.getTags().get("newFoo") == "newBar"
}

def "set operation name"() {
when:
Tags.COMPONENT.set(span, component)

then:
span.getOperationName() == operationName

where:
component << OperationDecorator.MAPPINGS.keySet()
operationName << OperationDecorator.MAPPINGS.values()
}

def "set span type"() {
when:
span.setTag(DDTags.SPAN_TYPE, type)
Expand All @@ -58,20 +46,19 @@ class SpanDecoratorTest extends DDSpecification {
type = DDSpanTypes.HTTP_CLIENT
}

def "override operation with DBTypeDecorator"() {

def "set span type with DBTypeDecorator"() {
when:
Tags.DB_TYPE.set(span, type)

then:
span.getOperationName() == type + ".query"
span.context().getSpanType() == "sql"


when:
Tags.DB_TYPE.set(span, "mongo")

then:
span.getOperationName() == "mongo.query"
span.context().getSpanType() == "mongodb"

where:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DDTracerTest extends DDSpecification {
def tracer = new DDTracer()

then:
tracer.spanContextDecorators.size() == 5
tracer.spanContextDecorators.size() == 4

tracer.injector instanceof DatadogHttpCodec.Injector
tracer.extractor instanceof DatadogHttpCodec.Extractor
Expand Down

0 comments on commit 38a916f

Please sign in to comment.