Skip to content

Commit a3800d3

Browse files
committed
actually fix the conflict with #54437
1 parent 4067443 commit a3800d3

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,8 @@ internal sealed class DiagnosticsHandler : DelegatingHandler
2828

2929
public static bool IsGloballyEnabled { get; } = GetEnableActivityPropagationValue();
3030

31-
private static bool GetEnableActivityPropagationValue()
32-
{
33-
// First check for the AppContext switch, giving it priority over the environment variable.
34-
if (AppContext.TryGetSwitch(Namespace + ".EnableActivityPropagation", out bool enableActivityPropagation))
35-
{
36-
return enableActivityPropagation;
37-
}
38-
39-
// AppContext switch wasn't used. Check the environment variable to determine which handler should be used.
40-
string? envVar = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION");
41-
if (envVar != null && (envVar.Equals("false", StringComparison.OrdinalIgnoreCase) || envVar.Equals("0")))
42-
{
43-
// Suppress Activity propagation.
44-
return false;
45-
}
46-
47-
// Defaults to enabling Activity propagation.
48-
return true;
49-
}
31+
private static bool GetEnableActivityPropagationValue() =>
32+
RuntimeSettingParser.QueryRuntimeSettingSwitch(Namespace + ".EnableActivityPropagation", "DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION", true);
5033

5134
public DiagnosticsHandler(HttpMessageHandler innerHandler) : base(innerHandler)
5235
{
@@ -274,7 +257,6 @@ internal ResponseData(HttpResponseMessage? response, Guid loggingRequestId, long
274257
public override string ToString() => $"{{ {nameof(Response)} = {Response}, {nameof(LoggingRequestId)} = {LoggingRequestId}, {nameof(Timestamp)} = {Timestamp}, {nameof(RequestTaskStatus)} = {RequestTaskStatus} }}";
275258
}
276259

277-
private static bool GetEnableActivityPropagationValue() => RuntimeSettingParser.QueryRuntimeSettingSwitch(EnableActivityPropagationAppCtxSettingName, EnableActivityPropagationEnvironmentVariableSettingName, true);
278260
private static void InjectHeaders(Activity currentActivity, HttpRequestMessage request)
279261
{
280262
const string TraceParentHeaderName = "traceparent";

0 commit comments

Comments
 (0)