@@ -39,6 +39,7 @@ import datadog.trace.bootstrap.instrumentation.api.Tags
3939import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter
4040import datadog.trace.bootstrap.instrumentation.api.URIUtils
4141import datadog.trace.core.DDSpan
42+ import datadog.trace.core.Metadata
4243import datadog.trace.core.datastreams.StatsGroup
4344import datadog.trace.test.util.Flaky
4445import groovy.json.JsonOutput
@@ -780,6 +781,15 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
780781
781782 def " test baggage span tags are properly added" () {
782783 setup :
784+ def recordedBaggageTags = [:]
785+ TEST_WRITER . metadataConsumer = { Metadata md ->
786+ md. baggage. forEach { k , v ->
787+ // record non-internal baggage sent to agent as trace metadata
788+ if (! k. startsWith(" _dd." )) {
789+ recordedBaggageTags. put(k, v)
790+ }
791+ }
792+ }
783793 // Use default configuration for TRACE_BAGGAGE_TAG_KEYS (user.id, session.id, account.id)
784794 def baggageHeader = " user.id=test-user,session.id=test-session,account.id=test-account,language=en"
785795 def request = request(SUCCESS , ' GET' , null )
@@ -799,12 +809,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
799809 trace(spanCount(SUCCESS )) {
800810 sortSpansByStart()
801811 // Verify baggage tags are added for default configured keys only
802- serverSpan(it, null , null , ' GET' , SUCCESS , [
803- " baggage.user.id" : " test-user" ,
804- " baggage.session.id" : " test-session" ,
805- " baggage.account.id" : " test-account"
806- // "baggage.language" should NOT be present since it's not in default config
807- ])
812+ serverSpan(it, null , null , ' GET' , SUCCESS )
808813 if (hasHandlerSpan()) {
809814 handlerSpan(it)
810815 }
@@ -814,6 +819,12 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
814819 }
815820 }
816821 }
822+ recordedBaggageTags == [
823+ " baggage.user.id" : " test-user" ,
824+ " baggage.session.id" : " test-session" ,
825+ " baggage.account.id" : " test-account"
826+ // "baggage.language" should NOT be present since it's not in default config
827+ ]
817828
818829 and :
819830 if (isDataStreamsEnabled()) {
0 commit comments