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
nextIDispatcherThe next dispatcher in the dispatch pipeline.
activitySourceActivitySourceThe 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
requestIncomingRequestThe incoming request being dispatched.
cancellationTokenCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<OutgoingResponse>
The outgoing response.