File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111# Configuration for transient labels that should be normalized during comparison
1212TRANSIENT_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,17 @@ 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+ # For global patterns, directly replace the value
61+ labels_copy [label_name ] = pattern_config ['replacement' ]
4162
4263 for service_pattern , label_configs in TRANSIENT_LABEL_PATTERNS .items ():
64+ if service_pattern == 'GLOBAL' :
65+ continue
4366 if service_pattern in metric_name :
4467 for label_name , pattern_config in label_configs .items ():
4568 if label_name in labels_copy :
You can’t perform that action at this time.
0 commit comments