@@ -67,9 +67,10 @@ test.afterEach((ctx) => {
67
67
68
68
test ( 'mix internal and NR span tests' , ( t , end ) => {
69
69
const { agent, api, tracer } = t . nr
70
- function main ( mainSegment ) {
70
+ function main ( mainSegment , tx ) {
71
71
tracer . startActiveSpan ( 'hi' , ( span ) => {
72
72
const segment = agent . tracer . getSegment ( )
73
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
73
74
assert . equal ( segment . name , span . name )
74
75
assert . equal ( segment . parentId , mainSegment . id )
75
76
span . end ( )
@@ -81,6 +82,7 @@ test('mix internal and NR span tests', (t, end) => {
81
82
const parentSegment = agent . tracer . getSegment ( )
82
83
tracer . startActiveSpan ( 'bye' , ( span ) => {
83
84
const segment = agent . tracer . getSegment ( )
85
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
84
86
assert . equal ( segment . name , span . name )
85
87
assert . equal ( segment . parentId , parentSegment . id )
86
88
span . end ( )
@@ -93,7 +95,8 @@ test('mix internal and NR span tests', (t, end) => {
93
95
tx . name = 'otel-example-tx'
94
96
tracer . startActiveSpan ( 'main' , ( span ) => {
95
97
const segment = agent . tracer . getSegment ( )
96
- main ( segment )
98
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
99
+ main ( segment , tx )
97
100
span . end ( )
98
101
assert . equal ( span [ otelSynthesis ] , undefined )
99
102
assert . equal ( segment . name , span . name )
@@ -121,6 +124,7 @@ test('client span(http) is bridge accordingly', (t, end) => {
121
124
tracer . startActiveSpan ( 'http-outbound' , { kind : otel . SpanKind . CLIENT , attributes : { [ ATTR_HTTP_HOST ] : 'newrelic.com' , [ ATTR_HTTP_METHOD ] : 'GET' } } , ( span ) => {
122
125
const segment = agent . tracer . getSegment ( )
123
126
assert . equal ( segment . name , 'External/newrelic.com' )
127
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
124
128
span . end ( )
125
129
const duration = hrTimeToMilliseconds ( span . duration )
126
130
assert . equal ( duration , segment . getDurationInMillis ( ) )
@@ -152,6 +156,7 @@ test('client span(db) is bridge accordingly(statement test)', (t, end) => {
152
156
tracer . startActiveSpan ( 'db-test' , { kind : otel . SpanKind . CLIENT , attributes } , ( span ) => {
153
157
const segment = agent . tracer . getSegment ( )
154
158
assert . equal ( segment . name , 'Datastore/statement/postgresql/test/select' )
159
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
155
160
span . end ( )
156
161
const duration = hrTimeToMilliseconds ( span . duration )
157
162
assert . equal ( duration , segment . getDurationInMillis ( ) )
@@ -196,6 +201,7 @@ test('client span(db) is bridged accordingly(operation test)', (t, end) => {
196
201
tracer . startActiveSpan ( 'db-test' , { kind : otel . SpanKind . CLIENT , attributes } , ( span ) => {
197
202
const segment = agent . tracer . getSegment ( )
198
203
assert . equal ( segment . name , 'Datastore/operation/redis/hset' )
204
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
199
205
span . end ( )
200
206
const duration = hrTimeToMilliseconds ( span . duration )
201
207
assert . equal ( duration , segment . getDurationInMillis ( ) )
@@ -240,6 +246,7 @@ test('server span is bridged accordingly', (t, end) => {
240
246
241
247
tracer . startActiveSpan ( 'http-test' , { kind : otel . SpanKind . SERVER , attributes } , ( span ) => {
242
248
const tx = agent . getTransaction ( )
249
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
243
250
span . setAttribute ( ATTR_HTTP_STATUS_CODE , 200 )
244
251
span . setAttribute ( ATTR_HTTP_STATUS_TEXT , 'OK' )
245
252
span . end ( )
@@ -294,6 +301,7 @@ test('server span(rpc) is bridged accordingly', (t, end) => {
294
301
tracer . startActiveSpan ( 'http-test' , { kind : otel . SpanKind . SERVER , attributes } , ( span ) => {
295
302
span . setAttribute ( ATTR_GRPC_STATUS_CODE , 0 )
296
303
const tx = agent . getTransaction ( )
304
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
297
305
span . end ( )
298
306
assert . ok ( ! tx . isDistributedTrace )
299
307
const segment = agent . tracer . getSegment ( )
@@ -344,6 +352,7 @@ test('server span(fallback) is bridged accordingly', (t, end) => {
344
352
const expectedHost = agent . config . getHostnameSafe ( '127.0.0.1' )
345
353
tracer . startActiveSpan ( 'http-test' , { kind : otel . SpanKind . SERVER , attributes } , ( span ) => {
346
354
const tx = agent . getTransaction ( )
355
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
347
356
span . end ( )
348
357
assert . ok ( ! tx . isDistributedTrace )
349
358
const segment = agent . tracer . getSegment ( )
@@ -394,6 +403,7 @@ test('producer span is bridged accordingly', (t, end) => {
394
403
const expectedHost = agent . config . getHostnameSafe ( 'localhost' )
395
404
tracer . startActiveSpan ( 'prod-test' , { kind : otel . SpanKind . PRODUCER , attributes } , ( span ) => {
396
405
const segment = agent . tracer . getSegment ( )
406
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
397
407
assert . equal ( segment . name , 'MessageBroker/messaging-lib/queue/Produce/Named/test-queue' )
398
408
span . end ( )
399
409
const duration = hrTimeToMilliseconds ( span . duration )
@@ -434,6 +444,7 @@ test('consumer span is bridged correctly', (t, end) => {
434
444
const tx = agent . getTransaction ( )
435
445
assert . ok ( ! tx . isDistributedTrace )
436
446
const segment = agent . tracer . getSegment ( )
447
+ assert . equal ( tx . traceId , span . spanContext ( ) . traceId )
437
448
span . end ( )
438
449
const duration = hrTimeToMilliseconds ( span . duration )
439
450
assert . equal ( duration , segment . getDurationInMillis ( ) )
0 commit comments