Skip to content

Rename Application to Resource in dashboard OTLP functionality #10868

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract class ChartBase : ComponentBase, IAsyncDisposable
public required TimeSpan Duration { get; set; }

[Parameter]
public required List<OtlpApplication> Applications { get; set; }
public required List<OtlpResource> Resources { get; set; }

// Stores a cache of the last set of spans returned as exemplars.
// This dictionary is replaced each time the chart is updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else
Label="@Loc[nameof(ControlsStrings.ChartContainerGraphTab)]"
Icon="@(new Icons.Regular.Size24.DataArea())">
<div class="metrics-chart-container metric-tab">
<PlotlyChart InstrumentViewModel="_instrumentViewModel" Duration="Duration" Applications="Applications"/>
<PlotlyChart InstrumentViewModel="_instrumentViewModel" Duration="Duration" Resources="Resources"/>
<ChartFilters InstrumentViewModel="_instrumentViewModel" Instrument="_instrument" DimensionFilters="@DimensionFilters" />
</div>
</FluentTab>
Expand All @@ -47,7 +47,7 @@ else
Label="@Loc[nameof(ControlsStrings.ChartContainerTableTab)]"
Icon="@(new Icons.Regular.Size24.Table())">
<div class="metrics-chart-container metric-tab">
<MetricTable InstrumentViewModel="_instrumentViewModel" Duration="Duration" Applications="Applications" />
<MetricTable InstrumentViewModel="_instrumentViewModel" Duration="Duration" Resources="Resources" />
<ChartFilters InstrumentViewModel="_instrumentViewModel" Instrument="_instrument" DimensionFilters="@DimensionFilters"/>
</div>
</FluentTab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public partial class ChartContainer : ComponentBase, IAsyncDisposable
private readonly InstrumentViewModel _instrumentViewModel = new InstrumentViewModel();

[Parameter, EditorRequired]
public required ApplicationKey ApplicationKey { get; set; }
public required ResourceKey ResourceKey { get; set; }

[Parameter, EditorRequired]
public required string MeterName { get; set; }
Expand All @@ -41,7 +41,7 @@ public partial class ChartContainer : ComponentBase, IAsyncDisposable
public required Func<Pages.Metrics.MetricViewKind, Task> OnViewChangedAsync { get; set; }

[Parameter, EditorRequired]
public required List<OtlpApplication> Applications { get; set; }
public required List<OtlpResource> Resources { get; set; }

[Parameter, EditorRequired]
public required string? PauseText { get; set; }
Expand Down Expand Up @@ -190,7 +190,7 @@ protected override async Task OnParametersSetAsync()

var instrument = TelemetryRepository.GetInstrument(new GetInstrumentRequest
{
ApplicationKey = ApplicationKey,
ResourceKey = ResourceKey,
MeterName = MeterName,
InstrumentName = InstrumentName,
StartTime = startDate,
Expand All @@ -200,8 +200,8 @@ protected override async Task OnParametersSetAsync()
if (instrument == null)
{
Logger.LogDebug(
"Unable to find instrument. ApplicationKey: {ApplicationKey}, MeterName: {MeterName}, InstrumentName: {InstrumentName}",
ApplicationKey,
"Unable to find instrument. ResourceKey: {ResourceKey}, MeterName: {MeterName}, InstrumentName: {InstrumentName}",
ResourceKey,
MeterName,
InstrumentName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ private async Task OpenExemplarsDialogAsync(MetricViewBase metric)
var vm = new ExemplarsDialogViewModel
{
Exemplars = metric.Exemplars,
Applications = Applications,
Resources = Resources,
Instrument = InstrumentViewModel.Instrument!
};
var parameters = new DialogParameters
{
Title = DialogsLoc[nameof(Resources.Dialogs.ExemplarsDialogTitle)],
PrimaryAction = DialogsLoc[nameof(Resources.Dialogs.DialogCloseButtonText)],
DismissTitle = DialogsLoc[nameof(Resources.Dialogs.DialogCloseButtonText)],
Title = DialogsLoc[nameof(Dashboard.Resources.Dialogs.ExemplarsDialogTitle)],
PrimaryAction = DialogsLoc[nameof(Dashboard.Resources.Dialogs.DialogCloseButtonText)],
DismissTitle = DialogsLoc[nameof(Dashboard.Resources.Dialogs.DialogCloseButtonText)],
SecondaryAction = string.Empty,
Width = "800px",
Height = "auto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private PlotlyTrace CalculateExemplarsTrace(List<DateTimeOffset> xValues, List<C
string title;
if (exemplar.Span != null)
{
title = SpanWaterfallViewModel.GetTitle(exemplar.Span, Applications);
title = SpanWaterfallViewModel.GetTitle(exemplar.Span, Resources);
}
else if (!string.IsNullOrEmpty(exemplar.TraceId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class ClearSignalsButton : ComponentBase
public required SelectViewModel<ResourceTypeDetails> SelectedResource { get; set; }

[Parameter]
public required Func<ApplicationKey?, Task> HandleClearSignal { get; set; }
public required Func<ResourceKey?, Task> HandleClearSignal { get; set; }

private readonly List<MenuButtonItem> _clearMenuItems = new();

Expand All @@ -45,7 +45,7 @@ protected override void OnParametersSet()
{
Id = "clear-menu-resource",
Icon = s_clearSelectedResourceIcon,
OnClick = () => HandleClearSignal(SelectedResource.Id?.GetApplicationKey()),
OnClick = () => HandleClearSignal(SelectedResource.Id?.GetResourceKey()),
IsDisabled = SelectedResource.Id == null,
Text = SelectedResource.Id == null
? ControlsStringsLoc[nameof(ControlsStrings.ClearPendingSelectedResource)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public sealed partial class LogViewer
public bool NoWrapLogs { get; set; }

[Parameter]
public string? ApplicationName { get; set; }
public string? ResourceName { get; set; }

protected override void OnParametersSet()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class ResourceNameButtonValue
public required string HighlightText { get; set; }

[Parameter, EditorRequired]
public required OtlpApplication Resource { get; set; }
public required OtlpResource Resource { get; set; }

[Inject]
public required NavigationManager NavigationManager { get; init; }
Expand All @@ -36,7 +36,7 @@ protected override void OnParametersSet()

if (DashboardClient.IsEnabled)
{
_resource = DashboardClient.GetResource(Resource.ApplicationKey.ToString());
_resource = DashboardClient.GetResource(Resource.ResourceKey.ToString());
if (_resource != null)
{
_resourceIcon = ResourceIconHelpers.GetIconForResource(_resource, IconSize.Size16, IconVariant.Regular);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@key="@Resources?.Count()"
Id="@_selectId"
OptionValue="@(c => c!.Name)"
OptionDisabled="@(c => !CanSelectGrouping && c!.Id?.Type is Otlp.Model.OtlpApplicationType.ResourceGrouping)"
OptionDisabled="@(c => !CanSelectGrouping && c!.Id?.Type is Otlp.Model.OtlpResourceType.ResourceGrouping)"
@bind-SelectedOption="SelectedResource"
@bind-SelectedOption:after="SelectedResourceChangedCore"
ValueChanged="ValuedChanged"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
@inject IStringLocalizer<ControlsStrings> Loc

<FluentStack Orientation="Orientation.Horizontal" HorizontalGap="3">
@if (ViewModel.Id?.Type is OtlpApplicationType.ResourceGrouping)
@if (ViewModel.Id?.Type is OtlpResourceType.ResourceGrouping)
{
<FluentIcon Icon="Icons.Regular.Size20.AppsList"
Color="Color.Accent"
Style="vertical-align: text-bottom;"/>
<span>@ViewModel.Name (<span class="resource-select-application-label">@Loc[nameof(ControlsStrings.ApplicationLower)]</span>)</span>
<span>@ViewModel.Name (<span class="resource-select-resource-label">@Loc[nameof(ControlsStrings.ApplicationLower)]</span>)</span>
}
else if (ViewModel.Id?.Type is OtlpApplicationType.Instance)
else if (ViewModel.Id?.Type is OtlpResourceType.Instance)
{
<span style="padding-left: 20px;" aria-label="@string.Format(@Loc[nameof(ControlsStrings.ResourceDropdownReplicaAccessibleTitle)], ViewModel.Name, ViewModel.Id.ReplicaSetName)">@ViewModel.Name</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public partial class SignalsActionsDisplay
public required Action<bool> OnPausedChanged { get; set; }

[Parameter, EditorRequired]
public required Func<ApplicationKey?, Task> HandleClearSignal { get; set; }
public required Func<ResourceKey?, Task> HandleClearSignal { get; set; }

[Parameter, EditorRequired]
public required SelectViewModel<ResourceTypeDetails> SelectedResource { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Dashboard/Components/Controls/SpanDetails.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="span-details-layout">
<FluentToolbar Orientation="Orientation.Horizontal">
<div>
@((MarkupString)string.Format(ControlsStrings.SpanDetailsResource, ViewModel.Span.Source.Application.ApplicationName))
@((MarkupString)string.Format(ControlsStrings.SpanDetailsResource, ViewModel.Span.Source.Resource.ResourceName))
</div>
<FluentDivider Role="DividerRole.Presentation" Orientation="Orientation.Vertical" />
<div>
Expand Down Expand Up @@ -158,10 +158,10 @@
RenderFragment WriteSpanLink(SpanLinkViewModel context)
{
var content = context.Span != null
? SpanWaterfallViewModel.GetTitle(context.Span, ViewModel.Applications)
? SpanWaterfallViewModel.GetTitle(context.Span, ViewModel.Resources)
: $"{Loc[nameof(ControlsStrings.SpanDetailsSpanPrefix)]}: {OtlpHelpers.ToShortenedId(context.SpanId)}";
var color = context.Span != null
? ColorGenerator.Instance.GetColorHexByKey(OtlpApplication.GetResourceName(context.Span.Source, ViewModel.Applications))
? ColorGenerator.Instance.GetColorHexByKey(OtlpResource.GetResourceName(context.Span.Source, ViewModel.Resources))
: "transparent";

return @<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected override void OnParametersSet()
[KnownResourceFields.ServiceNameField] = new ComponentMetadata
{
Type = typeof(ResourceNameButtonValue),
Parameters = { ["Resource"] = _viewModel.Span.Source.Application }
Parameters = { ["Resource"] = _viewModel.Span.Source.Resource }
},
[KnownTraceFields.StatusField] = new ComponentMetadata
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="structured-log-details-layout">
<FluentToolbar Orientation="Orientation.Horizontal">
<div>
@((MarkupString)string.Format(ControlsStrings.StructuredLogsDetailsResource, ViewModel.LogEntry.ApplicationView.Application.ApplicationName))
@((MarkupString)string.Format(ControlsStrings.StructuredLogsDetailsResource, ViewModel.LogEntry.ResourceView.Resource.ResourceName))
</div>
<FluentDivider Role="DividerRole.Presentation" Orientation="Orientation.Vertical" />
<div title="@FormatHelpers.FormatTimeWithOptionalDate(TimeProvider, ViewModel.LogEntry.TimeStamp, MillisecondsDisplay.Full)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class StructuredLogDetails : IDisposable
_contextAttributes.Where(ApplyFilter).AsQueryable();

internal IQueryable<TelemetryPropertyViewModel> FilteredResourceItems =>
ViewModel.LogEntry.ApplicationView.AllProperties().Select(p => new TelemetryPropertyViewModel { Name = p.DisplayName, Key = p.Key, Value = p.Value })
ViewModel.LogEntry.ResourceView.AllProperties().Select(p => new TelemetryPropertyViewModel { Name = p.DisplayName, Key = p.Key, Value = p.Value })
.Where(ApplyFilter).AsQueryable();

private string _filter = "";
Expand Down Expand Up @@ -112,7 +112,7 @@ protected override void OnParametersSet()
[KnownResourceFields.ServiceNameField] = new ComponentMetadata
{
Type = typeof(ResourceNameButtonValue),
Parameters = { ["Resource"] = _viewModel.LogEntry.ApplicationView.Application }
Parameters = { ["Resource"] = _viewModel.LogEntry.ResourceView.Resource }
},
[KnownStructuredLogFields.LevelField] = new ComponentMetadata
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
TGridItem="ChartExemplar">
<ChildContent>
<TemplateColumn Title="@Loc[nameof(Dialogs.ExemplarsDialogTraceColumnHeader)]" TooltipText="@(context => GetTitle(context))" Tooltip="true">
<span style="padding-left:5px; border-left-width: 5px; border-left-style: solid; border-left-color: @(context.Span != null ? ColorGenerator.Instance.GetColorHexByKey(OtlpApplication.GetResourceName(context.Span.Source, Content.Applications)) : "transparent");">
<span style="padding-left:5px; border-left-width: 5px; border-left-style: solid; border-left-color: @(context.Span != null ? ColorGenerator.Instance.GetColorHexByKey(OtlpResource.GetResourceName(context.Span.Source, Content.Resources)) : "transparent");">
@GetTitle(context)
</span>
</TemplateColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task OnViewDetailsAsync(ChartExemplar exemplar)
private string GetTitle(ChartExemplar exemplar)
{
return (exemplar.Span != null)
? SpanWaterfallViewModel.GetTitle(exemplar.Span, Content.Applications)
? SpanWaterfallViewModel.GetTitle(exemplar.Span, Content.Resources)
: $"{Loc[nameof(Resources.Dialogs.ExemplarsDialogTrace)]}: {OtlpHelpers.ToShortenedId(exemplar.TraceId)}";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
ShowTimestamp="@_showTimestamp"
IsTimestampUtc="@_isTimestampUtc"
NoWrapLogs="@_noWrapLogs"
ApplicationName="@PageViewModel.SelectedResource?.Name"/>
ResourceName="@PageViewModel.SelectedResource?.Name"/>
</MainSection>
</AspirePageContentLayout>
</div>
28 changes: 14 additions & 14 deletions src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void SetSelectedResourceOption(ResourceViewModel resource)
private SelectViewModel<ResourceTypeDetails> GetSelectedOption()
{
Debug.Assert(_resources is not null);
return _resources.GetApplication(Logger, ResourceName, canSelectGrouping: false, fallback: _noSelection);
return _resources.GetResource(Logger, ResourceName, canSelectGrouping: false, fallback: _noSelection);
}

protected override async Task OnParametersSetAsync()
Expand Down Expand Up @@ -451,26 +451,26 @@ internal static ImmutableList<SelectViewModel<ResourceTypeDetails>> GetConsoleLo
.OrderBy(c => c.Value, ResourceViewModelNameComparer.Instance)
.GroupBy(r => r.Value.DisplayName, StringComparers.ResourceName))
{
string applicationName;
string resourceName;

if (grouping.Count() > 1)
{
applicationName = grouping.Key;
resourceName = grouping.Key;

builder.Add(new SelectViewModel<ResourceTypeDetails>
{
Id = ResourceTypeDetails.CreateApplicationGrouping(applicationName, true),
Name = applicationName
Id = ResourceTypeDetails.CreateResourceGrouping(resourceName, true),
Name = resourceName
});
}
else
{
applicationName = grouping.First().Value.DisplayName;
resourceName = grouping.First().Value.DisplayName;
}

foreach (var resource in grouping.Select(g => g.Value).OrderBy(r => r, ResourceViewModelNameComparer.Instance))
{
builder.Add(ToOption(resource, grouping.Count() > 1, applicationName));
builder.Add(ToOption(resource, grouping.Count() > 1, resourceName));
}
}

Expand All @@ -488,11 +488,11 @@ internal static ImmutableList<SelectViewModel<ResourceTypeDetails>> GetConsoleLo

return builder.ToImmutableList();

SelectViewModel<ResourceTypeDetails> ToOption(ResourceViewModel resource, bool isReplica, string applicationName)
SelectViewModel<ResourceTypeDetails> ToOption(ResourceViewModel resource, bool isReplica, string resourceName)
{
var id = isReplica
? ResourceTypeDetails.CreateReplicaInstance(resource.Name, applicationName)
: ResourceTypeDetails.CreateSingleton(resource.Name, applicationName);
? ResourceTypeDetails.CreateReplicaInstance(resource.Name, resourceName)
: ResourceTypeDetails.CreateSingleton(resource.Name, resourceName);

return new SelectViewModel<ResourceTypeDetails>
{
Expand Down Expand Up @@ -631,7 +631,7 @@ private void LoadLogs(ConsoleLogsSubscription newConsoleLogsSubscription)

if (PageViewModel.SelectedOption.Id is not null &&
_consoleLogFilters.FilterResourceLogsDates.TryGetValue(
PageViewModel.SelectedOption.Id.GetApplicationKey().ToString(),
PageViewModel.SelectedOption.Id.GetResourceKey().ToString(),
out var filterResourceLogsDate))
{
// There is a filter for this individual resource.
Expand Down Expand Up @@ -725,7 +725,7 @@ private async Task DownloadLogsAsync()
await JS.InvokeVoidAsync("downloadStreamAsFile", fileName, streamReference);
}

private async Task ClearConsoleLogs(ApplicationKey? key)
private async Task ClearConsoleLogs(ResourceKey? key)
{
var now = TimeProvider.GetUtcNow().UtcDateTime;
if (key is null)
Expand Down Expand Up @@ -808,8 +808,8 @@ public Task UpdateViewModelFromQueryAsync(ConsoleLogsViewModel viewModel)
}
else if (TryGetSingleResource() is { } r)
{
// If there is no app selected and there is only one application available, select it.
viewModel.SelectedOption = _resources.GetApplication(Logger, r.Name, canSelectGrouping: false, fallback: _noSelection);
// If there is no resource selected and there is only one resource available, select it.
viewModel.SelectedOption = _resources.GetResource(Logger, r.Name, canSelectGrouping: false, fallback: _noSelection);
viewModel.SelectedResource = r;
return this.AfterViewModelChangedAsync(_contentLayout, waitToApplyMobileChange: false);
}
Expand Down
Loading
Loading