Table of Contents

Class TelemetryMiddleware

Namespace
IceRpc.Telemetry
Assembly
IceRpc.Telemetry.dll

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. The activity records the outcome of the dispatch. The rpc.status_code tag holds the status code of the response returned by the dispatch. When the dispatch throws an exception, this tag holds the status code of the failure response the caller receives, given by FromException(Exception). A status code that reports a problem with the request (ApplicationError, NotFound, InvalidData, TruncatedPayload and Unauthorized) leaves the activity status unset. Any other failure status code sets the activity status to Error and the error.type tag identifies the failure. A cancellation by the token passed to DispatchAsync(IncomingRequest, CancellationToken) is not a failure: the icerpc.canceled tag is set to true, the activity status stays unset, and the rpc.status_code tag is not set since the caller receives no response.

Constructors

TelemetryMiddleware(IDispatcher, ActivitySource)

Constructs a telemetry middleware.

public TelemetryMiddleware(IDispatcher next, ActivitySource activitySource)

Parameters

next IDispatcher

The next dispatcher in the dispatch pipeline.

activitySource ActivitySource

The 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 IncomingRequest

The incoming request being dispatched.

cancellationToken CancellationToken

A cancellation token that receives the cancellation requests.

Returns

ValueTask<OutgoingResponse>

The outgoing response.

See Also