Skip to content

Commit a6023fe

Browse files
committed
Handle more priorities combinations
1 parent 20fe725 commit a6023fe

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tracer/src/Datadog.Trace/Configuration/ApmTracingConfig.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,21 @@ public ApmTracingConfig(string configId, LibConfig libConfig, ServiceTarget? ser
3535
/// <summary>
3636
/// Gets the priority of this configuration based on targeting specificity.
3737
/// 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)
3840
/// </summary>
3941
public int Priority
4042
{
4143
get
4244
{
4345
var hasService = !string.IsNullOrEmpty(ServiceTarget?.Service) && ServiceTarget?.Service != "*";
4446
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);
5553
}
5654
}
5755

@@ -108,8 +106,6 @@ private static LibConfig MergeLibConfigs(LibConfig higher, LibConfig lower)
108106
SpanSamplingRules = higher.SpanSamplingRules ?? lower.SpanSamplingRules,
109107
};
110108
}
111-
112-
internal record struct ConfigurationTarget(bool HasService, bool HasEnv, bool HasCluster);
113109
}
114110

115111
internal class ApmTracingConfigDto

0 commit comments

Comments
 (0)