| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using IceRpc.Telemetry; |
| | 4 | | using System.Diagnostics; |
| | 5 | |
|
| | 6 | | namespace IceRpc; |
| | 7 | |
|
| | 8 | | /// <summary>Provides an extension method for <see cref="Router" /> to add the telemetry middleware.</summary> |
| | 9 | | public static class TelemetryRouterExtensions |
| | 10 | | { |
| | 11 | | /// <summary>Adds a <see cref="TelemetryMiddleware" /> to the router.</summary> |
| | 12 | | /// <param name="router">The router being configured.</param> |
| | 13 | | /// <param name="activitySource">The <see cref="ActivitySource" /> is used to start the request activity.</param> |
| | 14 | | /// <returns>The router being configured.</returns> |
| | 15 | | /// <example> |
| | 16 | | /// The following code adds the telemetry middleware to the dispatch pipeline. |
| | 17 | | /// <code source="../../docfx/examples/IceRpc.Telemetry.Examples/TelemetryMiddlewareExamples.cs" region="UseTelemetr |
| | 18 | | /// </example> |
| | 19 | | /// <seealso href="https://github.com/icerpc/icerpc-csharp/tree/main/examples/Telemetry"/> |
| | 20 | | public static Router UseTelemetry(this Router router, ActivitySource activitySource) => |
| 0 | 21 | | router.Use(next => new TelemetryMiddleware(next, activitySource)); |
| | 22 | | } |