Remove TraceParent header from HttpClient requests

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

posted @ 2023-12-24 21:44  ChasingDreams  阅读(82)  评论(0编辑  收藏  举报