Fix issue where AppInsights SDK doesn't load/configure correctly due to keyed services being registered in DI#594
Merged
Conversation
|
Contributor
Author
|
We can probably also just register AppInsights earlier in the DI container, since the issue is provoked when AppInsights scans the registry.. https://github.com/microsoft/ApplicationInsights-dotnet/blob/4626e3632323b741a2bd56d3d529c283cf7626c9/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs#L297 |
HauklandJ
approved these changes
Apr 16, 2024
5 tasks
ivarne
added a commit
that referenced
this pull request
Mar 28, 2025
Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from #594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder.
ivarne
added a commit
that referenced
this pull request
Mar 30, 2025
Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from #594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder.
ivarne
added a commit
that referenced
this pull request
Mar 30, 2025
* Update nuget depencencies Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from #594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder. * Revert to Altinn.Platform.Storage.Interface v 4.0.6
ivarne
added a commit
that referenced
this pull request
Mar 30, 2025
* Update nuget depencencies Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from #594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder.
ivarne
added a commit
that referenced
this pull request
Apr 4, 2025
* Update nuget depencencies Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from #594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder.
olamathiesenBlueTree
pushed a commit
to olamathiesenBlueTree/fork-altinn-app-lib-dotnet
that referenced
this pull request
Apr 8, 2025
* Update nuget depencencies Notable changes * Changed from Microsoft.CodeAnalysis.Workspaces to Microsoft.CodeAnalysis.CSharp, in Inernal.Analyzers because of a compiller warning see: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md * Updated SDK reference in global.json * Updated Applicationinsights package and removed the test from Altinn#594 * Updated to released version of HybridCache and remove #pragma waring disable for preview * Used [CallerFilePath] intead of assemly location to find test data folder. * Revert to Altinn.Platform.Storage.Interface v 4.0.6
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
A bug report came in, where logs/telemetry wasn't being shipped to AppInsights.
Upon inspecting the
IServiceCollectionregistrations after callingAddApplicationInsightsTelemetry, we discovered that everything until (and including) these lines of registrations succeeded:https://github.com/microsoft/ApplicationInsights-dotnet/blob/4626e3632323b741a2bd56d3d529c283cf7626c9/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs#L134
However the
TelemetryClientitself was never registered in DI. In the code linked above, if there is an exception, it is (relatively silently) swallowed and registered on the event source for AppInsights.We traced the event source in a local test app:
dotnet trace collect --providers Microsoft-ApplicationInsights-AspNetCore -- ./bin/Debug/net8.0/Altinn.AppWhich could be loaded into PerfView
We see this error:
Which means that AppInsights thinks that our DI container (Scrutor) doesn't support keyed services. I think that's right? Since there is an open issue on that: khellang/Scrutor#209
This PR replaces keyed services by just injecting multiple services, and introducing a second marker interface to distinguish between them instead.
Other options:
Related Issue(s)
Verification
Documentation