Set span.type tag
MODIFY
dd-java-agent-ittests/src/test/groovy/datadog/trace/agent/integration/servlet/JettyServletTest.groovy
dd-java-agent-ittests/src/test/groovy/datadog/trace/agent/integration/servlet/JettyServletTest.groovy
@@ -107,7 +107,7 @@ class JettyServletTest extends Specification {
span.context().tags["http.status_code"] == 200
span.context().tags["thread.name"] != null
span.context().tags["thread.id"] != null
- span.context().tags.size() == 7
+ span.context().tags.size() == 8
where:
path | expectedResponse
@@ -145,7 +145,7 @@ class JettyServletTest extends Specification {
span.context().tags["error.msg"] == "some $path error"
span.context().tags["error.type"] == RuntimeException.getName()
span.context().tags["error.stack"] != null
- span.context().tags.size() == 11
+ span.context().tags.size() == 12
where:
path | expectedResponse

MODIFY
dd-java-agent-ittests/src/test/groovy/datadog/trace/agent/integration/servlet/TomcatServletTest.groovy
dd-java-agent-ittests/src/test/groovy/datadog/trace/agent/integration/servlet/TomcatServletTest.groovy
@@ -106,7 +106,7 @@ class TomcatServletTest extends Specification {
span.context().tags["http.status_code"] == 200
span.context().tags["thread.name"] != null
span.context().tags["thread.id"] != null
- span.context().tags.size() == 7
+ span.context().tags.size() == 8
where:
path | expectedResponse
@@ -144,7 +144,7 @@ class TomcatServletTest extends Specification {
span.context().tags["error.msg"] == "some $path error"
span.context().tags["error.type"] == RuntimeException.getName()
span.context().tags["error.stack"] != null
- span.context().tags.size() == 11
+ span.context().tags.size() == 12
where:
path | expectedResponse

MODIFY
dd-java-agent/instrumentation/jms-1/src/test/groovy/JMS1Test.groovy
dd-java-agent/instrumentation/jms-1/src/test/groovy/JMS1Test.groovy
@@ -64,7 +64,7 @@ class JMS1Test extends AgentTestRunner {
tags0["thread.name"] != null
tags0["thread.id"] != null
- tags0.size() == 5
+ tags0.size() == 6
and: // span 1
def span1 = trace[1]
@@ -85,7 +85,7 @@ class JMS1Test extends AgentTestRunner {
tags1["thread.name"] != null
tags1["thread.id"] != null
- tags1.size() == 5
+ tags1.size() == 6
and: // span 2
def span2 = trace[2]
@@ -106,7 +106,7 @@ class JMS1Test extends AgentTestRunner {
tags2["thread.name"] != null
tags2["thread.id"] != null
- tags2.size() == 5
+ tags2.size() == 6
and: // consumer trace
def consumerTrace = TEST_WRITER.get(1)
@@ -130,7 +130,7 @@ class JMS1Test extends AgentTestRunner {
consumerTags["thread.name"] != null
consumerTags["thread.id"] != null
- consumerTags.size() == 5
+ consumerTags.size() == 6
cleanup:
producer.close()
@@ -188,7 +188,7 @@ class JMS1Test extends AgentTestRunner {
tags0["thread.name"] != null
tags0["thread.id"] != null
- tags0.size() == 5
+ tags0.size() == 6
and: // span 1
def span1 = trace[1]
@@ -209,7 +209,7 @@ class JMS1Test extends AgentTestRunner {
tags1["thread.name"] != null
tags1["thread.id"] != null
- tags1.size() == 5
+ tags1.size() == 6
and: // span 2
def span2 = trace[2]
@@ -230,7 +230,7 @@ class JMS1Test extends AgentTestRunner {
tags2["thread.name"] != null
tags2["thread.id"] != null
- tags2.size() == 5
+ tags2.size() == 6
and: // consumer trace
def consumerTrace = TEST_WRITER.get(1)
@@ -254,7 +254,7 @@ class JMS1Test extends AgentTestRunner {
consumerTags["thread.name"] != null
consumerTags["thread.id"] != null
- consumerTags.size() == 5
+ consumerTags.size() == 6
cleanup:
producer.close()

MODIFY
dd-java-agent/instrumentation/jms-2/src/test/groovy/JMS2Test.groovy
dd-java-agent/instrumentation/jms-2/src/test/groovy/JMS2Test.groovy
@@ -97,7 +97,7 @@ class JMS2Test extends AgentTestRunner {
producerTags["thread.name"] != null
producerTags["thread.id"] != null
- producerTags.size() == 5
+ producerTags.size() == 6
and: // consumer trace
def consumerTrace = TEST_WRITER.get(1)
@@ -121,7 +121,7 @@ class JMS2Test extends AgentTestRunner {
consumerTags["thread.name"] != null
consumerTags["thread.id"] != null
- consumerTags.size() == 5
+ consumerTags.size() == 6
cleanup:
producer.close()
@@ -178,7 +178,7 @@ class JMS2Test extends AgentTestRunner {
producerTags["thread.name"] != null
producerTags["thread.id"] != null
- producerTags.size() == 5
+ producerTags.size() == 6
and: // consumer trace
def consumerTrace = TEST_WRITER.get(1)
@@ -202,7 +202,7 @@ class JMS2Test extends AgentTestRunner {
consumerTags["thread.name"] != null
consumerTags["thread.id"] != null
- consumerTags.size() == 5
+ consumerTags.size() == 6
cleanup:
producer.close()

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
@@ -51,7 +51,7 @@ class OkHttp3Test extends AgentTestRunner {
tags1["component"] == "okhttp"
tags1["thread.name"] != null
tags1["thread.id"] != null
- tags1.size() == 3
+ tags1.size() == 4
and: // span 1
def span2 = trace[1]
@@ -74,7 +74,7 @@ class OkHttp3Test extends AgentTestRunner {
tags2[Tags.PEER_HOST_IPV4.key] != null
tags2[DDTags.THREAD_NAME] != null
tags2[DDTags.THREAD_ID] != null
- tags2.size() == 10
+ tags2.size() == 11
receivedHeaders.get().get("x-datadog-trace-id") == "$span2.traceId"
receivedHeaders.get().get("x-datadog-parent-id") == "$span2.spanId"

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/DDSpanContext.java
dd-trace-ot/src/main/java/datadog/opentracing/DDSpanContext.java
@@ -276,6 +276,7 @@ public class DDSpanContext implements io.opentracing.SpanContext {
}
tags.put(DDTags.THREAD_NAME, threadName);
tags.put(DDTags.THREAD_ID, threadId);
+ tags.put(DDTags.SPAN_TYPE, getSpanType());
return Collections.unmodifiableMap(tags);
}

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanSerializationTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanSerializationTest.groovy
@@ -51,6 +51,7 @@ class DDSpanSerializationTest extends Specification {
baggage.put(DDTags.THREAD_NAME, Thread.currentThread().getName())
baggage.put(DDTags.THREAD_ID, String.valueOf(Thread.currentThread().getId()))
+ baggage.put(DDTags.SPAN_TYPE, context.getSpanType())
DDSpan span = new DDSpan(100L, context)
span.finish(133L)

MODIFY
dd-trace-ot/src/test/groovy/datadog/trace/DDSpanContextTest.groovy
dd-trace-ot/src/test/groovy/datadog/trace/DDSpanContextTest.groovy
@@ -17,14 +17,14 @@ class DDSpanContextTest extends Specification {
context.serviceName == "fakeService"
context.resourceName == "fakeResource"
context.spanType == "fakeType"
- context.toString() == "Span [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource *errored* tags={${extra}thread.id=${Thread.currentThread().id}, thread.name=${Thread.currentThread().name}}"
+ context.toString() == "Span [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource *errored* tags={${extra}span.type=${context.getSpanType()}, thread.id=${Thread.currentThread().id}, thread.name=${Thread.currentThread().name}}"
where:
name | extra | tags
- DDTags.SERVICE_NAME | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
- DDTags.RESOURCE_NAME | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
- DDTags.SPAN_TYPE | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
- "some.tag" | "" | [(DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
+ DDTags.SERVICE_NAME | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.SPAN_TYPE):"fakeType", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
+ DDTags.RESOURCE_NAME | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.SPAN_TYPE):"fakeType", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
+ DDTags.SPAN_TYPE | "some.tag=asdf, " | ["some.tag": "asdf", (DDTags.SPAN_TYPE):"fakeType", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
+ "some.tag" | "" | [ (DDTags.SPAN_TYPE):"fakeType", (DDTags.THREAD_NAME): Thread.currentThread().name, (DDTags.THREAD_ID): Thread.currentThread().id]
}
def "special tags set certain values"() {
@@ -33,10 +33,13 @@ class DDSpanContextTest extends Specification {
context.setTag(name, value)
def thread = Thread.currentThread()
+ def expectedTags = [(DDTags.THREAD_NAME): thread.name, (DDTags.THREAD_ID): thread.id, (DDTags.SPAN_TYPE): context.getSpanType()]
+ def expectedTrace = "Span [ t_id=1, s_id=1, p_id=0] trace=$details tags={span.type=${context.getSpanType()}, thread.id=$thread.id, thread.name=$thread.name}"
+
expect:
- context.getTags() == [(DDTags.THREAD_NAME): thread.name, (DDTags.THREAD_ID): thread.id]
+ context.getTags() == expectedTags
context."$method" == value
- context.toString() == "Span [ t_id=1, s_id=1, p_id=0] trace=$details tags={thread.id=$thread.id, thread.name=$thread.name}"
+ context.toString() == expectedTrace
where:
name | value | method | details
@@ -54,14 +57,15 @@ class DDSpanContextTest extends Specification {
expect:
context.getTags() == [
(name) : value,
+ (DDTags.SPAN_TYPE) : context.getSpanType(),
(DDTags.THREAD_NAME): thread.name,
(DDTags.THREAD_ID) : thread.id
]
- context.toString() == "Span [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource tags={$name=$value, thread.id=$thread.id, thread.name=$thread.name}"
+ context.toString() == "Span [ t_id=1, s_id=1, p_id=0] trace=fakeService/fakeOperation/fakeResource tags={span.type=${context.getSpanType()}, $name=$value, thread.id=$thread.id, thread.name=$thread.name}"
where:
name | value
- "some.name" | "some value"
+ "tag.name" | "some value"
"tag with int" | 1234
"tag-with-bool" | false
"tag_with_float" | 0.321

MODIFY
dd-trace-ot/src/test/groovy/datadog/trace/api/writer/DDApiTest.groovy
dd-trace-ot/src/test/groovy/datadog/trace/api/writer/DDApiTest.groovy
@@ -101,7 +101,7 @@ class DDApiTest extends Specification {
[SpanFactory.newSpanOf(1L).setTag("service.name", "my-service")] | [new TreeMap<>([
"duration" : 0,
"error" : 0,
- "meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
+ "meta" : ["span.type": "fakeType", "thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
"name" : "fakeOperation",
"parent_id": 0,
"resource" : "fakeResource",
@@ -114,7 +114,7 @@ class DDApiTest extends Specification {
[SpanFactory.newSpanOf(100L).setTag("resource.name", "my-resource")] | [new TreeMap<>([
"duration" : 0,
"error" : 0,
- "meta" : ["thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
+ "meta" : ["span.type": "fakeType", "thread.name": Thread.currentThread().getName(), "thread.id": "${Thread.currentThread().id}"],
"name" : "fakeOperation",
"parent_id": 0,
"resource" : "my-resource",

MODIFY
dd-trace-ot/src/test/java/datadog/opentracing/DDSpanBuilderTest.java
dd-trace-ot/src/test/java/datadog/opentracing/DDSpanBuilderTest.java
@@ -63,7 +63,7 @@ public class DDSpanBuilderTest {
span = tracer.buildSpan(expectedName).withServiceName("foo").startManual();
assertThat(span.getTags()).isNotNull();
- assertThat(span.getTags().size()).isEqualTo(2);
+ assertThat(span.getTags().size()).isEqualTo(3);
// with all custom fields provided
final String expectedResource = "fakeResource";

Set span.type tag