IceRpc.Telemetry
0.7.0
Prefix Reserved
dotnet add package IceRpc.Telemetry --version 0.7.0
NuGet\Install-Package IceRpc.Telemetry -Version 0.7.0
<PackageReference Include="IceRpc.Telemetry" Version="0.7.0" />
<PackageVersion Include="IceRpc.Telemetry" Version="0.7.0" />
<PackageReference Include="IceRpc.Telemetry" />
paket add IceRpc.Telemetry --version 0.7.0
#r "nuget: IceRpc.Telemetry, 0.7.0"
#:package IceRpc.Telemetry@0.7.0
#addin nuget:?package=IceRpc.Telemetry&version=0.7.0
#tool nuget:?package=IceRpc.Telemetry&version=0.7.0
Telemetry interceptor and middleware for IceRPC
IceRpc.Telemetry provides an IceRPC interceptor and the corresponding middleware.
The telemetry interceptor starts an activity per request, following OpenTelemetry conventions. The activity context is propagated with the request using the trace context request field. The telemetry middleware starts an activity per dispatch. When the trace context request field is present in the incoming request the telemetry middleware restores the activity context and uses it to set the parent activity of the dispatch activity it starts.
The telemetry interceptor and middleware create activities only for requests that use the icerpc protocol; they
don't create activities for requests that use the ice protocol.
Source code | Package | Example | API reference | Interceptor documentation | Middleware documentation
Activity name and tags
The name of an activity is {path}/{operation}, for example /greeter/greet. The interceptor and the middleware set
the following tags, named after the OpenTelemetry semantic conventions for RPC spans:
| Tag | Client activity (interceptor) | Server activity (middleware) | Example |
|---|---|---|---|
rpc.system.name |
icerpc |
icerpc |
icerpc |
rpc.method |
The operation name. | The operation name. | greet |
icerpc.path |
The path of the service address. | The path carried by the request. | /greeter |
rpc.status_code |
The status code carried by the response. | The status code sent to the caller. | Ok, DeadlineExceeded |
error.type |
A status code other than Ok, or the full name of the exception thrown by the invocation. |
A status code that reports a server failure. | DeadlineExceeded, IceRpc.IceRpcException |
network.peer.address |
The IP address of the server. | The IP address of the client. | 10.1.2.80, ::ffff:10.1.2.80 |
network.peer.port |
The port of the server. | The port of the client. | 4062 |
icerpc.canceled |
true when the invocation was canceled. |
true when the dispatch was canceled. |
true |
An activity with an error.type tag has the Error status; the status of any other activity is unset. For the
middleware, the ApplicationError, NotFound, InvalidData, TruncatedPayload and Unauthorized status codes report
a problem with the request, not a server failure.
Sample code
// Client application
using IceRpc;
using System.Diagnostics;
using System.Security.Cryptography.X509Certificates;
// The activity source used by the telemetry interceptor.
using var activitySource = new ActivitySource("IceRpc");
// Load the test root CA certificate in order to connect to the server that uses a test
// server certificate.
using var rootCA = X509CertificateLoader.LoadCertificateFromFile("certs/cacert.der");
await using var connection = new ClientConnection(
new Uri("icerpc://localhost"),
// examples/common/Program.Authentication.cs in the icerpc-csharp repo provides the
// CreateClientAuthenticationOptions helper method
clientAuthenticationOptions: CreateClientAuthenticationOptions(rootCA));
// Add the telemetry interceptor to the invocation pipeline.
Pipeline pipeline = new Pipeline().UseTelemetry(activitySource).Into(connection);
// Server application
using IceRpc;
using System.Diagnostics;
// The activity source used by the telemetry interceptor and middleware.
using var activitySource = new ActivitySource("IceRpc");
// Add the telemetry middleware to the dispatch pipeline.
Router router = new Router().UseTelemetry(activitySource);
Sample code with DI
This sample stays focused on the telemetry registration. For a complete Generic Host setup with certificates and configuration, see the GenericHost example.
// Client application
using IceRpc;
using IceRpc.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Diagnostics;
HostApplicationBuilder hostBuilder = Host.CreateApplicationBuilder(args);
hostBuilder.Services
.AddIceRpcClientConnection(new Uri("icerpc://localhost"))
// The activity source used by the telemetry interceptor.
.AddSingleton(_ => new ActivitySource("IceRpc"))
.AddIceRpcInvoker(builder =>
builder
// Add the telemetry interceptor to the invocation pipeline.
.UseTelemetry()
.Into<ClientConnection>());
using IHost host = hostBuilder.Build();
host.Run();
// Server application
using IceRpc;
using IceRpc.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Diagnostics;
HostApplicationBuilder hostBuilder = Host.CreateApplicationBuilder(args);
hostBuilder.Services
// The activity source used by the telemetry middleware.
.AddSingleton(_ => new ActivitySource("IceRpc"))
.AddIceRpcServer(builder =>
builder
// Add the telemetry middleware to the dispatch pipeline.
.UseTelemetry()
.Map<...>());
using IHost host = hostBuilder.Build();
host.Run();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- IceRpc (= 0.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.7.0 | 55 | 11/20/2026 |
| 0.6.2 | 116 | 11/16/2026 |
| 0.6.1 | 621 | 9/17/2026 |
| 0.6.0 | 228 | 6/5/2026 |
| 0.5.2 | 169 | 5/18/2026 |
| 0.5.1 | 256 | 1/7/2026 |
| 0.5.0 | 791 | 12/1/2025 |
| 0.4.1 | 351 | 11/15/2024 |
| 0.4.0.1 | 317 | 9/17/2024 |
| 0.4.0 | 280 | 9/16/2024 |
| 0.3.1 | 342 | 3/28/2024 |
| 0.3.0 | 383 | 2/14/2024 |
| 0.2.1 | 380 | 12/12/2023 |
| 0.2.0 | 359 | 12/4/2023 |
| 0.1.2 | 316 | 10/9/2023 |
| 0.1.1 | 269 | 9/18/2023 |
| 0.1.0 | 300 | 9/6/2023 |