diff --git a/Examples/aspnetcore/frontend/Startup.cs b/Examples/aspnetcore/frontend/Startup.cs index 204048d..fd106e0 100644 --- a/Examples/aspnetcore/frontend/Startup.cs +++ b/Examples/aspnetcore/frontend/Startup.cs @@ -13,7 +13,7 @@ public class Startup : CommonStartup public override void ConfigureServices(IServiceCollection services) { services.AddHttpClient("Tracer").AddHttpMessageHandler(provider => - new TracingHandler(provider.GetService()["applicationName"])); + TracingHandler.WithoutInnerHandler(provider.GetService()["applicationName"])); } protected override void Run(IApplicationBuilder app, IConfiguration config) diff --git a/Src/zipkin4net/Src/Transport/Http/TracingHandler.cs b/Src/zipkin4net/Src/Transport/Http/TracingHandler.cs index 5233e68..177e5f9 100644 --- a/Src/zipkin4net/Src/Transport/Http/TracingHandler.cs +++ b/Src/zipkin4net/Src/Transport/Http/TracingHandler.cs @@ -12,13 +12,13 @@ public class TracingHandler : DelegatingHandler private readonly string _serviceName; private readonly Func _getClientTraceRpc; - public TracingHandler(string serviceName, HttpMessageHandler httpMessageHandler, Func getClientTraceRpc = null) - : this(Propagations.B3String.Injector((carrier, key, value) => carrier.Add(key, value)), serviceName, httpMessageHandler, getClientTraceRpc) + public TracingHandler(string serviceName, HttpMessageHandler httpMessageHandler = null, Func getClientTraceRpc = null) + : this(Propagations.B3String.Injector((carrier, key, value) => carrier.Add(key, value)), serviceName, httpMessageHandler ?? new HttpClientHandler(), getClientTraceRpc) { } - public TracingHandler(string serviceName, Func getClientTraceRpc = null) - : this(Propagations.B3String.Injector((carrier, key, value) => carrier.Add(key, value)), serviceName, getClientTraceRpc) - { } + + public static TracingHandler WithoutInnerHandler(string serviceName, Func getClientTraceRpc = null) + => new TracingHandler(Propagations.B3String.Injector((carrier, key, value) => carrier.Add(key, value)), serviceName, getClientTraceRpc); private TracingHandler(IInjector injector, string serviceName, HttpMessageHandler httpMessageHandler, Func getClientTraceRpc = null) : base(httpMessageHandler)