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

.Net8 in-proc hosts creates an Activity without a source name #10571

Closed
JessicaA-Auror opened this issue Oct 24, 2024 · 3 comments
Closed

.Net8 in-proc hosts creates an Activity without a source name #10571

JessicaA-Auror opened this issue Oct 24, 2024 · 3 comments

Comments

@JessicaA-Auror
Copy link

When upgrading an http triggered in-proc function to net8, the host runtime is now creating a new Activity without a Source Name. This is a change in behaviour that breaks telemetry. This changes otel by adding a new parent activity. Additionally the activity cannot be subscribe to due to not having a source name. When exporting otel, this looks like an empty root span.

A similar issue looks to have be recently fixed in isolated function see here: Azure/azure-functions-dotnet-worker#2733

Repro steps

  1. Create a new HTTP Trigger function (in-proc) running on net6

  2. Add OpenTelemetry configuration

  builder.Services.AddOpenTelemetry().WithTracing(tracerProviderBuilder =>
          {
              tracerProviderBuilder
                  .SetResourceBuilder(appResourceBuilder)
                  .SetSampler<AlwaysOnSampler>()
                  .AddSource("ServiceName")
                  .AddOtlpExporter();
          });
  1. Add a breakpoint after function dispatch, add watch on Activty.Current => should be null

  2. Repeat above steps with net8. Should see something similar to the below

Image

Expected Behaviour

Expected behaviour is not having the host create a current activity. If host is required to create activities then a source name is required to be able to subscribe to it. This results in missing spans in our otel telemetry after export.

Known workarounds

We've temporarily patched this by setting Activty.Current to null before starting a root activity.

@bhagyshricompany
Copy link

Hi @JessicaA-Auror thanks for update this is occurring exactly on which net 6 or net 6. will check and update.Thanks

@jviau
Copy link
Contributor

jviau commented Oct 30, 2024

@JessicaA-Auror I don't think this is functions specific. I believe this is a BCL change between .net6 and .net8. You are specifically seeing an operation from AspNetCore. Have you tried using OTels AspNetCore instrumentation package? I believe they do some work to shim this: https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore

@jviau jviau added the external label Oct 30, 2024
@jviau jviau assigned jviau and unassigned bhagyshricompany Oct 30, 2024
Copy link
Contributor

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.

If you are not the original author (JessicaA-Auror) and believe this issue is not stale, please comment with /bot not-stale and I will not close it.

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

No branches or pull requests

3 participants