[release/9.3] Initialize telemetry context in UpdateTelemetryProperties if not already initialized#9602
Merged
danmoseley merged 1 commit intorelease/9.3from Jun 2, 2025
Merged
Conversation
…ady initialized (#9553) Co-authored-by: James Newton-King <james@newtonking.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the telemetry context by ensuring properties are only posted when initialized and by adding logging support. It also cleans up duplicate initialization calls and pins markdownlint to prevent unexpected new rules.
- Extend
UpdateTelemetryPropertiesandPostPropertiesto accept anILoggerand guard against uninitialized telemetry service - Update tests to pass a logger instance into telemetry property updates
- Inject
ILoggerinto components and remove redundantTelemetryContextProvider.Initializecalls
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Dashboard/Components/Pages/ComponentTelemetryContext.cs | Added ILogger parameter to UpdateTelemetryProperties and a null check in PostProperties |
| tests/Aspire.Dashboard.Tests/Telemetry/ComponentTelemetryContextTests.cs | Updated tests to declare and pass a NullLogger instance |
| src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor.cs | Added TelemetryContextProvider.Initialize, updated telemetry calls to include Logger |
| src/Aspire.Dashboard/Components/Pages/Resources.razor.cs | Injected ILogger<Resources> and updated telemetry calls |
| src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs | Added TelemetryContextProvider.Initialize, updated telemetry calls to include Logger |
| src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs | Added TelemetryContextProvider.Initialize, updated telemetry calls to include Logger |
| src/Aspire.Dashboard/Components/Pages/Error.razor.cs | Injected ILogger<Error>, reordered RequestId assignment, updated telemetry calls |
| src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor.cs | Injected ILogger<ResourceDetails>, updated telemetry calls |
| src/Aspire.Dashboard/Components/Pages/Traces.razor.cs | Moved and de-duplicated TelemetryContextProvider.Initialize |
| src/Aspire.Dashboard/Components/Pages/TraceDetail.razor.cs | Moved and de-duplicated TelemetryContextProvider.Initialize |
| src/Aspire.Dashboard/Components/Pages/Login.razor.cs | Moved and de-duplicated TelemetryContextProvider.Initialize |
Comments suppressed due to low confidence (3)
src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor.cs:149
- The component calls
UpdateTelemetryProperties(..., Logger)but does not inject aLogger. Add an[Inject] public required ILogger<StructuredLogs> Logger { get; init; }property to this component.
protected override void OnInitialized()
src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:78
- The component calls
UpdateTelemetryProperties(..., Logger)but does not inject aLogger. Add an[Inject] public required ILogger<Metrics> Logger { get; init; }property to this component.
protected override void OnInitialized()
src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs:128
- The component calls
UpdateTelemetryProperties(..., Logger)but does not inject aLogger. Add an[Inject] public required ILogger<ConsoleLogs> Logger { get; init; }property to this component.
protected override async Task OnInitializedAsync()
Member
|
there was a merge conflict resolved to put this in 9.3 -- have you or @adamint verified the fix functions in its 9.3 form? if so, good to go |
adamint
approved these changes
Jun 2, 2025
Member
|
@danmoseley yep, verified after pulling down branch |
danmoseley
approved these changes
Jun 2, 2025
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Customer Impact
Race between initializing telemetry for a component can cause a dashboard error: #9559
The fixes in the PR:
OnInitializedAsync. This means it will always been initialized when parameters are updated.Testing
Manual
Risk
Low
Regression?
Telemetry is new in 9.3. But it causes errors on existing pages that previously worked.