microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Teams.Apps/Diagnostics/AppsTelemetry.cs
55lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Diagnostics; |
| 5 | using System.Diagnostics.Metrics; |
| 6 | |
| 7 | namespace Microsoft.Teams.Apps.Diagnostics; |
| 8 | |
| 9 | /// <summary> |
| 10 | /// Singletons for the Apps-level <see cref="ActivitySource"/>, <see cref="Meter"/>, and instruments. |
| 11 | /// Internal to <c>Microsoft.Teams.Apps</c>. |
| 12 | /// </summary> |
| 13 | internal static class AppsTelemetry |
| 14 | { |
| 15 | private const string s_version = ThisAssembly.NuGetPackageVersion; |
| 16 | |
| 17 | public static readonly ActivitySource Source = |
| 18 | new(TeamsBotApplicationTelemetry.ActivitySourceName, s_version); |
| 19 | |
| 20 | public static readonly Meter Meter = |
| 21 | new(TeamsBotApplicationTelemetry.MeterName, s_version); |
| 22 | |
| 23 | public static readonly Counter<long> HandlerDispatched = |
| 24 | Meter.CreateCounter<long>(Metrics.HandlerDispatched, description: "Total handler invocations dispatched by the router."); |
| 25 | |
| 26 | public static readonly Histogram<double> HandlerDuration = |
| 27 | Meter.CreateHistogram<double>(Metrics.HandlerDuration, unit: "ms", description: "Duration of individual handler invocations."); |
| 28 | |
| 29 | public static readonly Counter<long> HandlerFailures = |
| 30 | Meter.CreateCounter<long>(Metrics.HandlerFailures, description: "Total handler invocations that threw an exception."); |
| 31 | |
| 32 | public static readonly Counter<long> HandlerUnmatched = |
| 33 | Meter.CreateCounter<long>(Metrics.HandlerUnmatched, description: "Total activities that found no matching route."); |
| 34 | |
| 35 | public static class Spans |
| 36 | { |
| 37 | public const string Handler = "handler"; |
| 38 | } |
| 39 | |
| 40 | public static class Tags |
| 41 | { |
| 42 | public const string HandlerType = "handler.type"; |
| 43 | public const string HandlerDispatch = "handler.dispatch"; |
| 44 | public const string ActivityType = "activity.type"; |
| 45 | public const string InvokeName = "invoke.name"; |
| 46 | } |
| 47 | |
| 48 | public static class Metrics |
| 49 | { |
| 50 | public const string HandlerDispatched = "teams.handler.dispatched"; |
| 51 | public const string HandlerDuration = "teams.handler.duration"; |
| 52 | public const string HandlerFailures = "teams.handler.failures"; |
| 53 | public const string HandlerUnmatched = "teams.handler.unmatched"; |
| 54 | } |
| 55 | } |
| 56 | |