Azure Application Insights - Grouping Custom Events/Exceptions to a Request's End-to-End Transaction

CudoXY 26 Reputation points
2022-01-31T06:28:57.3+00:00

I am using Azure Application Insights for logging and tracking event flows for my Azure Function. I was wondering if there's a way to group Custom Events and manually-logged Exceptions (via TrackException()) in the end-to-end transaction details of a particular request in the Transaction Search.

I'm using the following sample code:

   using (var operation = telemetryClient.StartOperation<RequestTelemetry>("operationName"))  
   {  
       telemetryClient.TrackEvent("test event");  
       telemetryClient.TrackException(new Exception("test exception"));  
   }  

And getting the following logs (newest first):
169694-image.png

And the end-to-end transaction detail for the request looks like this (no child event nor exception)
169727-image.png

I would just like to confirm if there's a way to get something similar to this:
169695-image.png

Thanks in advance!

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

Answer accepted by question author
  1. AnuragSingh-MSFT 21,566 Reputation points Moderator
    2022-02-02T11:23:55.233+00:00

    Hi @CudoXY ,

    Welcome to Microsoft Q&A! Thanks for posting the question.

    There are certain limitations when calling the AppInsight's TelemetryClient from Azure Function App. For example, "You should not call TrackRequest or StartOperation<RequestTelemetry>, because you'll see duplicate requests for a function invocation. The Functions runtime automatically tracks requests."

    The details for using TelemetryClient and custom DependencyTelemetry is available at this link: Log custom telemetry in Azure Functions
    In this example, the DependencyTelemetry is used to record the success or failure of any operation.

    Also, for tracking the Exception, you can use the initialized telemetryClient object as given in this example as below:

    this.telemetryClient.TrackException(new Exception("test exception"));

    This code snippet when added after the this.telemetryClient.TrackDependency() call looks like below in End-to-end transaction details

    170557-image.png

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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