@@ -1006,7 +1006,7 @@ def _update_agent_attributes(self):
10061006 def user_attributes (self ):
10071007 return create_attributes (self ._custom_params , DST_ALL , self .attribute_filter )
10081008
1009- def sampling_algo_compute_sampled_and_priority (self , priority , sampled ):
1009+ def sampling_algo_compute_sampled_and_priority (self , priority , sampled , sampler_kwargs ):
10101010 # self._priority and self._sampled are set when parsing the W3C tracestate
10111011 # or newrelic DT headers and may be overridden in _make_sampling_decision
10121012 # based on the configuration. The only time they are set in here is when the
@@ -1016,25 +1016,21 @@ def sampling_algo_compute_sampled_and_priority(self, priority, sampled):
10161016 priority = float (f"{ random .random ():.6f} " ) # noqa: S311
10171017 if sampled is None :
10181018 _logger .debug ("No trusted account id found. Sampling decision will be made by adaptive sampling algorithm." )
1019- sampled = self ._application .compute_sampled ()
1019+ sampled = self ._application .compute_sampled (** sampler_kwargs )
10201020 if sampled :
10211021 priority += 1
10221022 return priority , sampled
10231023
10241024 def _compute_sampled_and_priority (
1025- self ,
1026- priority ,
1027- sampled ,
1028- remote_parent_sampled_path ,
1029- remote_parent_sampled_setting ,
1030- remote_parent_not_sampled_path ,
1031- remote_parent_not_sampled_setting ,
1025+ self , priority , sampled , full_granularity , remote_parent_sampled_setting , remote_parent_not_sampled_setting
10321026 ):
10331027 if self ._remote_parent_sampled is None :
1028+ section = 0
10341029 config = "default" # Use sampling algo.
10351030 _logger .debug ("Sampling decision made based on no remote parent sampling decision present." )
10361031 elif self ._remote_parent_sampled :
1037- setting_path = remote_parent_sampled_path
1032+ section = 1
1033+ setting_path = f"distributed_tracing.sampler.{ 'full_granularity' if full_granularity else 'partial_granularity' } .remote_parent_sampled"
10381034 config = remote_parent_sampled_setting
10391035 _logger .debug (
10401036 "Sampling decision made based on remote_parent_sampled=%s and %s=%s." ,
@@ -1043,7 +1039,8 @@ def _compute_sampled_and_priority(
10431039 config ,
10441040 )
10451041 else : # self._remote_parent_sampled is False.
1046- setting_path = remote_parent_not_sampled_path
1042+ section = 2
1043+ setting_path = f"distributed_tracing.sampler.{ 'full_granularity' if full_granularity else 'partial_granularity' } .remote_parent_not_sampled"
10471044 config = remote_parent_not_sampled_setting
10481045 _logger .debug (
10491046 "Sampling decision made based on remote_parent_sampled=%s and %s=%s." ,
@@ -1064,7 +1061,9 @@ def _compute_sampled_and_priority(
10641061 _logger .debug (
10651062 "Let adaptive sampler algorithm decide based on sampled=%s and priority=%s." , sampled , priority
10661063 )
1067- priority , sampled = self .sampling_algo_compute_sampled_and_priority (priority , sampled )
1064+ priority , sampled = self .sampling_algo_compute_sampled_and_priority (
1065+ priority , sampled , {"full_granularity" : full_granularity , "section" : section }
1066+ )
10681067 return priority , sampled
10691068
10701069 def _make_sampling_decision (self ):
@@ -1084,9 +1083,8 @@ def _make_sampling_decision(self):
10841083 computed_priority , computed_sampled = self ._compute_sampled_and_priority (
10851084 priority ,
10861085 sampled ,
1087- remote_parent_sampled_path = "distributed_tracing.sampler. full_granularity.remote_parent_sampled" ,
1086+ full_granularity = True ,
10881087 remote_parent_sampled_setting = self .settings .distributed_tracing .sampler .full_granularity .remote_parent_sampled ,
1089- remote_parent_not_sampled_path = "distributed_tracing.sampler.full_granularity.remote_parent_not_sampled" ,
10901088 remote_parent_not_sampled_setting = self .settings .distributed_tracing .sampler .full_granularity .remote_parent_not_sampled ,
10911089 )
10921090 _logger .debug ("Full granularity sampling decision was %s with priority=%s." , sampled , priority )
@@ -1102,9 +1100,8 @@ def _make_sampling_decision(self):
11021100 self ._priority , self ._sampled = self ._compute_sampled_and_priority (
11031101 priority ,
11041102 sampled ,
1105- remote_parent_sampled_path = "distributed_tracing.sampler.partial_granularity.remote_parent_sampled" ,
1103+ full_granularity = False ,
11061104 remote_parent_sampled_setting = self .settings .distributed_tracing .sampler .partial_granularity .remote_parent_sampled ,
1107- remote_parent_not_sampled_path = "distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled" ,
11081105 remote_parent_not_sampled_setting = self .settings .distributed_tracing .sampler .partial_granularity .remote_parent_not_sampled ,
11091106 )
11101107 _logger .debug (
0 commit comments