File tree 2 files changed +29
-0
lines changed
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):
32
32
self .ignore_endpoints = set (
33
33
config .value ("ignore_endpoints" ) + config .value ("ignore" )
34
34
)
35
+ self .legacy_ignore = set (config .value ("ignore" ))
35
36
self .ignore_jobs = set (config .value ("ignore_jobs" ))
36
37
self .endpoint_sample_rate = config .value ("endpoint_sample_rate" )
37
38
self .job_sample_rate = config .value ("job_sample_rate" )
@@ -48,6 +49,7 @@ def _any_sampling(self):
48
49
or self .sample_endpoints
49
50
or self .sample_jobs
50
51
or self .ignore_endpoints
52
+ or self .legacy_ignore
51
53
or self .ignore_jobs
52
54
or self .endpoint_sample_rate is not None
53
55
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):
168
168
169
169
# VIP users API should always be sampled
170
170
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