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

RequestTelemetry missing in HttpContext.Features #2842

Open
mcgiany opened this issue Jan 24, 2024 · 2 comments
Open

RequestTelemetry missing in HttpContext.Features #2842

mcgiany opened this issue Jan 24, 2024 · 2 comments
Labels

Comments

@mcgiany
Copy link

mcgiany commented Jan 24, 2024

.NET 7
Nuget version 2.21.0
Windows

Hi, we are facing weird issue in our .NET7 ASP NET Project, that Features in HTTP Context doesnt contain RequestTelemetry.
HttpContext.Features.Get<RequestTelemetry>() returns NULL.

The problem is, we cannot reproduce it on developers machine, it happens only in our test machine. (Same build same code).
Is there anything, that could cause this behaviour? Like any IIS setting or evironment variable, etc.

I cannot add example project, because on local machine it works.

@mcgiany mcgiany added the bug label Jan 24, 2024
@CharlesSchimmel
Copy link

CharlesSchimmel commented Apr 29, 2024

I'm seeing this as well. Works when ran locally but not when deployed an Azure app service. .NET 8, ASP.NET API wherein I have a middleware that attempts to add values to the RequestTelemetry.

@CharlesSchimmel
Copy link

CharlesSchimmel commented May 3, 2024

My Azure App Service is using Application Insights autoinstrumentation extension (v2.8.45.1) with interop enabled (XDT_MicrosoftApplicationInsights_PreemptSdk=1), and I wonder if that is related. Perhaps when running locally, there's no autoinstrumented instance of AI running to pre-empt the SDK, so custom telemetry still works.

It's unclear to me what SDK interop actually does; the documentation says "Loads the extension side by side with the SDK and uses it to send telemetry. (Disables the Application Insights SDK.)" which to me is ambiguous if things like writing RequestTelemetry in middleware would still work.

Something else I've found is that if I enumerate and log out httpContext.Features.AsEnumerable() in the middleware, RequestTelemetry appears as a registered feature, but any attempt to retrieve it returns null.

Update: Setting XDT_MicrosoftApplicationInsights_PreemptSdk=0 seems to have resolved it.

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

2 participants