Trying to add heartbeat for my console application.

Kundan Pitroda 1 Reputation point
2022-02-10T13:25:09.527+00:00

A discussion on github mentions that heartbeat is automatically sent when Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule& is added to the applicationinsights.config file. I want to create an alert in case the app hangs or crashes. Where can I track the heart beat on the AI instance? Also, currently its not sending anything . I am using .net framework 4.7.2. Am I configuring it wrong? I am not able to track the heartbeat on application insights instance. Where can I track it? Can someone provide a snippet for config file?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,798 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Monalla-MSFT 11,551 Reputation points
    2022-02-15T03:32:40.667+00:00

    @Kundan Pitroda - Welcome to Microsoft Q&A and thanks for reaching out.

    By looking at it, it looks like at this moment, there is an issue involving this telemetry module.

    And I also see that one of our engineers have already responded to you in other forum, resurfacing it here for broader audience.

    Here is a temporary workaround for WorkerServices that will help you.

    • Add application insights to worker service using

    services.AddApplicationInsightsTelemetryWorkerService().

    • Not only this DiagnosticsTelemetryModule adding to DI and also we need to configure it's heartbeat interval/module using the below code: services.TryAddSingleton<ITelemetryModule, DiagnosticsTelemetryModule>();
      services.ConfigureTelemetryModule<DiagnosticsTelemetryModule>((mod,opt) => mod.HeartbeatInterval = TimeSpan.FromSeconds(30));
      services.AddApplicationInsightsTelemetryWorkerService();
    • The TelemetryConfiguration.Active is not recommended because Worker service is new SDK, its not touching active or any other static singletons.

    For tracking purposed, after Deploying, Look for "HeartbeatState" in customMetrics.

    Note:

    Disabling DiagnosticsTelemetryModule will cause the following settings to be ignored:

    1. EnableHeartbeat,
    2. EnableAzureInstanceMetadataTelemetryModule,
    3. EnableAppServicesHeartbeatTelemetryModule.
    4. Enable Azure Monitor from the Portal.

    Please take a look at the below docs for more reference:
    worker-service
    Enabling Heartbeat in App Services

    Hope this helps.

    ------------------------------------------------------------------

    If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community.

    0 comments No comments