Skip to content

Commit 08e05ea

Browse files
authored
Merge pull request #296 from DataDog/tyler/op-names
Use hardcoded operation names for integrations
2 parents 353bc1b + e6179f6 commit 08e05ea

File tree

34 files changed

+1350
-326
lines changed

34 files changed

+1350
-326
lines changed

dd-java-agent-ittests/src/test/groovy/datadog/trace/agent/integration/httpclient/ApacheHttpClientTest.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ class ApacheHttpClientTest extends Specification {
6666
final DDSpan localSpan = clientTrace.get(1)
6767
localSpan.getType() == null
6868
localSpan.getTags()[Tags.COMPONENT.getKey()] == "apache-httpclient"
69-
localSpan.getOperationName() == "GET"
69+
localSpan.getOperationName() == "http.request"
7070

7171
final DDSpan clientSpan = clientTrace.get(2)
72-
clientSpan.getOperationName() == "GET"
72+
clientSpan.getOperationName() == "http.request"
7373
clientSpan.getType() == DDSpanTypes.HTTP_CLIENT
7474
clientSpan.getTags()[Tags.HTTP_METHOD.getKey()] == "GET"
7575
clientSpan.getTags()[Tags.HTTP_STATUS.getKey()] == 200
@@ -111,10 +111,10 @@ class ApacheHttpClientTest extends Specification {
111111
// our instrumentation makes 2 spans for apache-httpclient
112112
final DDSpan localSpan = clientTrace.get(1)
113113
localSpan.getTags()[Tags.COMPONENT.getKey()] == "apache-httpclient"
114-
localSpan.getOperationName() == "GET"
114+
localSpan.getOperationName() == "http.request"
115115

116116
final DDSpan clientSpan = clientTrace.get(2)
117-
clientSpan.getOperationName() == "GET"
117+
clientSpan.getOperationName() == "http.request"
118118
clientSpan.getTags()[Tags.HTTP_METHOD.getKey()] == "GET"
119119
clientSpan.getTags()[Tags.HTTP_STATUS.getKey()] == 200
120120
clientSpan.getTags()[Tags.HTTP_URL.getKey()] == "http://localhost:" + TestHttpServer.getPort()

dd-java-agent/dd-java-agent.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jacocoTestReport.dependsOn ':dd-java-agent-ittests:test'
1212
whitelistedInstructionClasses += whitelistedBranchClasses += [
1313
'datadog.agent.*',
1414
'datadog.agent.decorators.*',
15-
'io.opentracing.contrib.*',
16-
'dd.opentracing.contrib.*',
1715
]
1816

1917
/*

dd-java-agent/instrumentation/apache-httpclient-4.3/src/main/java/datadog/trace/instrumentation/apachehttpclient/DDTracingClientExec.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
@Slf4j
3535
public class DDTracingClientExec implements ClientExecChain {
3636
private static final String COMPONENT_NAME = "apache-httpclient";
37+
private static final String OPERATION_NAME = "http.request";
3738
/**
3839
* Id of {@link HttpClientContext#setAttribute(String, Object)} representing span associated with
3940
* the current client processing. Referenced span is local span not a span representing HTTP
@@ -108,9 +109,7 @@ public CloseableHttpResponse execute(
108109
private Scope createLocalScope(
109110
final HttpRequest httpRequest, final HttpClientContext clientContext) {
110111
final Tracer.SpanBuilder spanBuilder =
111-
tracer
112-
.buildSpan(httpRequest.getRequestLine().getMethod())
113-
.withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME);
112+
tracer.buildSpan(OPERATION_NAME).withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME);
114113

115114
final Scope scope = spanBuilder.startActive(true);
116115
clientContext.setAttribute(ACTIVE_SPAN, scope);
@@ -133,7 +132,7 @@ private CloseableHttpResponse createNetworkSpan(
133132
try {
134133
networkScope =
135134
tracer
136-
.buildSpan(request.getMethod())
135+
.buildSpan(OPERATION_NAME)
137136
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
138137
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
139138
.asChildOf(parentScope.span())
@@ -157,7 +156,7 @@ private CloseableHttpResponse createNetworkSpan(
157156
Tags.PEER_PORT.set(networkSpan, uri.getPort() == -1 ? 80 : uri.getPort());
158157
Tags.PEER_HOSTNAME.set(networkSpan, uri.getHost());
159158
}
160-
} catch (Exception e) {
159+
} catch (final Exception e) {
161160
log.debug("failed to create network span", e);
162161
}
163162

@@ -169,7 +168,7 @@ private CloseableHttpResponse createNetworkSpan(
169168
if (null != networkSpan) {
170169
Tags.HTTP_STATUS.set(networkSpan, response.getStatusLine().getStatusCode());
171170
}
172-
} catch (Exception e) {
171+
} catch (final Exception e) {
173172
log.debug("failed to set network span status", e);
174173
}
175174

dd-java-agent/instrumentation/aws-sdk/src/main/java/datadog/trace/instrumentation/aws/TracingRequestHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public AmazonWebServiceRequest beforeMarshalling(final AmazonWebServiceRequest r
6262
@Override
6363
public void beforeRequest(final Request<?> request) {
6464
final Tracer.SpanBuilder spanBuilder =
65-
tracer
66-
.buildSpan(request.getServiceName())
67-
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
65+
tracer.buildSpan("aws.command").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
6866

6967
if (parentContext != null) {
7068
spanBuilder.asChildOf(parentContext);

dd-java-agent/instrumentation/aws-sdk/src/test/groovy/AWSClientTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ class AWSClientTest extends AgentTestRunner {
9898
and: // span 0 - from apache-httpclient instrumentation
9999
def span1 = trace[0]
100100

101-
span1.context().operationName == "PUT"
101+
span1.context().operationName == "http.request"
102102
span1.serviceName == "unnamed-java-app"
103-
span1.resourceName == "PUT"
103+
span1.resourceName == "http.request"
104104
span1.type == null
105105
!span1.context().getErrorFlag()
106106
span1.context().parentId == 0
@@ -115,7 +115,7 @@ class AWSClientTest extends AgentTestRunner {
115115
and: // span 1 - from aws instrumentation
116116
def span2 = trace[1]
117117

118-
span2.context().operationName == "PUT"
118+
span2.context().operationName == "http.request"
119119
span2.serviceName == "unnamed-java-app"
120120
span2.resourceName == "PUT /testbucket/"
121121
span2.type == "http"

dd-java-agent/instrumentation/datastax-cassandra-3.2/datastax-cassandra-3.2.gradle

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,9 @@ versionScan {
88
group = "com.datastax.cassandra"
99
module = "cassandra-driver-core"
1010
versions = "[3.2.0,)"
11-
// verifyPresent = [
12-
// // class we're advising
13-
// 'com.datastax.driver.core.Cluster$Manager' : null,
14-
// // used by TracingSession
15-
// 'com.datastax.driver.core.BoundStatement' : null,
16-
// 'com.datastax.driver.core.BoundStatement' : null,
17-
// 'com.datastax.driver.core.CloseFuture' : null,
18-
// 'com.datastax.driver.core.Cluster' : null,
19-
// 'com.datastax.driver.core.Host' : null,
20-
// 'com.datastax.driver.core.PreparedStatement' : null,
21-
// 'com.datastax.driver.core.RegularStatement' : null,
22-
// 'com.datastax.driver.core.ResultSet' : null,
23-
// 'com.datastax.driver.core.ResultSetFuture' : null,
24-
// 'com.datastax.driver.core.Session' : null,
25-
// 'com.datastax.driver.core.Statement' : null,
26-
// 'com.google.common.base.Function' : null,
27-
// 'com.google.common.util.concurrent.Futures' : null,
28-
// 'com.google.common.util.concurrent.ListenableFuture': null
29-
// ]
11+
verifyPresent = [
12+
"com.datastax.driver.core.Duration": null,
13+
]
3014
}
3115

3216
apply from: "${rootDir}/gradle/java.gradle"
@@ -36,9 +20,6 @@ testJava8Only += '**/CassandraClientTest.class'
3620

3721
dependencies {
3822
compileOnly group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.2.0'
39-
compile('io.opentracing.contrib:opentracing-cassandra-driver:0.0.3') {
40-
transitive = false
41-
}
4223

4324
compile project(':dd-java-agent:agent-tooling')
4425

dd-java-agent/instrumentation/datastax-cassandra-3.2/src/main/java/datadog/trace/instrumentation/datastax/cassandra/CassandraClientInstrumentation.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,12 @@ public AgentBuilder apply(final AgentBuilder agentBuilder) {
3030
return agentBuilder
3131
.type(
3232
named("com.datastax.driver.core.Cluster$Manager"),
33-
classLoaderHasClasses(
34-
"com.datastax.driver.core.BoundStatement",
35-
"com.datastax.driver.core.BoundStatement",
36-
"com.datastax.driver.core.CloseFuture",
37-
"com.datastax.driver.core.Cluster",
38-
"com.datastax.driver.core.Host",
39-
"com.datastax.driver.core.PreparedStatement",
40-
"com.datastax.driver.core.RegularStatement",
41-
"com.datastax.driver.core.ResultSet",
42-
"com.datastax.driver.core.ResultSetFuture",
43-
"com.datastax.driver.core.Session",
44-
"com.datastax.driver.core.Statement",
45-
"com.google.common.base.Function",
46-
"com.google.common.util.concurrent.Futures",
47-
"com.google.common.util.concurrent.ListenableFuture"))
33+
classLoaderHasClasses("com.datastax.driver.core.Duration"))
4834
.transform(
4935
new HelperInjector(
50-
"io.opentracing.contrib.cassandra.TracingSession",
51-
"io.opentracing.contrib.cassandra.TracingSession$1",
52-
"io.opentracing.contrib.cassandra.TracingSession$2",
53-
"io.opentracing.contrib.cassandra.TracingCluster",
54-
"io.opentracing.contrib.cassandra.TracingCluster$1"))
36+
"datadog.trace.instrumentation.datastax.cassandra.TracingSession",
37+
"datadog.trace.instrumentation.datastax.cassandra.TracingSession$1",
38+
"datadog.trace.instrumentation.datastax.cassandra.TracingSession$2"))
5539
.transform(DDTransformers.defaultTransformers())
5640
.transform(
5741
DDAdvice.create()
@@ -74,11 +58,13 @@ public static class CassandraClientAdvice {
7458
@Advice.OnMethodExit(suppress = Throwable.class)
7559
public static void injectTracingSession(@Advice.Return(readOnly = false) Session session)
7660
throws Exception {
77-
if (session.getClass().getName().endsWith("contrib.cassandra.TracingSession")) {
61+
// This should cover ours and OT's TracingSession
62+
if (session.getClass().getName().endsWith("cassandra.TracingSession")) {
7863
return;
7964
}
8065

81-
final Class<?> clazz = Class.forName("io.opentracing.contrib.cassandra.TracingSession");
66+
final Class<?> clazz =
67+
Class.forName("datadog.trace.instrumentation.datastax.cassandra.TracingSession");
8268
final Constructor<?> constructor = clazz.getDeclaredConstructor(Session.class, Tracer.class);
8369
constructor.setAccessible(true);
8470
session = (Session) constructor.newInstance(session, GlobalTracer.get());

0 commit comments

Comments
 (0)