Skip to content

Commit 91b6de7

Browse files
dougqhclaude
andcommitted
Add setTag/getTag round-trip tests for span.kind
Tests the public API path through TagInterceptor: - setTag + getTag round-trip for all known span kinds - getTag returns null when span.kind is not set - removeTag clears span.kind - custom (non-standard) span.kind falls back to tag map Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8c2ed03 commit 91b6de7

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,67 @@ class DDSpanContextTest extends DDCoreSpecification {
393393
Tags.SPAN_KIND_INTERNAL | DDSpanContext.SPAN_KIND_INTERNAL
394394
Tags.SPAN_KIND_BROKER | DDSpanContext.SPAN_KIND_BROKER
395395
}
396+
397+
def "setTag and getTag round-trip for span.kind"() {
398+
when:
399+
def span = tracer.buildSpan("test", "test").start()
400+
span.setTag(Tags.SPAN_KIND, kindString)
401+
402+
then:
403+
span.getTag(Tags.SPAN_KIND) == kindString
404+
405+
cleanup:
406+
span.finish()
407+
408+
where:
409+
kindString << [
410+
Tags.SPAN_KIND_SERVER,
411+
Tags.SPAN_KIND_CLIENT,
412+
Tags.SPAN_KIND_PRODUCER,
413+
Tags.SPAN_KIND_CONSUMER,
414+
Tags.SPAN_KIND_INTERNAL,
415+
Tags.SPAN_KIND_BROKER,
416+
]
417+
}
418+
419+
def "getTag returns null when span.kind is not set"() {
420+
when:
421+
def span = tracer.buildSpan("test", "test").start()
422+
423+
then:
424+
span.getTag(Tags.SPAN_KIND) == null
425+
426+
cleanup:
427+
span.finish()
428+
}
429+
430+
def "setTag then removeTag clears span.kind"() {
431+
when:
432+
def span = tracer.buildSpan("test", "test").start()
433+
span.setTag(Tags.SPAN_KIND, Tags.SPAN_KIND_SERVER)
434+
435+
then:
436+
span.getTag(Tags.SPAN_KIND) == Tags.SPAN_KIND_SERVER
437+
438+
when:
439+
((DDSpan) span).context().removeTag(Tags.SPAN_KIND)
440+
441+
then:
442+
span.getTag(Tags.SPAN_KIND) == null
443+
444+
cleanup:
445+
span.finish()
446+
}
447+
448+
def "setTag with custom span.kind falls back to tag map"() {
449+
when:
450+
def span = tracer.buildSpan("test", "test").start()
451+
span.setTag(Tags.SPAN_KIND, "custom-kind")
452+
453+
then:
454+
span.getTag(Tags.SPAN_KIND) == "custom-kind"
455+
456+
cleanup:
457+
span.finish()
458+
}
396459
}

0 commit comments

Comments
 (0)