Remove TraceParent header from HttpClient requests

发布时间 2023-12-24 21:48:25作者: ChasingDreams

ASP.NET Core creates an Activity that represents the request by default. This is what tells HttpClient to send an outgoing request id header. You can disable it in a couple of ways:

By setting the current activity to null before making the request (Activity.Current = null)
By setting the environment variable DOTNET_SYSTEM_NET_HTTP_ENABLEACTIVITYPROPAGATION to "false" or "0".
By the AppContext switch System.Net.Http.EnableActivityPropagation to false

https://stackoverflow.com/questions/72277304/remove-traceparent-header-from-httpclient-requests