Skip to content

Commit

Permalink
actually fix the conflict with #54437
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Jun 25, 2021
1 parent 4067443 commit a3800d3
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,8 @@ internal sealed class DiagnosticsHandler : DelegatingHandler

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

private static bool GetEnableActivityPropagationValue()
{
// First check for the AppContext switch, giving it priority over the environment variable.
if (AppContext.TryGetSwitch(Namespace + ".EnableActivityPropagation", out bool enableActivityPropagation))
{
return enableActivityPropagation;
}

// AppContext switch wasn't used. Check the environment variable to determine which handler should be used.
string? envVar = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION");
if (envVar != null && (envVar.Equals("false", StringComparison.OrdinalIgnoreCase) || envVar.Equals("0")))
{
// Suppress Activity propagation.
return false;
}

// Defaults to enabling Activity propagation.
return true;
}
private static bool GetEnableActivityPropagationValue() =>
RuntimeSettingParser.QueryRuntimeSettingSwitch(Namespace + ".EnableActivityPropagation", "DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION", true);

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

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

0 comments on commit a3800d3

Please sign in to comment.