Skip to content

Commit 148ebf0

Browse files
committed
Fix flaky metrics comparison by ignoring transient labels
1 parent 9d2f487 commit 148ebf0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/e2e/compare_metrics.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111
# Configuration for transient labels that should be normalized during comparison
1212
TRANSIENT_LABEL_PATTERNS = {
13+
'GLOBAL': {
14+
'otel_scope_version': {
15+
'pattern': r'.*',
16+
'replacement': 'version'
17+
},
18+
'k8s_namespace_name': {
19+
'pattern': r'.*',
20+
'replacement': 'namespace'
21+
},
22+
'namespace': {
23+
'pattern': r'.*',
24+
'replacement': 'namespace'
25+
}
26+
},
1327
'kafka': {
1428
'topic': {
1529
'pattern': r'jaeger-spans-\d+',
@@ -38,8 +52,18 @@ def suppress_transient_labels(metric_name, labels):
3852
Dictionary of labels with transient values normalized
3953
"""
4054
labels_copy = labels.copy()
55+
56+
# Apply global patterns first
57+
if 'GLOBAL' in TRANSIENT_LABEL_PATTERNS:
58+
for label_name, pattern_config in TRANSIENT_LABEL_PATTERNS['GLOBAL'].items():
59+
if label_name in labels_copy:
60+
pattern = pattern_config['pattern']
61+
replacement = pattern_config['replacement']
62+
labels_copy[label_name] = re.sub(pattern, replacement, labels_copy[label_name])
4163

4264
for service_pattern, label_configs in TRANSIENT_LABEL_PATTERNS.items():
65+
if service_pattern == 'GLOBAL':
66+
continue
4367
if service_pattern in metric_name:
4468
for label_name, pattern_config in label_configs.items():
4569
if label_name in labels_copy:

0 commit comments

Comments
 (0)