-
Notifications
You must be signed in to change notification settings - Fork 752
[release/9.3] Initialize telemetry context in UpdateTelemetryProperties if not already initialized #9602
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
Conversation
…ady initialized (#9553) Co-authored-by: James Newton-King <james@newtonking.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
|
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 |
|
@danmoseley yep, verified after pulling down branch |
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.