@@ -35,23 +35,21 @@ public ApmTracingConfig(string configId, LibConfig libConfig, ServiceTarget? ser
35
35
/// <summary>
36
36
/// Gets the priority of this configuration based on targeting specificity.
37
37
/// Higher values = higher priority.
38
+ /// Precedence ordering goes from most specific to least specific:
39
+ /// 1. Service (bit 2), 2. Env (bit 1), 3. Cluster target (bit 0)
38
40
/// </summary>
39
41
public int Priority
40
42
{
41
43
get
42
44
{
43
45
var hasService = ! string . IsNullOrEmpty ( ServiceTarget ? . Service ) && ServiceTarget ? . Service != "*" ;
44
46
var hasEnv = ! string . IsNullOrEmpty ( ServiceTarget ? . Env ) && ServiceTarget ? . Env != "*" ;
45
- var hasCluster = ClusterTarget != null ;
46
-
47
- return new ConfigurationTarget ( hasService , hasEnv , hasCluster ) switch
48
- {
49
- ( true , true , _ ) => 5 , // Service+env (highest priority)
50
- ( true , false , _ ) => 4 , // Service only
51
- ( false , true , _ ) => 3 , // Env only
52
- ( false , false , true ) => 2 , // Cluster
53
- ( false , false , false ) => 1 // Org level
54
- } ;
47
+ var hasCluster = ClusterTarget is { ClusterTargets . Count : > 0 } ;
48
+
49
+ // This handles all possible combinations
50
+ return ( ( hasService ? 1 : 0 ) << 2 ) |
51
+ ( ( hasEnv ? 1 : 0 ) << 1 ) |
52
+ ( ( hasCluster ? 1 : 0 ) << 0 ) ;
55
53
}
56
54
}
57
55
@@ -108,8 +106,6 @@ private static LibConfig MergeLibConfigs(LibConfig higher, LibConfig lower)
108
106
SpanSamplingRules = higher . SpanSamplingRules ?? lower . SpanSamplingRules ,
109
107
} ;
110
108
}
111
-
112
- internal record struct ConfigurationTarget ( bool HasService , bool HasEnv , bool HasCluster ) ;
113
109
}
114
110
115
111
internal class ApmTracingConfigDto
0 commit comments