@@ -39,6 +39,7 @@ import datadog.trace.bootstrap.instrumentation.api.Tags
39
39
import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter
40
40
import datadog.trace.bootstrap.instrumentation.api.URIUtils
41
41
import datadog.trace.core.DDSpan
42
+ import datadog.trace.core.Metadata
42
43
import datadog.trace.core.datastreams.StatsGroup
43
44
import datadog.trace.test.util.Flaky
44
45
import groovy.json.JsonOutput
@@ -780,6 +781,15 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
780
781
781
782
def " test baggage span tags are properly added" () {
782
783
setup :
784
+ def recordedBaggage = [:]
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
+ recordedBaggage. put(k, v)
790
+ }
791
+ }
792
+ }
783
793
// Use default configuration for TRACE_BAGGAGE_TAG_KEYS (user.id, session.id, account.id)
784
794
def baggageHeader = " user.id=test-user,session.id=test-session,account.id=test-account,language=en"
785
795
def request = request(SUCCESS , ' GET' , null )
@@ -799,12 +809,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
799
809
trace(spanCount(SUCCESS )) {
800
810
sortSpansByStart()
801
811
// 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 )
808
813
if (hasHandlerSpan()) {
809
814
handlerSpan(it)
810
815
}
@@ -814,6 +819,12 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
814
819
}
815
820
}
816
821
}
822
+ recordedBaggage == [
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
+ ]
817
828
818
829
and :
819
830
if (isDataStreamsEnabled()) {
0 commit comments