Class TraceHeaderPropagatingHandler (4.4.0)

[Obsolete("Use Google.Cloud.Diagnostics.Common.HttpClientBuilderExtensions.AddOutgoingGoogleTraceHandler insted. For more information see https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests")]
public class TraceHeaderPropagatingHandler : UnchainedTraceHeaderPropagatingHandler, IDisposable

Traces outgoing HTTP requests and propagates the trace header.

Inheritance

Object > HttpMessageHandler > DelegatingHandler > UnchainedTraceHeaderPropagatingHandler > TraceHeaderPropagatingHandler

Implements

IDisposable

Namespace

Google.Cloud.Diagnostics.Common

Assembly

Google.Cloud.Diagnostics.Common.dll

Remarks

Ensures the trace header is propagated in the headers for outgoing HTTP requests and traces the total time of the outgoing HTTP request. This is only done if tracing is initialized and tracing is enabled for the current request.

Constructors

TraceHeaderPropagatingHandler(Func<IManagedTracer>, Action<HttpRequestMessage, ITraceContext>, HttpMessageHandler)

public TraceHeaderPropagatingHandler(Func<IManagedTracer> managedTracerFactory, Action<HttpRequestMessage, ITraceContext> traceContextPropagator, HttpMessageHandler innerHandler = null)

Constructs a new instance using the given delegate to obtain the "current" tracer on each request.

Parameters
NameDescription
managedTracerFactoryFunc<IManagedTracer>

A delegate used to obtain the "current" tracer for each request. The delegate should therefore be thread-safe.

traceContextPropagatorAction<HttpRequestMessage, ITraceContext>

The trace context propagator used to set the trace context on the outgoing HTTP request. May be null, in which case the Google Trace Header will be set.

innerHandlerHttpMessageHandler

The inner handler to delegate to. May be null, in which case a new HttpClientHandler will be used.

TraceHeaderPropagatingHandler(Func<IManagedTracer>, HttpMessageHandler)

public TraceHeaderPropagatingHandler(Func<IManagedTracer> managedTracerFactory, HttpMessageHandler innerHandler = null)

Constructs a new instance using the given delegate to obtain the "current" tracer on each request.

Parameters
NameDescription
managedTracerFactoryFunc<IManagedTracer>

A delegate used to obtain the "current" tracer for each request. The delegate should therefore be thread-safe.

innerHandlerHttpMessageHandler

The inner handler to delegate to. May be null, in which case a new HttpClientHandler will be used.