@@ -27,7 +27,6 @@ describe('SpanProcessor', () => {
2727
2828 describe ( 'baggage to span attribute enrichment' , ( ) => {
2929 it ( 'should copy generic attributes from baggage to span' , ( ) => {
30- // Set baggage
3130 const baggageEntries = {
3231 [ OpenTelemetryConstants . TENANT_ID_KEY ] : 'tenant-123' ,
3332 [ OpenTelemetryConstants . CORRELATION_ID_KEY ] : 'corr-456' ,
@@ -41,7 +40,7 @@ describe('SpanProcessor', () => {
4140
4241 const ctx = propagation . setBaggage ( context . active ( ) , baggage ) ;
4342
44- // Create a span in this context
43+ // Create a span in this context (parentContext not passed so processor may no-op)
4544 const tracer = provider . getTracer ( 'test' ) ;
4645 let testSpan : Span | undefined ;
4746
@@ -52,10 +51,23 @@ describe('SpanProcessor', () => {
5251 }
5352 } ) ;
5453
55- // The span processor should have copied baggage to attributes
5654 expect ( testSpan ) . toBeDefined ( ) ;
5755 } ) ;
5856
57+
58+ it ( 'should copy sessionId from baggage to span' , ( ) => {
59+ let baggage = propagation . createBaggage ( ) ;
60+ baggage = baggage . setEntry ( OpenTelemetryConstants . SESSION_ID_KEY , { value : 'session-abc' } ) ;
61+
62+ const ctx = propagation . setBaggage ( context . active ( ) , baggage ) ;
63+ const tracer = provider . getTracer ( 'test' ) ;
64+ const testSpan = tracer . startSpan ( 'test-span' , { kind : SpanKind . CLIENT } , ctx as any ) ;
65+ testSpan . end ( ) ;
66+
67+ const attrs = ( testSpan as any ) . _attributes ?? ( testSpan as any ) . attributes ?? { } ;
68+ expect ( attrs [ OpenTelemetryConstants . SESSION_ID_KEY ] ) . toBe ( 'session-abc' ) ;
69+ } ) ;
70+
5971 it ( 'should copy invoke agent attributes for invoke_agent operations' , ( ) => {
6072 // Set baggage with invoke agent specific fields
6173 const baggageEntries = {
@@ -139,6 +151,7 @@ describe('SpanProcessor', () => {
139151 expect ( GENERIC_ATTRIBUTES ) . toContain ( OpenTelemetryConstants . TENANT_ID_KEY ) ;
140152 expect ( GENERIC_ATTRIBUTES ) . toContain ( OpenTelemetryConstants . CORRELATION_ID_KEY ) ;
141153 expect ( GENERIC_ATTRIBUTES ) . toContain ( OpenTelemetryConstants . GEN_AI_AGENT_ID_KEY ) ;
154+ expect ( GENERIC_ATTRIBUTES ) . toContain ( OpenTelemetryConstants . SESSION_ID_KEY ) ;
142155 } ) ;
143156
144157 it ( 'should apply invoke agent specific attributes' , ( ) => {
0 commit comments