Http Span Status - Default to Unset if not in range defined by spec (#5060)

This commit is contained in:
Vishwesh Bankwar 2023-11-17 14:02:24 -08:00 committed by GitHub
parent 68eabf0188
commit 0256f875d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -32,12 +32,13 @@ internal static class SpanHelper
/// <returns>Resolved span <see cref="Status"/> for the Http status code.</returns>
public static ActivityStatusCode ResolveSpanStatusForHttpStatusCode(ActivityKind kind, int httpStatusCode)
{
var upperBound = kind == ActivityKind.Client ? 399 : 499;
if (httpStatusCode >= 100 && httpStatusCode <= upperBound)
var lowerBound = kind == ActivityKind.Client ? 400 : 500;
var upperBound = 599;
if (httpStatusCode >= lowerBound && httpStatusCode <= upperBound)
{
return ActivityStatusCode.Unset;
return ActivityStatusCode.Error;
}
return ActivityStatusCode.Error;
return ActivityStatusCode.Unset;
}
}