Skip to content

Commit

Permalink
Trace detail page - customize peer icons based on span attributes (#1865
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JamesNK authored Jan 26, 2024
1 parent cc7f801 commit 2a25291
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Aspire.Dashboard/Components/Pages/TraceDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,22 @@
@if (context.HasUninstrumentedPeer)
{
<span class="uninstrumented-peer">
<FluentIcon Style="@($"fill: {ColorGenerator.Instance.GetColorHexByKey(context.UninstrumentedPeer)};")" Icon="Icons.Filled.Size16.ArrowCircleRight" Class="uninstrumented-peer-icon"/>
@{
Icon icon;
if (context.Span.Attributes.HasKey("db.system"))
{
icon = new Icons.Filled.Size16.Database();
}
else
{
// Everything else.
icon = new Icons.Filled.Size16.ArrowCircleRight();
}
}
<FluentIcon
Style="@($"fill: {ColorGenerator.Instance.GetColorHexByKey(context.UninstrumentedPeer)};")"
Value="icon"
Class="uninstrumented-peer-icon"/>
@context.UninstrumentedPeer
</span>
}
Expand Down
12 changes: 12 additions & 0 deletions src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ private static void CopyKeyValues(RepeatedField<KeyValue> attributes, KeyValuePa
return null;
}

public static bool HasKey(this KeyValuePair<string, string>[] values, string name)
{
for (var i = 0; i < values.Length; i++)
{
if (values[i].Key == name)
{
return true;
}
}
return false;
}

public static string ConcatProperties(this KeyValuePair<string, string>[] properties)
{
StringBuilder sb = new();
Expand Down

0 comments on commit 2a25291

Please sign in to comment.