File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ def __init__(self, config):
3232 self .ignore_endpoints = set (
3333 config .value ("ignore_endpoints" ) + config .value ("ignore" )
3434 )
35+ self .legacy_ignore = set (config .value ("ignore" ))
3536 self .ignore_jobs = set (config .value ("ignore_jobs" ))
3637 self .endpoint_sample_rate = config .value ("endpoint_sample_rate" )
3738 self .job_sample_rate = config .value ("job_sample_rate" )
@@ -48,6 +49,7 @@ def _any_sampling(self):
4849 or self .sample_endpoints
4950 or self .sample_jobs
5051 or self .ignore_endpoints
52+ or self .legacy_ignore
5153 or self .ignore_jobs
5254 or self .endpoint_sample_rate is not None
5355 or self .job_sample_rate is not None
Original file line number Diff line number Diff line change @@ -168,3 +168,30 @@ def test_prefix_matching_precedence(config):
168168
169169 # VIP users API should always be sampled
170170 assert sampler .should_sample ("Controller/api/users/vip/list" , False ) is True
171+
172+
173+ def test_should_sample_with_legacy_ignore (config ):
174+ """Test that sampling works correctly when only legacy 'ignore' config is set."""
175+ config .set (
176+ sample_rate = 100 , # Return config to defaults
177+ sample_endpoints = {},
178+ sample_jobs = {},
179+ ignore_endpoints = [], # No explicit ignore_endpoints
180+ ignore_jobs = [],
181+ ignore = ["metrics" , "health" ], # Only set legacy ignore patterns
182+ endpoint_sample_rate = None ,
183+ job_sample_rate = None ,
184+ )
185+ sampler = Sampler (config )
186+
187+ # Legacy ignored endpoints should not be sampled
188+ assert sampler .should_sample ("Controller/metrics/stats" , False ) is False
189+ assert sampler .should_sample ("Controller/health/check" , False ) is False
190+
191+ # Legacy ignore should be combined with ignore_endpoints
192+ assert "metrics" in sampler .ignore_endpoints
193+ assert "health" in sampler .ignore_endpoints
194+
195+ # Non-ignored endpoints and jobs should be sampled
196+ assert sampler .should_sample ("Controller/users/list" , False ) is True
197+ assert sampler .should_sample ("Job/process_data" , False ) is True
You can’t perform that action at this time.
0 commit comments