This repository was archived by the owner on Oct 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -262,11 +262,15 @@ export class CoreTracerBase implements types.TracerBase {
262262 }
263263 let propagatedSample = null ;
264264 // if there is a context propagation, keep the decision
265- if ( options && options . spanContext && options . spanContext . options ) {
265+ if (
266+ options &&
267+ options . spanContext &&
268+ options . spanContext . options !== undefined
269+ ) {
266270 propagatedSample = ( options . spanContext . options & this . IS_SAMPLED ) !== 0 ;
271+ return ! ! propagatedSample ;
267272 }
268-
269- // Propagated sample or use the default global sampler
270- return ! ! propagatedSample || this . sampler . shouldSample ( traceId ) ;
273+ // default global sampler
274+ return this . sampler . shouldSample ( traceId ) ;
271275 }
272276}
Original file line number Diff line number Diff line change @@ -225,12 +225,13 @@ describe('Tracer Base', () => {
225225 } ) ;
226226 } ) ;
227227
228- it ( 'should create the new RootSpan with no propagation ( options bit is not set )' , ( ) => {
228+ it ( 'should create the new NoRecordRootSpan with propagation options bit set to not-sample )' , ( ) => {
229229 const tracer = new CoreTracerBase ( ) ;
230230 tracer . start ( defaultConfig ) ;
231231 traceOptions . spanContext ! . options = 0x0 ;
232232 tracer . startRootSpan ( traceOptions , rootSpan => {
233233 assert . ok ( rootSpan ) ;
234+ assert . ok ( rootSpan instanceof NoRecordRootSpan ) ;
234235 assert . strictEqual ( rootSpan . name , traceOptions . name ) ;
235236 assert . strictEqual ( rootSpan . kind , traceOptions . kind ) ;
236237 assert . strictEqual ( rootSpan . traceId , spanContextPropagated . traceId ) ;
You can’t perform that action at this time.
0 commit comments