Class UnchainedTraceHeaderPropagatingHandler
Class for tracing outgoing HTTP requests and propagating the trace header.
Namespace: Google.Cloud.Diagnostics.Common
Assembly: Google.Cloud.Diagnostics.Common.dll
Syntax
public class UnchainedTraceHeaderPropagatingHandler : DelegatingHandler
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.
Explicitly leaves unset the InnerHandler property so that this Handler can be used with the System.Net.Http.IHttpClientFactory defined in Microsoft.Extensions.Http.
Constructors
UnchainedTraceHeaderPropagatingHandler(Func<IManagedTracer>)
Constructs a new instance using the given delegate to obtain the "current" tracer on each request.
Declaration
public UnchainedTraceHeaderPropagatingHandler(Func<IManagedTracer> managedTracerFactory)
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. |
Methods
SendAsync(HttpRequestMessage, CancellationToken)
Sends the given request. If tracing is initialized and enabled the outgoing request is traced and the trace header is added to the request.
Declaration
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpRequestMessage | request | |
| System.Threading.CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<HttpResponseMessage> |