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': {
'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:
Copy link
Member

Choose a reason for hiding this comment

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

so if the PR is meant to fix the metrics divergence then should we expect zero diffs reported in the PR? This one has 106 differences still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you should expect zero diffs now. I just pushed a fix that addresses the label value duplication bug I found during testing. The previous version was incorrectly normalizing labels which caused the 106 differences.

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':
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