@@ -3489,59 +3489,104 @@ rules:
34893489 describe ( 'remote config field mapping' , ( ) => {
34903490 it ( 'should map dynamic_instrumentation_enabled to dynamicInstrumentation.enabled' , ( ) => {
34913491 const config = getConfig ( )
3492+ assert . strictEqual ( config . dynamicInstrumentation . enabled , false )
34923493 config . setRemoteConfig ( { dynamic_instrumentation_enabled : true } )
34933494 assert . strictEqual ( config . dynamicInstrumentation . enabled , true )
34943495 } )
34953496
34963497 it ( 'should map code_origin_enabled to codeOriginForSpans.enabled' , ( ) => {
34973498 const config = getConfig ( )
3498- config . setRemoteConfig ( { code_origin_enabled : true } )
34993499 assert . strictEqual ( config . codeOriginForSpans . enabled , true )
3500+ config . setRemoteConfig ( { code_origin_enabled : false } )
3501+ assert . strictEqual ( config . codeOriginForSpans . enabled , false )
35003502 } )
35013503
3502- it ( 'should handle false values correctly ' , ( ) => {
3504+ it ( 'should map tracing_sampling_rate to sampleRate ' , ( ) => {
35033505 const config = getConfig ( )
3504- config . setRemoteConfig ( { dynamic_instrumentation_enabled : false } )
3505- assert . strictEqual ( config . dynamicInstrumentation . enabled , false )
3506+ assert . strictEqual ( config . sampleRate , undefined )
3507+ config . setRemoteConfig ( { tracing_sampling_rate : 0.5 } )
3508+ assert . strictEqual ( config . sampleRate , 0.5 )
3509+ } )
3510+
3511+ it ( 'should map log_injection_enabled to logInjection' , ( ) => {
3512+ const config = getConfig ( )
3513+ assert . strictEqual ( config . logInjection , true )
3514+ config . setRemoteConfig ( { log_injection_enabled : false } )
3515+ assert . strictEqual ( config . logInjection , false )
3516+ } )
3517+
3518+ it ( 'should map tracing_enabled to tracing' , ( ) => {
3519+ const config = getConfig ( )
3520+ assert . strictEqual ( config . tracing , true )
3521+ config . setRemoteConfig ( { tracing_enabled : false } )
3522+ assert . strictEqual ( config . tracing , false )
3523+ } )
3524+
3525+ it ( 'should map tracing_sampling_rules to sampler.rules' , ( ) => {
3526+ const config = getConfig ( )
3527+ assert . deepStrictEqual ( config . sampler . rules , [ ] )
3528+ config . setRemoteConfig ( { tracing_sampling_rules : [ { sample_rate : 0.5 } ] } )
3529+ assert . deepStrictEqual ( config . sampler . rules , [ { sampleRate : 0.5 } ] )
3530+ } )
3531+
3532+ it ( 'should map tracing_header_tags to headerTags' , ( ) => {
3533+ const config = getConfig ( { headerTags : [ 'foo:bar' ] } )
3534+ assert . deepStrictEqual ( config . headerTags , [ 'foo:bar' ] )
3535+ config . setRemoteConfig ( { tracing_header_tags : [ { header : 'x-custom-header' , tag_name : 'custom.tag' } ] } )
3536+ assert . deepStrictEqual ( config . headerTags , [
3537+ // TODO: There's an unrelated bug in the tracer resulting in headerTags not being merged.
3538+ // 'foo:bar',
3539+ 'x-custom-header:custom.tag'
3540+ ] )
3541+ } )
3542+
3543+ it ( 'should map tracing_tags to tags' , ( ) => {
3544+ const config = getConfig ( { tags : { foo : 'bar' } } )
3545+ assertObjectContains ( config . tags , { foo : 'bar' } )
3546+ assert . strictEqual ( config . tags . team , undefined )
3547+ config . setRemoteConfig ( { tracing_tags : [ 'team:backend' ] } )
3548+ assertObjectContains ( config . tags , {
3549+ // TODO: There's an unrelated bug in the tracer resulting in tags not being merged.
3550+ // foo: 'bar',
3551+ team : 'backend'
3552+ } )
35063553 } )
35073554 } )
35083555
35093556 describe ( 'remote config application' , ( ) => {
35103557 it ( 'should clear RC fields when setRemoteConfig is called with null' , ( ) => {
35113558 const config = getConfig ( { logInjection : true , sampleRate : 0.5 } )
35123559
3513- // Apply remote config with tracing_enabled set to false (different from default)
35143560 config . setRemoteConfig ( { tracing_enabled : false } )
35153561
3516- // RC sets tracing to false, but logInjection and sampleRate come from env/options
35173562 assert . strictEqual ( config . tracing , false )
35183563 assert . strictEqual ( config . logInjection , true )
35193564 assert . strictEqual ( config . sampleRate , 0.5 )
35203565
3521- // Now clear remote config (all configs removed)
35223566 config . setRemoteConfig ( null )
35233567
3524- // All RC values should be cleared, falling back to env/options/defaults
3525- assert . strictEqual ( config . tracing , true ) // Falls back to default (true)
3568+ assert . strictEqual ( config . tracing , true )
35263569 assert . strictEqual ( config . logInjection , true )
35273570 assert . strictEqual ( config . sampleRate , 0.5 )
35283571 } )
35293572
3530- it ( 'should treat null values as unset ' , ( ) => {
3573+ it ( 'should ignore null values' , ( ) => {
35313574 const config = getConfig ( { sampleRate : 0.5 } )
3532-
3533- // Apply remote config with null value (field is present but null)
3534- // Null should be treated as "unset" and not override the env/options value
35353575 config . setRemoteConfig ( { tracing_sampling_rate : null } )
3576+ assert . strictEqual ( config . sampleRate , 0.5 )
3577+ } )
35363578
3537- // Null values should result in undefined, falling back to env value
3579+ it ( 'should treat null values as unset' , ( ) => {
3580+ const config = getConfig ( { sampleRate : 0.5 } )
3581+ config . setRemoteConfig ( { tracing_sampling_rate : 0.8 } )
3582+ assert . strictEqual ( config . sampleRate , 0.8 )
3583+ config . setRemoteConfig ( { tracing_sampling_rate : null } )
35383584 assert . strictEqual ( config . sampleRate , 0.5 )
35393585 } )
35403586
35413587 it ( 'should replace all RC fields with each update' , ( ) => {
35423588 const config = getConfig ( )
35433589
3544- // First apply a remote config with multiple fields
35453590 config . setRemoteConfig ( {
35463591 tracing_enabled : true ,
35473592 log_injection_enabled : false ,
@@ -3552,111 +3597,13 @@ rules:
35523597 assert . strictEqual ( config . logInjection , false )
35533598 assert . strictEqual ( config . sampleRate , 0.8 )
35543599
3555- // Then apply a new merged config with only tracing_enabled
3556- // This represents the complete merged config after multiconfig processing
35573600 config . setRemoteConfig ( {
35583601 tracing_enabled : false
35593602 } )
35603603
3561- // Only tracing_enabled is set by RC now, others fall back to defaults
35623604 assert . strictEqual ( config . tracing , false )
3563- assert . strictEqual ( config . logInjection , true ) // Falls back to default (true)
3564- assert . strictEqual ( config . sampleRate , undefined ) // Falls back to default (undefined)
3565- } )
3566-
3567- it ( 'should clear tracing_header_tags when not in merged config' , ( ) => {
3568- const config = getConfig ( {
3569- headerTags : [ 'x-custom-header:custom.tag' ]
3570- } )
3571-
3572- // Apply remote config with tracing_header_tags
3573- config . setRemoteConfig ( {
3574- tracing_header_tags : [
3575- { header : 'x-rc-header' , tag_name : 'rc.tag' }
3576- ]
3577- } )
3578-
3579- // RC value should override
3580- assert . deepStrictEqual ( config . headerTags , [ 'x-rc-header:rc.tag' ] )
3581-
3582- // Apply remote config without tracing_header_tags
3583- config . setRemoteConfig ( { tracing_enabled : true } )
3584-
3585- // RC no longer sets headerTags, falls back to env/options
3586- assert . deepStrictEqual ( config . headerTags , [ 'x-custom-header:custom.tag' ] )
3587- } )
3588-
3589- it ( 'should process tracing_header_tags when present' , ( ) => {
3590- const config = getConfig ( {
3591- headerTags : [ 'x-custom-header:custom.tag' ]
3592- } )
3593-
3594- // Apply remote config with tracing_header_tags
3595- config . setRemoteConfig ( {
3596- tracing_header_tags : [
3597- { header : 'x-new-header' , tag_name : 'new.tag' }
3598- ]
3599- } )
3600-
3601- // headerTags should be updated
3602- assert . deepStrictEqual ( config . headerTags , [ 'x-new-header:new.tag' ] )
3603- } )
3604-
3605- it ( 'should clear tracing_tags when not in merged config' , ( ) => {
3606- const config = getConfig ( {
3607- tags : { env : 'production' , version : '1.0.0' }
3608- } )
3609-
3610- // Apply remote config with tracing_tags
3611- config . setRemoteConfig ( {
3612- tracing_tags : [ 'team:backend' ]
3613- } )
3614-
3615- // RC tags should override
3616- assert . strictEqual ( config . tags . team , 'backend' )
3617- assert . strictEqual ( config . tags . env , undefined ) // RC doesn't include env
3618-
3619- // Apply remote config without tracing_tags
3620- config . setRemoteConfig ( { tracing_enabled : true } )
3621-
3622- // RC no longer sets tags, falls back to env/options
3623- assert . strictEqual ( config . tags . env , 'production' )
3624- assert . strictEqual ( config . tags . version , '1.0.0' )
3625- assert . strictEqual ( config . tags . team , undefined )
3626- } )
3627-
3628- it ( 'should process tracing_tags when present' , ( ) => {
3629- const config = getConfig ( {
3630- tags : { env : 'production' }
3631- } )
3632-
3633- // Apply remote config with tracing_tags
3634- config . setRemoteConfig ( {
3635- tracing_tags : [ 'team:backend' , 'region:us-east' ]
3636- } )
3637-
3638- // Tags should be updated
3639- assert . strictEqual ( config . tags . team , 'backend' )
3640- assert . strictEqual ( config . tags . region , 'us-east' )
3641- } )
3642-
3643- it ( 'should clear tracing_sampling_rules when not in merged config' , ( ) => {
3644- const config = getConfig ( )
3645- const originalRules = config . sampler . rules
3646-
3647- // Apply remote config with sampling rules
3648- config . setRemoteConfig ( {
3649- tracing_sampling_rules : [ { sample_rate : 0.5 } ]
3650- } )
3651-
3652- // Rules should be set from RC
3653- assert . deepStrictEqual ( config . sampler . rules , [ { sampleRate : 0.5 } ] )
3654-
3655- // Apply remote config without tracing_sampling_rules
3656- config . setRemoteConfig ( { tracing_enabled : true } )
3657-
3658- // Rules should fall back to original
3659- assert . deepStrictEqual ( config . sampler . rules , originalRules )
3605+ assert . strictEqual ( config . logInjection , true )
3606+ assert . strictEqual ( config . sampleRate , undefined )
36603607 } )
36613608 } )
36623609} )
0 commit comments