Class TraceHeaderPropagatingHandler
Traces outgoing HTTP requests and propagates the trace header.
Inherited Members
Namespace: Google.Cloud.Diagnostics.Common
Assembly: Google.Cloud.Diagnostics.Common.dll
Syntax
public class TraceHeaderPropagatingHandler : UnchainedTraceHeaderPropagatingHandler
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 request current request.
Examples
public void DoSomething(IManagedTracer tracer)
{
var traceHeaderHandler = new TraceHeaderPropagatingHandler(() => tracer);
using (var httpClient = new HttpClient(traceHeaderHandler))
{
...
}
}
Constructors
TraceHeaderPropagatingHandler(Func<IManagedTracer>, HttpMessageHandler)
Constructs a new instance using the given delegate to obtain the "current" tracer on each request.
Declaration
public TraceHeaderPropagatingHandler(Func<IManagedTracer> managedTracerFactory, HttpMessageHandler innerHandler = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<IManagedTracer> | managedTracerFactory | A delegate used to obtain the "current" tracer for each request. The delegate should therefore be thread-safe. |
| HttpMessageHandler | innerHandler | The inner handler to delegate to. May be null, in which
case a new |