Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions scripts/e2e/compare_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@

# Configuration for transient labels that should be normalized during comparison
TRANSIENT_LABEL_PATTERNS = {
'GLOBAL': {
'otel_scope_version': {
'pattern': r'.*',
'replacement': 'version'
},
'k8s_namespace_name': {
'pattern': r'.*',
'replacement': 'namespace'
},
'namespace': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of namespace label? In which context does it come up? If it's specific to some of the storage implementations then it should not be in GLOBAL but in its own category

'pattern': r'.*',
'replacement': 'namespace'
}
},
'kafka': {
'topic': {
'pattern': r'jaeger-spans-\d+',
Expand Down Expand Up @@ -38,8 +52,17 @@ def suppress_transient_labels(metric_name, labels):
Dictionary of labels with transient values normalized
"""
labels_copy = labels.copy()

# Apply global patterns first
if 'GLOBAL' in TRANSIENT_LABEL_PATTERNS:
for label_name, pattern_config in TRANSIENT_LABEL_PATTERNS['GLOBAL'].items():
if label_name in labels_copy:
# For global patterns, directly replace the value
labels_copy[label_name] = pattern_config['replacement']

for service_pattern, label_configs in TRANSIENT_LABEL_PATTERNS.items():
if service_pattern == 'GLOBAL':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python dicts guarantee the order of keys to respect the order of declaration, so GLOBAL always comes in first. You can add a comment in its declaration clarifying that it must be first.

continue
if service_pattern in metric_name:
for label_name, pattern_config in label_configs.items():
if label_name in labels_copy:
Expand Down
Loading