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

Using TelemetryConfiguration and TelemetryClient in Azure Functions v2+ #7857

Closed
ForteUnited opened this issue Nov 12, 2021 · 2 comments
Closed

Comments

@ForteUnited
Copy link

ForteUnited commented Nov 12, 2021

Is your question related to a specific version? If so, please specify:

Azure Functions v2

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

.NET Core 3.1

Question

I would like to instrument my function using an Application Insights SDK and make calls to TrackRequest and TrackDependency as I see fit. Currently my example here would be track calls to CosmosDb since it appears that CosmosDb isn't an autotracked dependency in Functions even thought it is in App Service (Gateway Mode at least).
See here -> https://docs.microsoft.com/en-us/azure/azure-monitor/app/azure-functions-supported-features#supported-features

I am having trouble figuring out which NuGet to use and how to properly leverage the SDK. The documentation related to Application Insight + Azure Functions isn't super clear. I'm currently trying to follow this article (https://docs.microsoft.com/en-us/azure/azure-monitor/app/azure-functions-supported-features#sampling) which instructs me to inject an instance of TelemetryConfiguration into my Function class so as to ensure my TelemetryClient uses the same configuration as the Functions App itself otherwise I "may experience strange behavior if your sampling configuration is different than the Functions' sampling configuration".

The article doesn't explain which Nuget to use or how to configure dependency injection of the TelemetryConfiguration.

At this point, no matter what I do I end up with the following error:

Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type 'Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration' while attempting to activate 'FunctionApp.ExampleLoggingTimerFunction'.

Need assist

@ghost ghost assigned kashimiz Nov 12, 2021
@ForteUnited ForteUnited changed the title Using TelemtryConfiguration and TelemtryClient in Azure Functions v2+ Using TelemetryConfiguration and TelemetryClient in Azure Functions v2+ Nov 12, 2021
@v-bbalaiagar v-bbalaiagar self-assigned this Nov 15, 2021
@v-bbalaiagar
Copy link

Hi @ForteUnited, Thank you for your feedback! As mentioned in comment here #3741 (comment), setting the value to some dummy string (like "abc") will cause the TelemetryConfiguration to be registered.

Let us know if this helps.

@ghost
Copy link

ghost commented Nov 20, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost ghost closed this as completed Nov 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 23, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants