Class TelemetryInterceptor
An interceptor that starts an Activity per request, following OpenTelemetry conventions. The activity context is written in the request TraceContext field and can be restored on the server-side by installing the TelemetryMiddleware.
public class TelemetryInterceptor : IInvoker
- Inheritance
-
TelemetryInterceptor
- Implements
- Inherited Members
- Extension Methods
Remarks
The interceptor creates an activity only for a request that uses the icerpc protocol. The name of this
activity is {path}/{operation}, and its tags are:
<ul><li><code>rpc.system.name</code>: <code>icerpc</code>.</li><li><code>rpc.method</code>: the operation name.</li><li><code>icerpc.path</code>: the path of the service address.</li><li><code>rpc.status_code</code>: the status code carried by the response.</li><li><code>error.type</code>: a status code other than <xref href="IceRpc.StatusCode.Ok" data-throw-if-not-resolved="false"></xref>, or the full name of
the exception thrown by the invocation.</li><li><code>network.peer.address</code> and <code>network.peer.port</code>: the IP address and the port of the
server.</li><li><code>icerpc.canceled</code>: <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> when the invocation was canceled.
</li></ul>
An activity with an <code>error.type</code> tag has the <xref href="System.Diagnostics.ActivityStatusCode.Error" data-throw-if-not-resolved="false"></xref> status; the status of any
other activity is unset.
Constructors
TelemetryInterceptor(IInvoker, ActivitySource)
Constructs a telemetry interceptor.
public TelemetryInterceptor(IInvoker next, ActivitySource activitySource)
Parameters
nextIInvokerThe next invoker in the invocation pipeline.
activitySourceActivitySourceThe ActivitySource used to start the request activity.
Methods
InvokeAsync(OutgoingRequest, CancellationToken)
Sends an outgoing request and returns the corresponding incoming response.
public Task<IncomingResponse> InvokeAsync(OutgoingRequest request, CancellationToken cancellationToken)
Parameters
requestOutgoingRequestThe outgoing request being sent.
cancellationTokenCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task<IncomingResponse>
The corresponding IncomingResponse.
Remarks
When request is a two-way request, the returned task will not complete successfully
until after the request's Payload is fully sent and the response is received from
the peer. When the request is a one-way request, the returned task completes successfully with an empty response
when the request's Payload is fully sent. For all requests (one-way and two-way),
the sending of the request's PayloadContinuation can continue in a background task
after the returned task has completed successfully.