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

Code issue on article about OpenTelemetry and Application Insights #42467

Open
drilko opened this issue Sep 4, 2024 · 0 comments · May be fixed by #42468
Open

Code issue on article about OpenTelemetry and Application Insights #42467

drilko opened this issue Sep 4, 2024 · 0 comments · May be fixed by #42468
Labels
dotnet-fundamentals/svc in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 ⌚ Not Triaged Not triaged

Comments

@drilko
Copy link

drilko commented Sep 4, 2024

Type of issue

Code doesn't work

Description

There is a small issue in the article which prevents the sample code from working.
In step two the following code is added:

if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
{
    otel.UseAzureMonitor();
}

In step three it's recommended to add the following json to appsettings.json:

"AzureMonitor": {
    "ConnectionString": "InstrumentationKey=12345678-abcd-abcd-abcd-12345678..."
}

Because of this otel.UseAzureMonitor(); is never called.
An easy fix would be to update code in step 2 as so:

if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"] ?? builder.Configuration["AzureMonitor:ConnectionString"]))
{
    otel.UseAzureMonitor();
}

or something similar.

Thank you!

Page URL

https://learn.microsoft.com/en-us/dotnet/core/diagnostics/observability-applicationinsights

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/diagnostics/observability-applicationinsights.md

Document Version Independent Id

e14803f7-d5c7-657a-763c-680cf4197365

Article author

@tommcdon

Metadata

  • ID: 45cce027-ad78-e3d1-7144-6091a9b5f023
  • Service: dotnet-fundamentals
@issues-automation issues-automation bot added dotnet-fundamentals/svc Pri1 High priority, do before Pri2 and Pri3 labels Sep 4, 2024
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged labels Sep 4, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fundamentals/svc in-pr This issue will be closed (fixed) by an active pull request. Pri1 High priority, do before Pri2 and Pri3 ⌚ Not Triaged Not triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants