Skip to content

Commit 1654a8a

Browse files
authored
Merge pull request #140 from DataDog/tyler/consistency
Adjust tag naming for better consistency
2 parents 4b7df67 + 2775dd9 commit 1654a8a

File tree

10 files changed

+47
-53
lines changed

10 files changed

+47
-53
lines changed

dd-java-agent-ittests/src/test/groovy/com/datadoghq/agent/integration/servlet/JettyServletTest.groovy

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.datadoghq.agent.integration.servlet
22

33
import com.datadoghq.trace.DDBaseSpan
4-
import com.datadoghq.trace.DDTags
54
import com.datadoghq.trace.DDTracer
65
import com.datadoghq.trace.writer.ListWriter
7-
import io.opentracing.tag.Tags
86
import io.opentracing.util.GlobalTracer
97
import okhttp3.Interceptor
108
import okhttp3.OkHttpClient
@@ -101,13 +99,13 @@ class JettyServletTest extends Specification {
10199
span.context().operationName == "servlet.request"
102100
!span.context().getErrorFlag()
103101
span.context().parentId != 0 // parent should be the okhttp call.
104-
span.context().tags[Tags.HTTP_URL.key] == "http://localhost:$PORT/$path"
105-
span.context().tags[Tags.HTTP_METHOD.key] == "GET"
106-
span.context().tags[Tags.SPAN_KIND.key] == Tags.SPAN_KIND_SERVER
107-
span.context().tags[Tags.COMPONENT.key] == "java-web-servlet"
108-
span.context().tags[Tags.HTTP_STATUS.key] == 200
109-
span.context().tags[DDTags.THREAD_NAME] != null
110-
span.context().tags[DDTags.THREAD_ID] != null
102+
span.context().tags["http.url"] == "http://localhost:$PORT/$path"
103+
span.context().tags["http.method"] == "GET"
104+
span.context().tags["span.kind"] == "server"
105+
span.context().tags["component"] == "java-web-servlet"
106+
span.context().tags["http.status_code"] == 200
107+
span.context().tags["thread.name"] != null
108+
span.context().tags["thread.id"] != null
111109
span.context().tags.size() == 7
112110

113111
where:

dd-java-agent-ittests/src/test/groovy/com/datadoghq/agent/integration/servlet/TomcatServletTest.groovy

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.datadoghq.agent.integration.servlet
22

3-
import com.datadoghq.trace.DDTags
43
import com.datadoghq.trace.DDTracer
54
import com.datadoghq.trace.writer.ListWriter
65
import com.google.common.io.Files
7-
import io.opentracing.tag.Tags
86
import io.opentracing.util.GlobalTracer
97
import okhttp3.OkHttpClient
108
import okhttp3.Request
@@ -101,13 +99,13 @@ class TomcatServletTest extends Specification {
10199
span.context().operationName == "servlet.request"
102100
!span.context().getErrorFlag()
103101
span.context().parentId != 0 // parent should be the okhttp call.
104-
span.context().tags[Tags.HTTP_URL.key] == "http://localhost:$PORT/$path"
105-
span.context().tags[Tags.HTTP_METHOD.key] == "GET"
106-
span.context().tags[Tags.SPAN_KIND.key] == Tags.SPAN_KIND_SERVER
107-
span.context().tags[Tags.COMPONENT.key] == "java-web-servlet"
108-
span.context().tags[Tags.HTTP_STATUS.key] == 200
109-
span.context().tags[DDTags.THREAD_NAME] != null
110-
span.context().tags[DDTags.THREAD_ID] != null
102+
span.context().tags["http.url"] == "http://localhost:$PORT/$path"
103+
span.context().tags["http.method"] == "GET"
104+
span.context().tags["span.kind"] == "server"
105+
span.context().tags["component"] == "java-web-servlet"
106+
span.context().tags["http.status_code"] == 200
107+
span.context().tags["thread.name"] != null
108+
span.context().tags["thread.id"] != null
111109
span.context().tags.size() == 7
112110

113111
where:

dd-java-agent-ittests/src/test/java/com/datadoghq/agent/TraceAnnotationsManagerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.datadoghq.trace.DDTracer;
77
import com.datadoghq.trace.integration.ErrorFlag;
88
import com.datadoghq.trace.writer.ListWriter;
9-
import io.opentracing.tag.Tags;
109
import io.opentracing.util.GlobalTracer;
1110
import java.lang.reflect.Field;
1211
import org.junit.Before;
@@ -74,7 +73,7 @@ public void testExceptionExit() {
7473
// DO NOTHING
7574
}
7675
assertThat(writer.firstTrace().get(0).getOperationName()).isEqualTo("ERROR");
77-
assertThat(writer.firstTrace().get(0).getTags().get(Tags.ERROR.getKey())).isEqualTo("true");
76+
assertThat(writer.firstTrace().get(0).getTags().get("error")).isEqualTo("true");
7877
assertThat(writer.firstTrace().get(0).getError()).isEqualTo(1);
7978
}
8079
}

dd-java-agent/src/main/java/com/datadoghq/agent/ClassLoaderIntegrationInjector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class ClassLoaderIntegrationInjector {
1515
private final Map<ZipEntry, byte[]> entries;
1616
private final Map<ClassLoader, Method> invocationPoints = Maps.newConcurrentMap();
1717

18-
public ClassLoaderIntegrationInjector(final Map<ZipEntry, byte[]> entries) {
19-
this.entries = Maps.newHashMap(entries);
18+
public ClassLoaderIntegrationInjector(final Map<ZipEntry, byte[]> allEntries) {
19+
this.entries = Maps.newHashMap(allEntries);
2020
for (final Iterator<Map.Entry<ZipEntry, byte[]>> it = entries.entrySet().iterator();
2121
it.hasNext();
2222
) {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.datadoghq.trace;
22

33
public class DDTags {
4-
public static final String SPAN_TYPE = "span-type";
5-
public static final String SERVICE_NAME = "service-name";
6-
public static final String RESOURCE_NAME = "resource-name";
7-
public static final String THREAD_NAME = "thread-name";
8-
public static final String THREAD_ID = "thread-id";
4+
public static final String SPAN_TYPE = "span.type";
5+
public static final String SERVICE_NAME = "service.name";
6+
public static final String RESOURCE_NAME = "resource.name";
7+
public static final String THREAD_NAME = "thread.name";
8+
public static final String THREAD_ID = "thread.id";
99
public static final String DB_STATEMENT = "sql.query";
1010
}

dd-trace/src/test/groovy/com/datadoghq/trace/SpanFactory.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SpanFactory {
1414
"fakeType",
1515
Collections.emptyMap(),
1616
null,
17-
null)
17+
new DDTracer())
1818
return new DDSpan(timestampMicro, context)
1919
}
2020

dd-trace/src/test/groovy/com/datadoghq/trace/writer/DDApiTest.groovy

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,28 @@ class DDApiTest extends Specification {
8484

8585
// Populate thread info dynamically as it is different when run via gradle vs idea.
8686
where:
87-
traces | expectedRequestBody
88-
[] | []
89-
[SpanFactory.newSpanOf(1L)] | [new TreeMap<>([
87+
traces | expectedRequestBody
88+
[] | []
89+
[SpanFactory.newSpanOf(1L).setTag("service.name", "my-service")] | [new TreeMap<>([
9090
"duration" : 0,
9191
"error" : 0,
92-
"meta" : ["thread-name": Thread.currentThread().getName(), "thread-id": "${Thread.currentThread().id}"],
92+
"meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
9393
"name" : "fakeOperation",
9494
"parent_id": 0,
9595
"resource" : "fakeResource",
96-
"service" : "fakeService",
96+
"service" : "my-service",
9797
"span_id" : 1,
9898
"start" : 1000,
9999
"trace_id" : 1,
100100
"type" : "fakeType"
101101
])]
102-
[SpanFactory.newSpanOf(100L)] | [new TreeMap<>([
102+
[SpanFactory.newSpanOf(100L).setTag("resource.name", "my-resource")] | [new TreeMap<>([
103103
"duration" : 0,
104104
"error" : 0,
105-
"meta" : ["thread-name": Thread.currentThread().getName(), "thread-id": "${Thread.currentThread().id}"],
105+
"meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
106106
"name" : "fakeOperation",
107107
"parent_id": 0,
108-
"resource" : "fakeResource",
108+
"resource" : "my-resource",
109109
"service" : "fakeService",
110110
"span_id" : 1,
111111
"start" : 100000,
@@ -183,10 +183,10 @@ class DDApiTest extends Specification {
183183

184184
// Populate thread info dynamically as it is different when run via gradle vs idea.
185185
where:
186-
services | expectedRequestBody
187-
[:] | [:]
188-
["service-name": new Service("service-name", "app-name", Service.AppType.CUSTOM)] | ["service-name": new TreeMap<>([
189-
"app" : "app-name",
186+
services | expectedRequestBody
187+
[:] | [:]
188+
["my-service-name": new Service("my-service-name", "my-app-name", Service.AppType.CUSTOM)] | ["my-service-name": new TreeMap<>([
189+
"app" : "my-app-name",
190190
"app_type": "custom"])
191191
]
192192
}

dd-trace/src/test/java/com/datadoghq/trace/DDSpanSerializationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public void setUp() throws Exception {
5050
null,
5151
null);
5252

53-
baggage.put("thread-name", Thread.currentThread().getName());
54-
baggage.put("thread-id", String.valueOf(Thread.currentThread().getId()));
53+
baggage.put(DDTags.THREAD_NAME, Thread.currentThread().getName());
54+
baggage.put(DDTags.THREAD_ID, String.valueOf(Thread.currentThread().getId()));
5555

5656
span = new DDSpan(100L, context);
5757
span.finish(133L);

dd-trace/src/test/java/com/datadoghq/trace/resolver/TracerResolverTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.opentracing.NoopTracerFactory;
1010
import io.opentracing.Tracer;
1111
import io.opentracing.contrib.tracerresolver.TracerResolver;
12-
import io.opentracing.tag.Tags;
1312
import io.opentracing.util.GlobalTracer;
1413
import java.lang.reflect.Field;
1514
import java.util.List;
@@ -23,7 +22,7 @@ public void testResolve() {
2322
final DDTracer tracer = (DDTracer) tracerResolver.resolve();
2423

2524
// for HTTP decorators
26-
List<AbstractDecorator> decorators = tracer.getSpanContextDecorators(Tags.COMPONENT.getKey());
25+
List<AbstractDecorator> decorators = tracer.getSpanContextDecorators("component");
2726

2827
assertThat(decorators.size()).isEqualTo(2);
2928
AbstractDecorator decorator = decorators.get(0);
@@ -34,7 +33,7 @@ public void testResolve() {
3433
assertThat(httpServiceDecorator.getSetValue()).isEqualTo("world");
3534

3635
// for URL decorators
37-
decorators = tracer.getSpanContextDecorators(Tags.HTTP_URL.getKey());
36+
decorators = tracer.getSpanContextDecorators("http.url");
3837
assertThat(decorators.size()).isEqualTo(1);
3938

4039
decorator = decorators.get(0);

dd-trace/src/test/java/com/datadoghq/trace/sampling/ExampleWithDDAgentWriter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@
77

88
public class ExampleWithDDAgentWriter {
99

10-
public static void main(String[] args) throws Exception {
10+
public static void main(final String[] args) throws Exception {
1111

1212
// Instantiate the DDWriter
1313
// By default, traces are written to localhost:8126 (the ddagent)
14-
Writer writer = new DDAgentWriter();
14+
final Writer writer = new DDAgentWriter();
1515

1616
// Instantiate the proper Sampler
1717
// - RateSampler if you want to keep `ratio` traces
1818
// - AllSampler to keep all traces
19-
Sampler sampler = new AllSampler();
19+
final Sampler sampler = new AllSampler();
2020

2121
// Create the tracer
22-
DDTracer tracer = new DDTracer(writer, sampler);
22+
final DDTracer tracer = new DDTracer(writer, sampler);
2323

24-
Span parent =
24+
final Span parent =
2525
tracer
2626
.buildSpan("hello-world")
27-
.withServiceName("service-name")
27+
.withServiceName("my-service-name")
2828
.withSpanType("web")
2929
.startManual();
3030

3131
Thread.sleep(100);
3232

3333
parent.setBaggageItem("a-baggage", "value");
3434

35-
Span child =
35+
final Span child =
3636
tracer
3737
.buildSpan("hello-world")
3838
.asChildOf(parent)
39-
.withResourceName("resource-name")
39+
.withResourceName("my-resource-name")
4040
.startManual();
4141

4242
Thread.sleep(100);

0 commit comments

Comments
 (0)