Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -159,8 +159,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

protected override void OnInitialized()
{
(_resizeLabels, _sortLabels) = DashboardUIHelpers.CreateGridLabels(ControlStringsLoc);
TelemetryContextProvider.Initialize(TelemetryContext);
(_resizeLabels, _sortLabels) = DashboardUIHelpers.CreateGridLabels(ControlStringsLoc);
}

private IEnumerable<ResourceDetailRelationshipViewModel> GetRelationships()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private sealed class ConsoleLogsSubscription

protected override async Task OnInitializedAsync()
{
TelemetryContextProvider.Initialize(TelemetryContext);
_resourceSubscriptionToken = _resourceSubscriptionCts.Token;
_logEntries = new(Options.Value.Frontend.MaxConsoleLogCount);
_noSelection = new() { Id = null, Name = ControlsStringsLoc[nameof(ControlsStrings.LabelNone)] };
Expand Down Expand Up @@ -172,8 +173,6 @@ protected override async Task OnInitializedAsync()
PageViewModel.Status = Loc[nameof(Dashboard.Resources.ConsoleLogs.ConsoleLogsLogsNotYetAvailable)];
}

TelemetryContextProvider.Initialize(TelemetryContext);

async Task TrackResourceSnapshotsAsync()
{
if (!DashboardClient.IsEnabled)
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/Error.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public partial class Error : IComponentWithTelemetry, IDisposable

protected override void OnInitialized()
{
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
TelemetryContextProvider.Initialize(TelemetryContext);
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}

[Inject]
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/Login.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public partial class Login : IAsyncDisposable, IComponentWithTelemetry

protected override async Task OnInitializedAsync()
{
TelemetryContextProvider.Initialize(TelemetryContext);

// Create EditContext before awaiting. This is required to prevent an await in OnInitializedAsync
// triggering parameters being set on EditForm before EditContext is created.
// If that happens then EditForm errors that it requires an EditContext.
Expand All @@ -60,8 +62,6 @@ protected override async Task OnInitializedAsync()
return;
}
}

TelemetryContextProvider.Initialize(TelemetryContext);
}

protected override async Task OnAfterRenderAsync(bool firstRender)
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public partial class Metrics : IDisposable, IComponentWithTelemetry, IPageWithSe

protected override void OnInitialized()
{
TelemetryContextProvider.Initialize(TelemetryContext);

_durations = new List<SelectViewModel<TimeSpan>>
{
new() { Name = Loc[nameof(Dashboard.Resources.Metrics.MetricsLastOneMinute)], Id = TimeSpan.FromMinutes(1) },
Expand Down Expand Up @@ -109,8 +111,6 @@ protected override void OnInitialized()
UpdateApplications();
StateHasChanged();
}));

TelemetryContextProvider.Initialize(TelemetryContext);
}

protected override async Task OnParametersSetAsync()
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/Resources.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ private async Task HandleSearchFilterChangedAsync()

protected override async Task OnInitializedAsync()
{
TelemetryContextProvider.Initialize(TelemetryContext);

Copilot AI May 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add a comment explaining why telemetry initialization is placed at the top of OnInitializedAsync, so future maintainers understand its importance before any awaits or parameter setup.

Copilot uses AI. Check for mistakes.
(_resizeLabels, _sortLabels) = DashboardUIHelpers.CreateGridLabels(ControlsStringsLoc);

_gridColumns = [
Expand Down Expand Up @@ -214,7 +215,6 @@ protected override async Task OnInitializedAsync()
}
});

TelemetryContextProvider.Initialize(TelemetryContext);
_isLoading = false;

async Task SubscribeResourcesAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private async ValueTask<GridItemsProviderResult<OtlpLogEntry>> GetData(GridItems

protected override void OnInitialized()
{
TelemetryContextProvider.Initialize(TelemetryContext);
(_resizeLabels, _sortLabels) = DashboardUIHelpers.CreateGridLabels(ControlsStringsLoc);

_gridColumns = [
Expand Down Expand Up @@ -203,8 +204,6 @@ protected override void OnInitialized()
UpdateApplications();
StateHasChanged();
}));

TelemetryContextProvider.Initialize(TelemetryContext);
}

protected override async Task OnParametersSetAsync()
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/TraceDetail.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public partial class TraceDetail : ComponentBase, IComponentWithTelemetry, IDisp

protected override void OnInitialized()
{
TelemetryContextProvider.Initialize(TelemetryContext);

_gridColumns = [
new GridColumn(Name: NameColumn, DesktopWidth: "4fr", MobileWidth: "4fr"),
new GridColumn(Name: TicksColumn, DesktopWidth: "12fr", MobileWidth: "12fr"),
Expand All @@ -81,8 +83,6 @@ protected override void OnInitialized()
await InvokeAsync(_dataGrid.SafeRefreshDataAsync);
}));
}

TelemetryContextProvider.Initialize(TelemetryContext);
}

// Internal to be used in unit tests
Expand Down
3 changes: 1 addition & 2 deletions src/Aspire.Dashboard/Components/Pages/Traces.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private async ValueTask<GridItemsProviderResult<OtlpTrace>> GetData(GridItemsPro

protected override void OnInitialized()
{
TelemetryContextProvider.Initialize(TelemetryContext);
(_resizeLabels, _sortLabels) = DashboardUIHelpers.CreateGridLabels(ControlsStringsLoc);

_gridColumns = [
Expand All @@ -168,8 +169,6 @@ protected override void OnInitialized()
UpdateApplications();
StateHasChanged();
}));

TelemetryContextProvider.Initialize(TelemetryContext);
}

protected override async Task OnParametersSetAsync()
Expand Down