Azure / Azure/azure-functions-host
.Net8 in-proc hosts creates an Activity without a source name
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
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: https://github.com/Azure/azure-functions-dotnet-worker/issues/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()
.AddSource("ServiceName")
.AddOtlpExporter();
});
```
3. Add a breakpoint after function dispatch, add watch on `Activty.Current` => should be null
4. Repeat above steps with net8. Should see something similar to the below

#### 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.
Contributor guide
Assessment
This issue has not been assessed yet.