Skip to content

Commit 65589aa

Browse files
authored
ci: Exclude HTTP 5xx metrics from comparisons (#7671)
## Which problem is this PR solving? - Part of #7617 ## Description of the changes - This PR introduces the changes to filter out 503 calls to reduce the flakiness in the metrics comparision. ## How was this change tested? - I used the artifacts form https://github.com/jaegertracing/jaeger/actions/runs/19589467818/job/56105108460 and https://github.com/jaegertracing/jaeger/actions/runs/19596403385/job/56121587792?pr=7666 to manually test the script. Before changes the 503 calls were listed as metrics added/deleted but after changes they are being filtered correctly. Before changes <img width="1885" height="299" alt="image" src="https://github.com/user-attachments/assets/0bac1ceb-f8a9-47f3-b841-41639c4841c8" /> After changes <img width="1805" height="77" alt="image" src="https://github.com/user-attachments/assets/96e6d79c-352a-43a9-9da6-868791634277" /> ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Tushar Anand <tusharannand@gmail.com>
1 parent 72eca6e commit 65589aa

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

scripts/e2e/compare_metrics.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,41 @@
2626
# }
2727
}
2828

29+
METRIC_EXCLUSION_RULES = {
30+
# excluding HTTP 5xx responses as these can be flaky
31+
'http_5xx_errors': {
32+
'condition': 'label_match',
33+
'label': 'http_response_status_code',
34+
'pattern': r'^5\d{2}$',
35+
},
36+
37+
}
38+
39+
40+
def should_exclude_metric(metric_name, labels):
41+
"""
42+
Determines if a metric should be excluded from comparison based on configured rules.
43+
44+
Args:
45+
metric_name: The name of the metric
46+
labels: Dictionary of labels for the metric
47+
48+
Returns:
49+
tuple: (should_exclude: bool, reason: str or None)
50+
"""
51+
for rule_name, rule_config in METRIC_EXCLUSION_RULES.items():
52+
condition = rule_config['condition']
53+
54+
if condition == 'label_match':
55+
label = rule_config['label']
56+
pattern = rule_config['pattern']
57+
if label in labels and re.match(pattern, labels[label]):
58+
return True
59+
60+
61+
return False
62+
63+
2964
def suppress_transient_labels(metric_name, labels):
3065
"""
3166
Suppresses transient labels in metrics based on configured patterns.
@@ -58,9 +93,11 @@ def parse_metrics(content):
5893
for family in text_string_to_metric_families(content):
5994
for sample in family.samples:
6095
labels = dict(sample.labels)
61-
#simply pop undesirable metric labels
62-
labels.pop('service_instance_id',None)
63-
96+
97+
if should_exclude_metric(sample.name, labels):
98+
continue
99+
100+
labels.pop('service_instance_id', None)
64101
labels = suppress_transient_labels(sample.name, labels)
65102

66103
label_pairs = sorted(labels.items(), key=lambda x: x[0])

0 commit comments

Comments
 (0)