Class TelemetryRouterExtensions
- Namespace
- IceRpc
- Assembly
- IceRpc.Telemetry.dll
Provides an extension method for Router to add the telemetry middleware.
public static class TelemetryRouterExtensions
- Inheritance
-
TelemetryRouterExtensions
- Inherited Members
Methods
UseTelemetry(Router, ActivitySource)
Adds a TelemetryMiddleware to the router.
public static Router UseTelemetry(this Router router, ActivitySource activitySource)
Parameters
router
RouterThe router being configured.
activitySource
ActivitySourceThe ActivitySource is used to start the request activity.
Returns
- Router
The router being configured.
Examples
The following code adds the telemetry middleware to the dispatch pipeline.
// The activity source used by the telemetry middleware.
using var activitySource = new ActivitySource("IceRpc");
// Add the telemetry middleware to the dispatch pipeline.
Router router = new Router()
.UseTelemetry(activitySource);
await using var server = new Server(router);
server.Listen();
- See Also