Rename CanonicalCode to StatusCanonicalCode (#618)
* Add new ctor to Status, Rename CanonicalCode to StatusCanonicalCode. Both changes make code match the spec. * revert Status public ctor. There already exists a more efficient way to create Status without ctor. * minor * PropertyName in Status to be simply CanonicalCode ionstead of StatusCanonicalCode, as the name of class itself is Status already and hence no need to repeat in property name Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
This commit is contained in:
parent
9a1fa32b83
commit
8a22eaf81e
|
|
@ -24,12 +24,12 @@ namespace OpenTelemetry.Trace
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The operation completed successfully.
|
/// The operation completed successfully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Ok = new Status(CanonicalCode.Ok);
|
public static readonly Status Ok = new Status(StatusCanonicalCode.Ok);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The operation was cancelled (typically by the caller).
|
/// The operation was cancelled (typically by the caller).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Cancelled = new Status(CanonicalCode.Cancelled);
|
public static readonly Status Cancelled = new Status(StatusCanonicalCode.Cancelled);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unknown error. An example of where this error may be returned is if a Status value received
|
/// Unknown error. An example of where this error may be returned is if a Status value received
|
||||||
|
|
@ -37,14 +37,14 @@ namespace OpenTelemetry.Trace
|
||||||
/// Also errors raised by APIs that do not return enough error information may be converted to
|
/// Also errors raised by APIs that do not return enough error information may be converted to
|
||||||
/// this error.
|
/// this error.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Unknown = new Status(CanonicalCode.Unknown);
|
public static readonly Status Unknown = new Status(StatusCanonicalCode.Unknown);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION.
|
/// Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION.
|
||||||
/// INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the
|
/// INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the
|
||||||
/// system (e.g., a malformed file name).
|
/// system (e.g., a malformed file name).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status InvalidArgument = new Status(CanonicalCode.InvalidArgument);
|
public static readonly Status InvalidArgument = new Status(StatusCanonicalCode.InvalidArgument);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deadline expired before operation could complete. For operations that change the state of the
|
/// Deadline expired before operation could complete. For operations that change the state of the
|
||||||
|
|
@ -52,17 +52,17 @@ namespace OpenTelemetry.Trace
|
||||||
/// example, a successful response from a server could have been delayed long enough for the
|
/// example, a successful response from a server could have been delayed long enough for the
|
||||||
/// deadline to expire.
|
/// deadline to expire.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status DeadlineExceeded = new Status(CanonicalCode.DeadlineExceeded);
|
public static readonly Status DeadlineExceeded = new Status(StatusCanonicalCode.DeadlineExceeded);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some requested entity (e.g., file or directory) was not found.
|
/// Some requested entity (e.g., file or directory) was not found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status NotFound = new Status(CanonicalCode.NotFound);
|
public static readonly Status NotFound = new Status(StatusCanonicalCode.NotFound);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some entity that we attempted to create (e.g., file or directory) already exists.
|
/// Some entity that we attempted to create (e.g., file or directory) already exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status AlreadyExists = new Status(CanonicalCode.AlreadyExists);
|
public static readonly Status AlreadyExists = new Status(StatusCanonicalCode.AlreadyExists);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The caller does not have permission to execute the specified operation. PERMISSION_DENIED
|
/// The caller does not have permission to execute the specified operation. PERMISSION_DENIED
|
||||||
|
|
@ -70,18 +70,18 @@ namespace OpenTelemetry.Trace
|
||||||
/// instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be
|
/// instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be
|
||||||
/// identified (use UNAUTHENTICATED instead for those errors).
|
/// identified (use UNAUTHENTICATED instead for those errors).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status PermissionDenied = new Status(CanonicalCode.PermissionDenied);
|
public static readonly Status PermissionDenied = new Status(StatusCanonicalCode.PermissionDenied);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The request does not have valid authentication credentials for the operation.
|
/// The request does not have valid authentication credentials for the operation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Unauthenticated = new Status(CanonicalCode.Unauthenticated);
|
public static readonly Status Unauthenticated = new Status(StatusCanonicalCode.Unauthenticated);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system
|
/// Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system
|
||||||
/// is out of space.
|
/// is out of space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status ResourceExhausted = new Status(CanonicalCode.ResourceExhausted);
|
public static readonly Status ResourceExhausted = new Status(StatusCanonicalCode.ResourceExhausted);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operation was rejected because the system is not in a state required for the operation's
|
/// Operation was rejected because the system is not in a state required for the operation's
|
||||||
|
|
@ -95,13 +95,13 @@ namespace OpenTelemetry.Trace
|
||||||
/// is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless
|
/// is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless
|
||||||
/// they have first fixed up the directory by deleting files from it.
|
/// they have first fixed up the directory by deleting files from it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status FailedPrecondition = new Status(CanonicalCode.FailedPrecondition);
|
public static readonly Status FailedPrecondition = new Status(StatusCanonicalCode.FailedPrecondition);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The operation was aborted, typically due to a concurrency issue like sequencer check
|
/// The operation was aborted, typically due to a concurrency issue like sequencer check
|
||||||
/// failures, transaction aborts, etc.
|
/// failures, transaction aborts, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Aborted = new Status(CanonicalCode.Aborted);
|
public static readonly Status Aborted = new Status(StatusCanonicalCode.Aborted);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operation was attempted past the valid range. E.g., seeking or reading past end of file.
|
/// Operation was attempted past the valid range. E.g., seeking or reading past end of file.
|
||||||
|
|
@ -116,18 +116,18 @@ namespace OpenTelemetry.Trace
|
||||||
/// iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are
|
/// iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are
|
||||||
/// done.
|
/// done.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status OutOfRange = new Status(CanonicalCode.OutOfRange);
|
public static readonly Status OutOfRange = new Status(StatusCanonicalCode.OutOfRange);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operation is not implemented or not supported/enabled in this service.
|
/// Operation is not implemented or not supported/enabled in this service.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Unimplemented = new Status(CanonicalCode.Unimplemented);
|
public static readonly Status Unimplemented = new Status(StatusCanonicalCode.Unimplemented);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal errors. Means some invariants expected by underlying system has been broken. If you
|
/// Internal errors. Means some invariants expected by underlying system has been broken. If you
|
||||||
/// see one of these errors, something is very broken.
|
/// see one of these errors, something is very broken.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Internal = new Status(CanonicalCode.Internal);
|
public static readonly Status Internal = new Status(StatusCanonicalCode.Internal);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The service is currently unavailable. This is a most likely a transient condition and may be
|
/// The service is currently unavailable. This is a most likely a transient condition and may be
|
||||||
|
|
@ -135,16 +135,16 @@ namespace OpenTelemetry.Trace
|
||||||
///
|
///
|
||||||
/// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE.
|
/// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status Unavailable = new Status(CanonicalCode.Unavailable);
|
public static readonly Status Unavailable = new Status(StatusCanonicalCode.Unavailable);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unrecoverable data loss or corruption.
|
/// Unrecoverable data loss or corruption.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Status DataLoss = new Status(CanonicalCode.DataLoss);
|
public static readonly Status DataLoss = new Status(StatusCanonicalCode.DataLoss);
|
||||||
|
|
||||||
internal Status(CanonicalCode canonicalCode, string description = null)
|
internal Status(StatusCanonicalCode statusCanonicalCode, string description = null)
|
||||||
{
|
{
|
||||||
this.CanonicalCode = canonicalCode;
|
this.CanonicalCode = statusCanonicalCode;
|
||||||
this.Description = description;
|
this.Description = description;
|
||||||
this.IsValid = true;
|
this.IsValid = true;
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +158,7 @@ namespace OpenTelemetry.Trace
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the canonical code from this status.
|
/// Gets the canonical code from this status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CanonicalCode CanonicalCode { get; }
|
public StatusCanonicalCode CanonicalCode { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the status description.
|
/// Gets the status description.
|
||||||
|
|
@ -168,7 +168,7 @@ namespace OpenTelemetry.Trace
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether span completed sucessfully.
|
/// Gets a value indicating whether span completed sucessfully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsOk => this.CanonicalCode == CanonicalCode.Ok;
|
public bool IsOk => this.CanonicalCode == StatusCanonicalCode.Ok;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compare two <see cref="Status"/> for equality.
|
/// Compare two <see cref="Status"/> for equality.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// <copyright file="CanonicalCode.cs" company="OpenTelemetry Authors">
|
// <copyright file="StatusCanonicalCode.cs" company="OpenTelemetry Authors">
|
||||||
// Copyright 2018, OpenTelemetry Authors
|
// Copyright 2018, OpenTelemetry Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -19,7 +19,11 @@ namespace OpenTelemetry.Trace
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Canonical result code of span execution.
|
/// Canonical result code of span execution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum CanonicalCode
|
/// <remarks>
|
||||||
|
/// This follows the standard GRPC codes.
|
||||||
|
/// https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
|
||||||
|
/// </remarks>
|
||||||
|
public enum StatusCanonicalCode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The operation completed successfully.
|
/// The operation completed successfully.
|
||||||
|
|
@ -56,7 +56,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
|
||||||
["db.instance"] = 4, // peer.service for Redis.
|
["db.instance"] = 4, // peer.service for Redis.
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Dictionary<CanonicalCode, string> CanonicalCodeDictionary = new Dictionary<CanonicalCode, string>();
|
private static readonly Dictionary<StatusCanonicalCode, string> CanonicalCodeDictionary = new Dictionary<StatusCanonicalCode, string>();
|
||||||
|
|
||||||
private static readonly DictionaryEnumerator<string, object, TagState>.ForEachDelegate ProcessAttributeRef = ProcessAttribute;
|
private static readonly DictionaryEnumerator<string, object, TagState>.ForEachDelegate ProcessAttributeRef = ProcessAttribute;
|
||||||
private static readonly DictionaryEnumerator<string, object, TagState>.ForEachDelegate ProcessLibraryAttributeRef = ProcessLibraryAttribute;
|
private static readonly DictionaryEnumerator<string, object, TagState>.ForEachDelegate ProcessLibraryAttributeRef = ProcessLibraryAttribute;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation
|
||||||
|
|
||||||
private static readonly ConcurrentDictionary<string, ZipkinEndpoint> LocalEndpointCache = new ConcurrentDictionary<string, ZipkinEndpoint>();
|
private static readonly ConcurrentDictionary<string, ZipkinEndpoint> LocalEndpointCache = new ConcurrentDictionary<string, ZipkinEndpoint>();
|
||||||
private static readonly ConcurrentDictionary<string, ZipkinEndpoint> RemoteEndpointCache = new ConcurrentDictionary<string, ZipkinEndpoint>();
|
private static readonly ConcurrentDictionary<string, ZipkinEndpoint> RemoteEndpointCache = new ConcurrentDictionary<string, ZipkinEndpoint>();
|
||||||
private static readonly ConcurrentDictionary<CanonicalCode, string> CanonicalCodeCache = new ConcurrentDictionary<CanonicalCode, string>();
|
private static readonly ConcurrentDictionary<StatusCanonicalCode, string> CanonicalCodeCache = new ConcurrentDictionary<StatusCanonicalCode, string>();
|
||||||
|
|
||||||
private static readonly DictionaryEnumerator<string, object, AttributeEnumerationState>.ForEachDelegate ProcessAttributesRef = ProcessAttributes;
|
private static readonly DictionaryEnumerator<string, object, AttributeEnumerationState>.ForEachDelegate ProcessAttributesRef = ProcessAttributes;
|
||||||
private static readonly DictionaryEnumerator<string, object, AttributeEnumerationState>.ForEachDelegate ProcessLibraryResourcesRef = ProcessLibraryResources;
|
private static readonly DictionaryEnumerator<string, object, AttributeEnumerationState>.ForEachDelegate ProcessLibraryResourcesRef = ProcessLibraryResources;
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace OpenTelemetry.Adapter.AspNet.Tests
|
||||||
|
|
||||||
Assert.Equal(routeTemplate ?? HttpContext.Current.Request.Path, span.Name);
|
Assert.Equal(routeTemplate ?? HttpContext.Current.Request.Path, span.Name);
|
||||||
Assert.Equal(SpanKind.Server, span.Kind);
|
Assert.Equal(SpanKind.Server, span.Kind);
|
||||||
Assert.Equal(CanonicalCode.Ok, span.Status.CanonicalCode);
|
Assert.Equal(StatusCanonicalCode.Ok, span.Status.CanonicalCode);
|
||||||
Assert.Equal("OK", span.Status.Description);
|
Assert.Equal("OK", span.Status.Description);
|
||||||
|
|
||||||
var expectedUri = new Uri(url);
|
var expectedUri = new Uri(url);
|
||||||
|
|
|
||||||
|
|
@ -89,25 +89,25 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
|
||||||
Assert.Equal(tc.SpanName, span.Name);
|
Assert.Equal(tc.SpanName, span.Name);
|
||||||
Assert.Equal(tc.SpanKind, span.Kind.ToString());
|
Assert.Equal(tc.SpanKind, span.Kind.ToString());
|
||||||
|
|
||||||
var d = new Dictionary<CanonicalCode, string>()
|
var d = new Dictionary<StatusCanonicalCode, string>()
|
||||||
{
|
{
|
||||||
{ CanonicalCode.Ok, "OK"},
|
{ StatusCanonicalCode.Ok, "OK"},
|
||||||
{ CanonicalCode.Cancelled, "CANCELLED"},
|
{ StatusCanonicalCode.Cancelled, "CANCELLED"},
|
||||||
{ CanonicalCode.Unknown, "UNKNOWN"},
|
{ StatusCanonicalCode.Unknown, "UNKNOWN"},
|
||||||
{ CanonicalCode.InvalidArgument, "INVALID_ARGUMENT"},
|
{ StatusCanonicalCode.InvalidArgument, "INVALID_ARGUMENT"},
|
||||||
{ CanonicalCode.DeadlineExceeded, "DEADLINE_EXCEEDED"},
|
{ StatusCanonicalCode.DeadlineExceeded, "DEADLINE_EXCEEDED"},
|
||||||
{ CanonicalCode.NotFound, "NOT_FOUND"},
|
{ StatusCanonicalCode.NotFound, "NOT_FOUND"},
|
||||||
{ CanonicalCode.AlreadyExists, "ALREADY_EXISTS"},
|
{ StatusCanonicalCode.AlreadyExists, "ALREADY_EXISTS"},
|
||||||
{ CanonicalCode.PermissionDenied, "PERMISSION_DENIED"},
|
{ StatusCanonicalCode.PermissionDenied, "PERMISSION_DENIED"},
|
||||||
{ CanonicalCode.ResourceExhausted, "RESOURCE_EXHAUSTED"},
|
{ StatusCanonicalCode.ResourceExhausted, "RESOURCE_EXHAUSTED"},
|
||||||
{ CanonicalCode.FailedPrecondition, "FAILED_PRECONDITION"},
|
{ StatusCanonicalCode.FailedPrecondition, "FAILED_PRECONDITION"},
|
||||||
{ CanonicalCode.Aborted, "ABORTED"},
|
{ StatusCanonicalCode.Aborted, "ABORTED"},
|
||||||
{ CanonicalCode.OutOfRange, "OUT_OF_RANGE"},
|
{ StatusCanonicalCode.OutOfRange, "OUT_OF_RANGE"},
|
||||||
{ CanonicalCode.Unimplemented, "UNIMPLEMENTED"},
|
{ StatusCanonicalCode.Unimplemented, "UNIMPLEMENTED"},
|
||||||
{ CanonicalCode.Internal, "INTERNAL"},
|
{ StatusCanonicalCode.Internal, "INTERNAL"},
|
||||||
{ CanonicalCode.Unavailable, "UNAVAILABLE"},
|
{ StatusCanonicalCode.Unavailable, "UNAVAILABLE"},
|
||||||
{ CanonicalCode.DataLoss, "DATA_LOSS"},
|
{ StatusCanonicalCode.DataLoss, "DATA_LOSS"},
|
||||||
{ CanonicalCode.Unauthenticated, "UNAUTHENTICATED"},
|
{ StatusCanonicalCode.Unauthenticated, "UNAUTHENTICATED"},
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.Equal(tc.SpanStatus, d[span.Status.CanonicalCode]);
|
Assert.Equal(tc.SpanStatus, d[span.Status.CanonicalCode]);
|
||||||
|
|
|
||||||
|
|
@ -85,25 +85,25 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
|
||||||
Assert.Equal(tc.SpanName, span.Name);
|
Assert.Equal(tc.SpanName, span.Name);
|
||||||
Assert.Equal(tc.SpanKind, span.Kind.ToString());
|
Assert.Equal(tc.SpanKind, span.Kind.ToString());
|
||||||
|
|
||||||
var d = new Dictionary<CanonicalCode, string>()
|
var d = new Dictionary<StatusCanonicalCode, string>()
|
||||||
{
|
{
|
||||||
{ CanonicalCode.Ok, "OK"},
|
{ StatusCanonicalCode.Ok, "OK"},
|
||||||
{ CanonicalCode.Cancelled, "CANCELLED"},
|
{ StatusCanonicalCode.Cancelled, "CANCELLED"},
|
||||||
{ CanonicalCode.Unknown, "UNKNOWN"},
|
{ StatusCanonicalCode.Unknown, "UNKNOWN"},
|
||||||
{ CanonicalCode.InvalidArgument, "INVALID_ARGUMENT"},
|
{ StatusCanonicalCode.InvalidArgument, "INVALID_ARGUMENT"},
|
||||||
{ CanonicalCode.DeadlineExceeded, "DEADLINE_EXCEEDED"},
|
{ StatusCanonicalCode.DeadlineExceeded, "DEADLINE_EXCEEDED"},
|
||||||
{ CanonicalCode.NotFound, "NOT_FOUND"},
|
{ StatusCanonicalCode.NotFound, "NOT_FOUND"},
|
||||||
{ CanonicalCode.AlreadyExists, "ALREADY_EXISTS"},
|
{ StatusCanonicalCode.AlreadyExists, "ALREADY_EXISTS"},
|
||||||
{ CanonicalCode.PermissionDenied, "PERMISSION_DENIED"},
|
{ StatusCanonicalCode.PermissionDenied, "PERMISSION_DENIED"},
|
||||||
{ CanonicalCode.ResourceExhausted, "RESOURCE_EXHAUSTED"},
|
{ StatusCanonicalCode.ResourceExhausted, "RESOURCE_EXHAUSTED"},
|
||||||
{ CanonicalCode.FailedPrecondition, "FAILED_PRECONDITION"},
|
{ StatusCanonicalCode.FailedPrecondition, "FAILED_PRECONDITION"},
|
||||||
{ CanonicalCode.Aborted, "ABORTED"},
|
{ StatusCanonicalCode.Aborted, "ABORTED"},
|
||||||
{ CanonicalCode.OutOfRange, "OUT_OF_RANGE"},
|
{ StatusCanonicalCode.OutOfRange, "OUT_OF_RANGE"},
|
||||||
{ CanonicalCode.Unimplemented, "UNIMPLEMENTED"},
|
{ StatusCanonicalCode.Unimplemented, "UNIMPLEMENTED"},
|
||||||
{ CanonicalCode.Internal, "INTERNAL"},
|
{ StatusCanonicalCode.Internal, "INTERNAL"},
|
||||||
{ CanonicalCode.Unavailable, "UNAVAILABLE"},
|
{ StatusCanonicalCode.Unavailable, "UNAVAILABLE"},
|
||||||
{ CanonicalCode.DataLoss, "DATA_LOSS"},
|
{ StatusCanonicalCode.DataLoss, "DATA_LOSS"},
|
||||||
{ CanonicalCode.Unauthenticated, "UNAUTHENTICATED"},
|
{ StatusCanonicalCode.Unauthenticated, "UNAUTHENTICATED"},
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.Equal(tc.SpanStatus, d[span.Status.CanonicalCode]);
|
Assert.Equal(tc.SpanStatus, d[span.Status.CanonicalCode]);
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
|
||||||
|
|
||||||
Assert.Equal("master", span.Name);
|
Assert.Equal("master", span.Name);
|
||||||
Assert.Equal(SpanKind.Client, span.Kind);
|
Assert.Equal(SpanKind.Client, span.Kind);
|
||||||
Assert.Equal(CanonicalCode.Ok, span.Status.CanonicalCode);
|
Assert.Equal(StatusCanonicalCode.Ok, span.Status.CanonicalCode);
|
||||||
Assert.Null(span.Status.Description);
|
Assert.Null(span.Status.Description);
|
||||||
|
|
||||||
Assert.Equal("sql", span.Attributes.FirstOrDefault(i =>
|
Assert.Equal("sql", span.Attributes.FirstOrDefault(i =>
|
||||||
|
|
@ -206,7 +206,7 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
|
||||||
|
|
||||||
Assert.Equal("master", span.Name);
|
Assert.Equal("master", span.Name);
|
||||||
Assert.Equal(SpanKind.Client, span.Kind);
|
Assert.Equal(SpanKind.Client, span.Kind);
|
||||||
Assert.Equal(CanonicalCode.Unknown, span.Status.CanonicalCode);
|
Assert.Equal(StatusCanonicalCode.Unknown, span.Status.CanonicalCode);
|
||||||
Assert.Equal("Boom!", span.Status.Description);
|
Assert.Equal("Boom!", span.Status.Description);
|
||||||
|
|
||||||
Assert.Equal("sql", span.Attributes.FirstOrDefault(i =>
|
Assert.Equal("sql", span.Attributes.FirstOrDefault(i =>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Status_Ok()
|
public void Status_Ok()
|
||||||
{
|
{
|
||||||
Assert.Equal(CanonicalCode.Ok, Status.Ok.CanonicalCode);
|
Assert.Equal(StatusCanonicalCode.Ok, Status.Ok.CanonicalCode);
|
||||||
Assert.Null(Status.Ok.Description);
|
Assert.Null(Status.Ok.Description);
|
||||||
Assert.True(Status.Ok.IsOk);
|
Assert.True(Status.Ok.IsOk);
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ namespace OpenTelemetry.Trace.Test
|
||||||
public void CreateStatus_WithDescription()
|
public void CreateStatus_WithDescription()
|
||||||
{
|
{
|
||||||
var status = Status.Unknown.WithDescription("This is an error.");
|
var status = Status.Unknown.WithDescription("This is an error.");
|
||||||
Assert.Equal(CanonicalCode.Unknown, status.CanonicalCode);
|
Assert.Equal(StatusCanonicalCode.Unknown, status.CanonicalCode);
|
||||||
Assert.Equal("This is an error.", status.Description);
|
Assert.Equal("This is an error.", status.Description);
|
||||||
Assert.False(status.IsOk);
|
Assert.False(status.IsOk);
|
||||||
}
|
}
|
||||||
|
|
@ -39,8 +39,8 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Equality()
|
public void Equality()
|
||||||
{
|
{
|
||||||
var status1 = new Status(CanonicalCode.Ok);
|
var status1 = new Status(StatusCanonicalCode.Ok);
|
||||||
var status2 = new Status(CanonicalCode.Ok);
|
var status2 = new Status(StatusCanonicalCode.Ok);
|
||||||
|
|
||||||
Assert.Equal(status1, status2);
|
Assert.Equal(status1, status2);
|
||||||
Assert.True(status1 == status2);
|
Assert.True(status1 == status2);
|
||||||
|
|
@ -49,8 +49,8 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Equality_WithDescription()
|
public void Equality_WithDescription()
|
||||||
{
|
{
|
||||||
var status1 = new Status(CanonicalCode.Unknown, "error");
|
var status1 = new Status(StatusCanonicalCode.Unknown, "error");
|
||||||
var status2 = new Status(CanonicalCode.Unknown, "error");
|
var status2 = new Status(StatusCanonicalCode.Unknown, "error");
|
||||||
|
|
||||||
Assert.Equal(status1, status2);
|
Assert.Equal(status1, status2);
|
||||||
Assert.True(status1 == status2);
|
Assert.True(status1 == status2);
|
||||||
|
|
@ -60,8 +60,8 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Not_Equality()
|
public void Not_Equality()
|
||||||
{
|
{
|
||||||
var status1 = new Status(CanonicalCode.Ok);
|
var status1 = new Status(StatusCanonicalCode.Ok);
|
||||||
var status2 = new Status(CanonicalCode.Unknown);
|
var status2 = new Status(StatusCanonicalCode.Unknown);
|
||||||
|
|
||||||
Assert.NotEqual(status1, status2);
|
Assert.NotEqual(status1, status2);
|
||||||
Assert.True(status1 != status2);
|
Assert.True(status1 != status2);
|
||||||
|
|
@ -70,8 +70,8 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Not_Equality_WithDescription1()
|
public void Not_Equality_WithDescription1()
|
||||||
{
|
{
|
||||||
var status1 = new Status(CanonicalCode.Ok, "ok");
|
var status1 = new Status(StatusCanonicalCode.Ok, "ok");
|
||||||
var status2 = new Status(CanonicalCode.Unknown, "error");
|
var status2 = new Status(StatusCanonicalCode.Unknown, "error");
|
||||||
|
|
||||||
Assert.NotEqual(status1, status2);
|
Assert.NotEqual(status1, status2);
|
||||||
Assert.True(status1 != status2);
|
Assert.True(status1 != status2);
|
||||||
|
|
@ -81,8 +81,8 @@ namespace OpenTelemetry.Trace.Test
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Not_Equality_WithDescription2()
|
public void Not_Equality_WithDescription2()
|
||||||
{
|
{
|
||||||
var status1 = new Status(CanonicalCode.Ok);
|
var status1 = new Status(StatusCanonicalCode.Ok);
|
||||||
var status2 = new Status(CanonicalCode.Unknown, "error");
|
var status2 = new Status(StatusCanonicalCode.Unknown, "error");
|
||||||
|
|
||||||
Assert.NotEqual(status1, status2);
|
Assert.NotEqual(status1, status2);
|
||||||
Assert.True(status1 != status2);
|
Assert.True(status1 != status2);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace OpenTelemetry.Utils
|
||||||
{
|
{
|
||||||
internal static class CanonicalCodeExtensions
|
internal static class CanonicalCodeExtensions
|
||||||
{
|
{
|
||||||
public static Status ToStatus(this CanonicalCode code)
|
public static Status ToStatus(this StatusCanonicalCode code)
|
||||||
{
|
{
|
||||||
return new Status(code);
|
return new Status(code);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue