| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | namespace IceRpc.Telemetry.Internal; |
| | | 4 | | |
| | | 5 | | /// <summary>Provides an extension method for <see cref="StatusCode" /> to identify a failure in the |
| | | 6 | | /// <c>error.type</c> tag of an activity.</summary> |
| | | 7 | | internal static class StatusCodeExtensions |
| | | 8 | | { |
| | | 9 | | /// <summary>Gets the <c>error.type</c> of a failure status code. <see cref="StatusCode" /> is an unchecked enum, so |
| | | 10 | | /// an undefined value maps to <c>_OTHER</c> to keep the cardinality of <c>error.type</c> bounded.</summary> |
| | | 11 | | /// <param name="statusCode">The failure status code.</param> |
| | | 12 | | /// <returns>The name of <paramref name="statusCode" /> when it is defined; otherwise, <c>_OTHER</c>.</returns> |
| | | 13 | | internal static string ToErrorType(this StatusCode statusCode) => |
| | 15 | 14 | | Enum.IsDefined(statusCode) ? statusCode.ToString() : "_OTHER"; |
| | | 15 | | } |