Skip to content

OpenTelemetrySdk not defined with TelemetryClient using DI when calling flushAsync #3115

@andrkn

Description

@andrkn
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="3.0.0" />
  • Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file):
  • Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.):

net10.0, windows

Describe the bug

In my WorkerService I have an issue when trying to use telemetryClient.Flush/FlushAsync when doing shutdown of the service. It crashes as private OpenTelemetrySdk sdk; is null within my TelemetryClient.
Exception from TelemetryClient: System.NullReferenceException: 'Object reference not set to an instance of an object.',

To Reproduce

Attached code should reproduce my issue with using TelemetryClient.FlushAsync

TestWorker.zip

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions