How to Monitor Performance of Message Consumer Applications

sohlae 90 Reputation points
2024-12-19T12:23:05.6566667+00:00

I have developed a background service in .NET 8.0 which is responsible for receiving messages from an Azure Service Bus queue. The Program.cs has Application Insights configured as you can see in the code snippet below.

Is it possible to see in Application Insights the average response time of my background service? In the Performance section I can only see response times from API calls.

services.AddApplicationInsightsTelemetryWorkerService(new ApplicationInsightsServiceOptions

{

ConnectionString = "InstrumentationKey=...",

EnableAdaptiveSampling = false

});

Any guidance will be much appreciated!

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,402 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,025 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pranay Reddy Madireddy 1,310 Reputation points Microsoft Vendor
    2024-12-20T21:42:46.99+00:00

    Hi sohlae

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    Use the Application Insights SDK for Worker Services. This SDK is meant for background services and automatically tracks message processing data.

    When you use the ServiceBusProcessor to handle messages, Application Insights automatically records the processing times. This means you'll see performance metrics for those messages in Application Insights.

    In the Azure Portal, open your Application Insights resource and look at the Metrics section. You can create custom charts with the tracked metrics, like MessageProcessingTime, to see average response times and other performance indicators.

    The Performance section mainly shows HTTP request metrics. But by tracking custom metrics, you can also monitor your background service's performance along with API calls

    For reference, please review this documentation :-
    https://docs.azure.cn/en-us/batch/monitor-application-insights
    https://github.com/uglide/azure-content/blob/master/articles/application-insights/app-insights-windows-services.md

    If you have any further queries, do let us know.


    If the answer is helpful, please click "Accept Answer" and "Upvote it".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.