@@ -2102,6 +2102,34 @@ func TestDDAttributes(t *testing.T) {
21022102 // Verify Scope is set to "experiments"
21032103 assert .Equal (t , "experiments" , llmSpan .DDAttributes .Scope , "DDAttributes.Scope should be 'experiments' for experiment spans" )
21042104 })
2105+ t .Run ("child-span-inherits-experiment-scope-from-baggage" , func (t * testing.T ) {
2106+ tt , ll := testTracer (t )
2107+ ctx := context .Background ()
2108+
2109+ experimentID := "test-experiment-456"
2110+ parentSpan , ctx := ll .StartExperimentSpan (ctx , "parent-experiment" , experimentID , llmobs.StartSpanConfig {})
2111+ childSpan , _ := ll .StartSpan (ctx , llmobs .SpanKindLLM , "child-llm" , llmobs.StartSpanConfig {})
2112+
2113+ childSpan .Finish (llmobs.FinishSpanConfig {})
2114+ parentSpan .Finish (llmobs.FinishSpanConfig {})
2115+
2116+ llmSpans := tt .WaitForLLMObsSpans (t , 2 )
2117+
2118+ var parentLLM , childLLM * llmobstransport.LLMObsSpanEvent
2119+ for i := range llmSpans {
2120+ if llmSpans [i ].Name == "parent-experiment" {
2121+ parentLLM = & llmSpans [i ]
2122+ } else if llmSpans [i ].Name == "child-llm" {
2123+ childLLM = & llmSpans [i ]
2124+ }
2125+ }
2126+
2127+ require .NotNil (t , parentLLM , "Parent LLM span should exist" )
2128+ require .NotNil (t , childLLM , "Child LLM span should exist" )
2129+
2130+ assert .Equal (t , "experiments" , parentLLM .DDAttributes .Scope , "Parent scope should be 'experiments'" )
2131+ assert .Equal (t , "experiments" , childLLM .DDAttributes .Scope , "Child scope should be 'experiments' via baggage propagation" )
2132+ })
21052133 t .Run ("child-span-trace-ids" , func (t * testing.T ) {
21062134 tt , ll := testTracer (t )
21072135 ctx := context .Background ()
0 commit comments