@@ -28,25 +28,8 @@ internal sealed class DiagnosticsHandler : DelegatingHandler
28
28
29
29
public static bool IsGloballyEnabled { get ; } = GetEnableActivityPropagationValue ( ) ;
30
30
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 ) ;
50
33
51
34
public DiagnosticsHandler ( HttpMessageHandler innerHandler ) : base ( innerHandler )
52
35
{
@@ -274,7 +257,6 @@ internal ResponseData(HttpResponseMessage? response, Guid loggingRequestId, long
274
257
public override string ToString ( ) => $ "{{ { nameof ( Response ) } = { Response } , { nameof ( LoggingRequestId ) } = { LoggingRequestId } , { nameof ( Timestamp ) } = { Timestamp } , { nameof ( RequestTaskStatus ) } = { RequestTaskStatus } }}";
275
258
}
276
259
277
- private static bool GetEnableActivityPropagationValue ( ) => RuntimeSettingParser . QueryRuntimeSettingSwitch ( EnableActivityPropagationAppCtxSettingName , EnableActivityPropagationEnvironmentVariableSettingName , true ) ;
278
260
private static void InjectHeaders ( Activity currentActivity , HttpRequestMessage request )
279
261
{
280
262
const string TraceParentHeaderName = "traceparent" ;
0 commit comments