Skip to content

Disabling Heartbeats #1681

@tommy-ly

Description

@tommy-ly

Currently trying to disable heartbeats in my ASP.NET Core 3.1 web application with the following code in my startup:

var aiOptions = new ApplicationInsightsServiceOptions
{
    EnableHeartbeat = false,
    EnableAppServicesHeartbeatTelemetryModule = false
};

serviceCollection.AddApplicationInsightsTelemetry(aiOptions);

var config = new TelemetryConfiguration(key);
var diagnosticsTelemetryModule = new DiagnosticsTelemetryModule();
diagnosticsTelemetryModule.IsHeartbeatEnabled = false;
diagnosticsTelemetryModule.Initialize(config);

From what I can tell after reading the documentation the top half of the code (adding application insights telemetry) should have been enough. This didn't work which lead to me google further into the issue which someone had suggested initializing the diagnostics module (although I'm not sure how that works since we aren't actually doing anything with the module after instantiation).

After doing this I now get this error message every time it tries to do the heartbeat in my traces :

AI (Internal): [Microsoft-ApplicationInsights-Core] [msg=Log Error];[msg=Heartbeat pulse being sent without valid instance of HeartbeatProvider as its state]

Is there some simple setting I've missed in my startup?

Version Info

SDK Version : 2.12.0
.NET Version : Core 3.1
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Manual
OS : Windows
Hosting Info (IIS/Azure WebApps/ etc) : IIS

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions