16
16
17
17
import {
18
18
context ,
19
+ createContextKey ,
20
+ getSpan ,
19
21
INVALID_TRACEID ,
20
22
ROOT_CONTEXT ,
21
23
Sampler ,
@@ -222,7 +224,7 @@ describe('Tracer', () => {
222
224
span . end ( ) ;
223
225
} ) ;
224
226
225
- it ( 'should start an active span with name and function as args' , ( ) => {
227
+ it ( 'should start an active span with name and function args' , ( ) => {
226
228
const tracer = new Tracer (
227
229
{ name : 'default' , version : '0.0.1' } ,
228
230
{ sampler : new TestSampler ( ) } ,
@@ -231,14 +233,15 @@ describe('Tracer', () => {
231
233
232
234
assert . strictEqual ( tracer . startActiveSpan ( 'my-span' , span => {
233
235
try {
236
+ // assert.strictEqual(getSpan(context.active()), span)
234
237
return 1
235
238
} finally {
236
239
span . end ( ) ;
237
240
}
238
241
} ) , 1 ) ;
239
242
} ) ;
240
243
241
- it ( 'should start an active span with name, options and functin as args' , ( ) => {
244
+ it ( 'should start an active span with name, options and function args' , ( ) => {
242
245
const tracer = new Tracer (
243
246
{ name : 'default' , version : '0.0.1' } ,
244
247
{ sampler : new TestSampler ( ) } ,
@@ -247,22 +250,29 @@ describe('Tracer', () => {
247
250
248
251
assert . strictEqual ( tracer . startActiveSpan ( 'my-span' , { } , span => {
249
252
try {
253
+ // assert.strictEqual(getSpan(context.active()), span)
250
254
return 1
251
255
} finally {
252
256
span . end ( ) ;
253
257
}
254
258
} ) , 1 ) ;
255
259
} ) ;
256
260
257
- it ( 'should start an active span with name, options, context and function as args' , ( ) => {
261
+ it ( 'should start an active span with name, options, context and function args' , ( ) => {
258
262
const tracer = new Tracer (
259
263
{ name : 'default' , version : '0.0.1' } ,
260
264
{ sampler : new TestSampler ( ) } ,
261
265
tracerProvider
262
266
) ;
263
267
264
- assert . strictEqual ( tracer . startActiveSpan ( 'my-span' , { } , context . active ( ) , span => {
268
+ const ctxKey = createContextKey ( 'foo' ) ;
269
+
270
+ const ctx = context . active ( ) . setValue ( ctxKey , 'bar' )
271
+
272
+ assert . strictEqual ( tracer . startActiveSpan ( 'my-span' , { } , ctx , span => {
265
273
try {
274
+ // assert.strictEqual(getSpan(context.active()), span)
275
+ assert . strictEqual ( ctx . getValue ( ctxKey ) , 'bar' )
266
276
return 1
267
277
} finally {
268
278
span . end ( ) ;
0 commit comments