-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I have a simple initializer with defined ActivitySource.
When I call StartActivity I always get null despite source name is registered in WithTracing method:
builder.Services.AddOpenTelemetry()
.WithTracing(builder =>
{
builder
.AddAspNetCoreInstrumentation()
.AddEntityFrameworkCoreInstrumentation()
.AddSource(customSources); // <--- added in the list of `customSources`
In other types (hosted services) tracing works fine.
It looks like the issue is caused by how Otel library works:
public static OpenTelemetryBuilder AddOpenTelemetry(this IServiceCollection services)
{
Guard.ThrowIfNull(services);
if (!services.Any((ServiceDescriptor d) => d.ServiceType == typeof(IHostedService) && d.ImplementationType == typeof(TelemetryHostedService)))
{
services.Insert(0, ServiceDescriptor.Singleton<IHostedService, TelemetryHostedService>());
}
return new(services);
}
And the underlying issue seems to be the fact that host has no AfterInit event.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels