Class TelemetryMiddleware
A middleware that starts an Activity per request, following OpenTelemetry conventions. The middleware restores the parent invocation activity from the request TraceContext field before starting the dispatch activity.
public class TelemetryMiddleware : IDispatcher
- Inheritance
-
TelemetryMiddleware
- Implements
- Inherited Members
Remarks
The activities are only created for requests using the icerpc protocol.
Constructors
TelemetryMiddleware(IDispatcher, ActivitySource)
Constructs a telemetry middleware.
public TelemetryMiddleware(IDispatcher next, ActivitySource activitySource)
Parameters
next
IDispatcherThe next dispatcher in the dispatch pipeline.
activitySource
ActivitySourceThe ActivitySource is used to start the request activity.
Methods
DispatchAsync(IncomingRequest, CancellationToken)
Dispatches an incoming request and returns the corresponding outgoing response.
public ValueTask<OutgoingResponse> DispatchAsync(IncomingRequest request, CancellationToken cancellationToken)
Parameters
request
IncomingRequestThe incoming request being dispatched.
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<OutgoingResponse>
The corresponding OutgoingResponse.