Application Insights ‘handledAt’ field in exception

Mahesh Gupta 1 Reputation point Microsoft Employee
2020-07-21T20:39:13.987+00:00

I am looking at ‘handledAt’ field in exception telemetry.

https://zcusa.951200.xyz/en-us/dotnet/api/microsoft.applicationinsights.datacontracts.exceptionhandledat?view=azure-dotnet

The documentation says its obsolete but use custom properties to report exception handling. Is this filed still used and is there any other default field or alternative way to find that exceptions are handled. Also, till which version, 'handledAt, was supported.

If you have any information and provide, it will be of immense help.

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,285 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Krish G 2,331 Reputation points
    2020-07-22T08:10:51.277+00:00

    Hello @Mahesh Gupta ,

    The property HandledAt still works but it is deprecated, so I would not suggest you to use that anymore. If you set that property, the resulting exception in app insights would have a custom dimension like below:
    13361-image.png

    You can achieve the same by setting properties of the exception telemetry in code in either of the overloads of TrackException method of TelemetryClient:

    1. Setting properties of exception telemetry:
                   var telemetry = new ExceptionTelemetry(exception);  
                   telemetry.Properties["handledAt"] = "UserCode"; // or any string  
                   telemetryClient.TrackException(telemetry);  
      

    Or 2. The second overload of TrackException accepts properties as a param:

                    var properties = new Dictionary<string, string>();  
                    properties["handledAt"] = "UserCode"; // or any string  
                    telemetryClient.TrackException(exception, properties, metrics);                      
    

    Note Custom dimension is a very helpful way to set free form properties of telemetry from code. So, you can set whatever you want. The above handledAt is just to solve your problem.

    I am not too sure about the version in which handledAt got deprecated, it was way back in 2017-ish.

    0 comments No comments

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.