Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consumer and consumer messaging icons to traces UI #2969

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Aspire.Dashboard/Components/Pages/TraceDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
<TemplateColumn Title="Name">
<div class="col-long-content" title="@context.GetTooltip()" @onclick="() => OnShowProperties(context)">
@{
var isServerKind = context.Span.Kind == OtlpSpanKind.Server;
var isServerOrConsumer = context.Span.Kind == OtlpSpanKind.Server || context.Span.Kind == OtlpSpanKind.Consumer;
// Indent the span name based on the depth of the span.
var marginLeft = (context.Depth - 1) * 15;

// We want to have consistent margin for both client and server spans.
string spanNameContainerStyle;
if (!isServerKind)
if (!isServerOrConsumer)
{
// Client span has 19px extra content:
// - 5px extra margin-left
Expand All @@ -73,7 +73,7 @@
}
else
{
// Server span has 19px extra content:
// Span with icon has 19px extra content:
// - 16px icon
// - 3px padding-left
spanNameContainerStyle = string.Empty;
Expand All @@ -88,12 +88,12 @@
}
</span>
<span class="span-name-container" style="@spanNameContainerStyle">
@if (isServerKind)
@if (isServerOrConsumer)
{
<FluentIcon Class="server-request-icon"
<FluentIcon Class="span-kind-icon"
Color="Color.Custom"
CustomColor="@ColorGenerator.Instance.GetColorHexByKey(GetResourceName(context.Span.Source))"
Icon="Icons.Filled.Size16.Server" />
Value="@GetSpanIcon(context.Span)" />
}

@if (context.IsError)
Expand Down
20 changes: 20 additions & 0 deletions src/Aspire.Dashboard/Components/Pages/TraceDetail.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ private ValueTask<GridItemsProviderResult<SpanWaterfallViewModel>> GetData(GridI
});
}

private static Icon GetSpanIcon(OtlpSpan span)
{
switch (span.Kind)
{
case OtlpSpanKind.Server:
return new Icons.Filled.Size16.Server();
case OtlpSpanKind.Consumer:
if (span.Attributes.HasKey("messaging.system"))
{
return new Icons.Filled.Size16.Mailbox();
}
else
{
return new Icons.Filled.Size16.ContentSettings();
}
default:
throw new InvalidOperationException($"Unsupported span kind when resolving icon: {span.Kind}");
}
}

private static List<SpanWaterfallViewModel> CreateSpanWaterfallViewModels(OtlpTrace trace, TraceDetailState state)
{
var orderedSpans = new List<SpanWaterfallViewModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
padding-left: 0.25rem;
}

::deep .server-request-icon {
::deep .span-kind-icon {
margin-right: 3px;
vertical-align: text-bottom;
}
Expand Down