@@ -319,6 +319,55 @@ def _process_setting(section, option, getter, mapper):
319319 _raise_configuration_error (section , option )
320320
321321
322+ def _process_distributed_tracing_sampler_setting (section , option , getter , mapper ):
323+ try :
324+ # The type of a value is dictated by the getter
325+ # function supplied.
326+ value = getattr (_config_object , getter )(section , option )
327+ # The getter parsed the value okay but want to
328+ # pass this through a mapping function to change
329+ # it to internal value suitable for internal
330+ # settings object. This is usually one where the
331+ # value was a string.
332+ if mapper :
333+ value = mapper (value )
334+ # Now need to apply the option from the
335+ # configuration file to the internal settings
336+ # object. Walk the object path and assign it.
337+ target = _settings
338+ fields = option .split ("." )
339+ sampler_settings_fields = fields [0 :2 ]
340+
341+ for field in sampler_settings_fields :
342+ target = getattr (target , field )
343+ if len (fields ) == 2 :
344+ setattr (target , "_sampler" , value )
345+ if len (fields ) >= 3 :
346+ sampler_settings_obj = target
347+ sampler_value = fields [2 ]
348+ sampler_subsettings = fields [2 :]
349+ for field in sampler_subsettings [:- 1 ]:
350+ target = getattr (target , field )
351+ setattr (target , sampler_subsettings [- 1 ], value )
352+ breakpoint ()
353+ existing_sampler_value = getattr (sampler_settings_obj , "_sampler" , None )
354+ if existing_sampler_value is None :
355+ setattr (sampler_settings_obj , "_sampler" , sampler_value )
356+ elif existing_sampler_value != sampler_value :
357+ raise RuntimeError
358+ # Cache the configuration so can be dumped out to
359+ # log file when whole main configuration has been
360+ # processed. This ensures that the log file and log
361+ # level entries have been set.
362+ _cache_object .append ((option , value ))
363+ except configparser .NoSectionError :
364+ pass
365+ except configparser .NoOptionError :
366+ pass
367+ except Exception :
368+ _raise_configuration_error (section , option )
369+
370+
322371# Processing of all the settings for specified section except
323372# for log file and log level which are applied separately to
324373# ensure they are set as soon as possible.
@@ -407,11 +456,12 @@ def _process_configuration(section):
407456 _process_setting (section , "distributed_tracing.unique_spans.enabled" , "getboolean" , None )
408457 _process_setting (section , "distributed_tracing.minimize_attributes.enabled" , "getboolean" , None )
409458 _process_setting (section , "distributed_tracing.exclude_newrelic_header" , "getboolean" , None )
410- _process_setting (section , "distributed_tracing.sampler.remote_parent_sampled" , "get" , None )
411- _process_setting (section , "distributed_tracing.sampler.remote_parent_not_sampled" , "get" , None )
412- _process_setting (section , "distributed_tracing.sampler.partial_granularity.enabled" , "getboolean" , None )
459+ _process_distributed_tracing_sampler_setting (section , "distributed_tracing.sampler.remote_parent_sampled" , "get" , None )
460+ _process_distributed_tracing_sampler_setting (section , "distributed_tracing.sampler.remote_parent_not_sampled" , "get" , None )
461+ _process_distributed_tracing_sampler_setting (section , "distributed_tracing.sampler.partial_granularity.enabled" , "getboolean" , None )
413462 _process_setting (section , "distributed_tracing.sampler.partial_granularity.type" , "get" , None )
414463 _process_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_sampled" , "get" , None )
464+ _process_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_sampled.adaptive.sampling_target" , "get" , None )
415465 _process_setting (section , "distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled" , "get" , None )
416466 _process_setting (section , "span_events.enabled" , "getboolean" , None )
417467 _process_setting (section , "span_events.max_samples_stored" , "getint" , None )
0 commit comments