Skip to content
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

Issue while AddApplicationInsightsTelemetry along with KeyedInstances in IServiceCollection #2949

Open
mavsankar opened this issue Jan 21, 2025 · 1 comment
Labels

Comments

@mavsankar
Copy link

mavsankar commented Jan 21, 2025

  • List of NuGet packages and version that you are using: 2.22.0
  • Runtime version: net8.0
  • Hosting environment: Any

Describe the bug

When there are KeyedSingleton Registrations to IServiceCollection, the method AddApplicationInsightsTelemetry doesn't work if it is called after calling services.AddKeyedSingleton method.

More Info:

This is happening because here, the code is checking only for ImplementationType and ImplementationInstance.

Image

Instead, I think it should also check for KeyedImplementationType & KeyedImplementationInstance

To Reproduce

Simply run this web application to reproduce the issue. Please note the below two lines in the program.cs

Image

https://github.com/mavsankar/AppInsightsSdk-KeyedInstance-Repro

Workaround

Always use the AddApplicationInsightsTelemetry method before registering any keyed instances

We will close this issue if:

  • The repro project you share with us is complex. We can't investigate custom projects, so don't point us to such, please.
  • If we will not be able to repro the behavior you're reporting

For Immediate Support

For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository.
You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API

@mavsankar mavsankar added the bug label Jan 21, 2025
@mavsankar
Copy link
Author

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant