-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix displaying status message in span details (#7075)
- Loading branch information
Showing
6 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Aspire.Dashboard.Otlp.Model; | ||
|
||
[DebuggerDisplay("Key = {Key}, Value = {Value}")] | ||
public class OtlpDisplayField | ||
{ | ||
public required string DisplayName { get; init; } | ||
public required object Key { get; init; } | ||
public required string Value{ get; init; } | ||
public required string Value { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/Aspire.Dashboard.Tests/TelemetryRepositoryTests/OtlpSpanTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Dashboard.Model.Otlp; | ||
using Aspire.Dashboard.Otlp.Model; | ||
using Aspire.Tests.Shared.Telemetry; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using Xunit; | ||
|
||
namespace Aspire.Dashboard.Tests.TelemetryRepositoryTests; | ||
|
||
public class OtlpSpanTests | ||
{ | ||
private static readonly DateTime s_testTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | ||
|
||
[Fact] | ||
public void AllProperties() | ||
{ | ||
// Arrange | ||
var context = new OtlpContext { Logger = NullLogger.Instance, Options = new() }; | ||
var app1 = new OtlpApplication("app1", "instance", context); | ||
var trace = new OtlpTrace(new byte[] { 1, 2, 3 }); | ||
var scope = new OtlpScope(TelemetryTestHelpers.CreateScope(), context); | ||
|
||
var span = TelemetryTestHelpers.CreateOtlpSpan(app1, trace, scope, spanId: "abc", parentSpanId: null, startDate: s_testTime, | ||
statusCode: OtlpSpanStatusCode.Ok, statusMessage: "Status message!", attributes: [new KeyValuePair<string, string>(KnownTraceFields.StatusMessageField, "value")]); | ||
|
||
// Act | ||
var properties = span.AllProperties(); | ||
|
||
// Assert | ||
Assert.Collection(properties, | ||
a => | ||
{ | ||
Assert.Equal("trace.spanid", a.Key); | ||
Assert.Equal("abc", a.Value); | ||
}, | ||
a => | ||
{ | ||
Assert.Equal("trace.name", a.Key); | ||
Assert.Equal("Test", a.Value); | ||
}, | ||
a => | ||
{ | ||
Assert.Equal("trace.kind", a.Key); | ||
Assert.Equal("Unspecified", a.Value); | ||
}, | ||
a => | ||
{ | ||
Assert.Equal("trace.status", a.Key); | ||
Assert.Equal("Ok", a.Value); | ||
}, | ||
a => | ||
{ | ||
Assert.Equal("trace.statusmessage", a.Key); | ||
Assert.Equal("Status message!", a.Value); | ||
}, | ||
a => | ||
{ | ||
Assert.Equal("unknown-trace.statusmessage", a.Key); | ||
Assert.Equal("value", a.Value); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters