@@ -337,7 +337,11 @@ def _process_dt_setting(section, option_p1, option_p2, getter):
337337 while True :
338338 if len (fields ) == 1 :
339339 value = value1 or value2 or "default"
340- setattr (target , fields [0 ], value )
340+ # Store the value at the underscored location so if option_p1 is
341+ # distributed_tracing.sampler.full_granularity.remote_parent_sampled
342+ # store it at location
343+ # distributed_tracing.sampler.full_granularity._remote_parent_sampled
344+ setattr (target , f"_{ fields [0 ]} " , value )
341345 break
342346 target = getattr (target , fields [0 ])
343347 fields = fields [1 ].split ("." , 1 )
@@ -360,6 +364,90 @@ def _process_dt_setting(section, option_p1, option_p2, getter):
360364 _raise_configuration_error (section , option_p1 )
361365
362366
367+ def _process_dt_hidden_setting (section , option , getter ):
368+ try :
369+ # The type of a value is dictated by the getter
370+ # function supplied.
371+
372+ value = getattr (_config_object , getter )(section , option )
373+
374+ # Now need to apply the option from the
375+ # configuration file to the internal settings
376+ # object. Walk the object path and assign it.
377+
378+ target = _settings
379+ fields = option .split ("." , 1 )
380+
381+ while True :
382+ if len (fields ) == 1 :
383+ value = value or "default"
384+ # Store the value at the underscored location so if option is
385+ # distributed_tracing.sampler.full_granularity.remote_parent_sampled
386+ # store it at location
387+ # distributed_tracing.sampler.full_granularity._remote_parent_sampled
388+ setattr (target , f"_{ fields [0 ]} " , value )
389+ break
390+ target = getattr (target , fields [0 ])
391+ fields = fields [1 ].split ("." , 1 )
392+
393+ # Cache the configuration so can be dumped out to
394+ # log file when whole main configuration has been
395+ # processed. This ensures that the log file and log
396+ # level entries have been set.
397+
398+ _cache_object .append ((option , value ))
399+
400+ except configparser .NoSectionError :
401+ pass
402+
403+ except configparser .NoOptionError :
404+ pass
405+
406+ except Exception :
407+ _raise_configuration_error (section , option_p1 )
408+
409+ def _process_dt_sampler_setting (section , option , getter ):
410+ try :
411+ # The type of a value is dictated by the getter
412+ # function supplied.
413+
414+ value = getattr (_config_object , getter )(section , option )
415+
416+ # Now need to apply the option from the
417+ # configuration file to the internal settings
418+ # object. Walk the object path and assign it.
419+
420+ target = _settings
421+ fields = option .split ("." , 1 )
422+
423+ while True :
424+ if len (fields ) == 1 :
425+ setattr (target , f"{ fields [0 ]} " , value )
426+ break
427+ elif fields [0 ] in ("root" , "remote_parent_sampled" , "remote_parent_not_sampled" ):
428+ sampler = fields [1 ].split ("." , 1 )[0 ]
429+ setattr (target , f"_{ fields [0 ]} " , sampler )
430+ target = getattr (target , fields [0 ])
431+ fields = fields [1 ].split ("." , 1 )
432+
433+
434+ # Cache the configuration so can be dumped out to
435+ # log file when whole main configuration has been
436+ # processed. This ensures that the log file and log
437+ # level entries have been set.
438+
439+ _cache_object .append ((option , value ))
440+
441+ except configparser .NoSectionError :
442+ pass
443+
444+ except configparser .NoOptionError :
445+ pass
446+
447+ except Exception :
448+ _raise_configuration_error (section , option )
449+
450+
363451# Processing of all the settings for specified section except
364452# for log file and log level which are applied separately to
365453# ensure they are set as soon as possible.
@@ -452,17 +540,37 @@ def _process_configuration(section):
452540 "distributed_tracing.sampler.remote_parent_sampled" ,
453541 "get" ,
454542 )
543+ _process_dt_sampler_setting (
544+ section ,
545+ "distributed_tracing.sampler.full_granularity.remote_parent_sampled.adaptive.sampling_target" ,
546+ "getint" ,
547+ )
455548 _process_dt_setting (
456549 section ,
457550 "distributed_tracing.sampler.full_granularity.remote_parent_not_sampled" ,
458551 "distributed_tracing.sampler.remote_parent_not_sampled" ,
459552 "get" ,
460553 )
554+ _process_dt_sampler_setting (
555+ section ,
556+ "distributed_tracing.sampler.full_granularity.remote_parent_not_sampled.adaptive.sampling_target" ,
557+ "getint" ,
558+ )
461559 _process_setting (section , "distributed_tracing.sampler.full_granularity.enabled" , "getboolean" , None )
462560 _process_setting (section , "distributed_tracing.sampler.partial_granularity.enabled" , "getboolean" , None )
463561 _process_setting (section , "distributed_tracing.sampler.partial_granularity.type" , "get" , None )
464- _process_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_sampled" , "get" , None )
465- _process_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled" , "get" , None )
562+ _process_dt_hidden_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_sampled" , "get" )
563+ _process_dt_sampler_setting (
564+ section ,
565+ "distributed_tracing.sampler.partial_granularity.remote_parent_sampled.adaptive.sampling_target" ,
566+ "getint" ,
567+ )
568+ _process_dt_hidden_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled" , "get" )
569+ _process_dt_sampler_setting (
570+ section ,
571+ "distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled.adaptive.sampling_target" ,
572+ "getint" ,
573+ )
466574 _process_setting (section , "span_events.enabled" , "getboolean" , None )
467575 _process_setting (section , "span_events.max_samples_stored" , "getint" , None )
468576 _process_setting (section , "span_events.attributes.enabled" , "getboolean" , None )
0 commit comments