microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Teams.Core/Diagnostics/Telemetry.cs
71lines · 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.Core.Diagnostics; |
| 8 | |
| 9 | /// <summary> |
| 10 | /// Singletons for the SDK's <see cref="ActivitySource"/>, <see cref="Meter"/>, and instruments. |
| 11 | /// Internal to <c>Microsoft.Teams.Core</c>. |
| 12 | /// </summary> |
| 13 | internal static class Telemetry |
| 14 | { |
| 15 | private const string s_version = ThisAssembly.NuGetPackageVersion; |
| 16 | |
| 17 | public static readonly ActivitySource Source = |
| 18 | new(CoreTelemetryNames.ActivitySourceName, s_version); |
| 19 | |
| 20 | public static readonly Meter Meter = |
| 21 | new(CoreTelemetryNames.MeterName, s_version); |
| 22 | |
| 23 | public static readonly Counter<long> ActivitiesReceived = |
| 24 | Meter.CreateCounter<long>("teams.activities.received", description: "Total activities received by the bot."); |
| 25 | |
| 26 | public static readonly Histogram<double> TurnDuration = |
| 27 | Meter.CreateHistogram<double>("teams.turn.duration", unit: "ms", description: "Duration of full turn processing."); |
| 28 | |
| 29 | public static readonly Counter<long> HandlerErrors = |
| 30 | Meter.CreateCounter<long>("teams.handler.errors", description: "Total exceptions thrown during turn processing."); |
| 31 | |
| 32 | public static readonly Histogram<double> MiddlewareDuration = |
| 33 | Meter.CreateHistogram<double>("teams.middleware.duration", unit: "ms", description: "Duration of individual middleware execution."); |
| 34 | |
| 35 | public static readonly Counter<long> OutboundCalls = |
| 36 | Meter.CreateCounter<long>("teams.outbound.calls", description: "Total outbound Bot Service API calls."); |
| 37 | |
| 38 | public static readonly Counter<long> OutboundErrors = |
| 39 | Meter.CreateCounter<long>("teams.outbound.errors", description: "Total outbound Bot Service API call errors."); |
| 40 | |
| 41 | // Span name constants — kept here so callers don't drift on naming. |
| 42 | public static class Spans |
| 43 | { |
| 44 | public const string Turn = "turn"; |
| 45 | public const string Middleware = "middleware"; |
| 46 | public const string AuthOutbound = "auth.outbound"; |
| 47 | public const string ConversationClient = "conversation_client"; |
| 48 | } |
| 49 | |
| 50 | public static class Tags |
| 51 | { |
| 52 | public const string ActivityType = "activity.type"; |
| 53 | public const string ActivityId = "activity.id"; |
| 54 | public const string ConversationId = "conversation.id"; |
| 55 | public const string ChannelId = "channel.id"; |
| 56 | public const string BotId = "bot.id"; |
| 57 | public const string ServiceUrl = "service.url"; |
| 58 | public const string MiddlewareName = "middleware.name"; |
| 59 | public const string MiddlewareIndex = "middleware.index"; |
| 60 | public const string AuthFlow = "auth.flow"; |
| 61 | public const string AuthScope = "auth.scope"; |
| 62 | public const string Operation = "operation"; |
| 63 | } |
| 64 | |
| 65 | public static class Operations |
| 66 | { |
| 67 | public const string SendActivity = "sendActivity"; |
| 68 | public const string UpdateActivity = "updateActivity"; |
| 69 | public const string DeleteActivity = "deleteActivity"; |
| 70 | } |
| 71 | } |
| 72 | |