Skip to content

Heartbeat not working for WorkerService #1689

@danspam

Description

@danspam

The heartbeat relies on IHeartbeatPropertyManager being available on TelemetryModules.Instance.Modules, however this collection is empty when you add AI using services.AddApplicationInsightsTelemetryWorkerService().

You can make it work by adding, for example, var _ = TelemetryConfiguration.Active;, which initialises TelemetryConfigurationFactory adds the DiagnosticsTelemetryModule to the modules collection. However, TelemetryConfiguration.Active is obsolete and this does not seem like the correct thing to do. You would expect it to just work?

Repro Steps

  1. Add application insights to worker service using services.AddApplicationInsightsTelemetryWorkerService()
  2. Deploy service to VM
  3. Look for "HeartbeatState" in customMetrics

Actual Behavior

No HeartbeatState appears in customMetrics

Expected Behavior

HeartbeatState appear in customMeterics

Version Info

SDK Version : 2.12.1
.NET Version : Core 3.1
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio
OS : Windows
Hosting Info (IIS/Azure WebApps/ etc) : Windows VM Service

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions