This post comes to us from Premier Developer consultant Nasir Syed.
“Insert a few lines of code in your application to find out what users are doing with it, or to help diagnose issues. You can send telemetry from device and desktop apps, web clients, and web servers. Use the Azure Application Insights core telemetry API to send custom events and metrics, and your own versions of standard telemetry. This API is the same API that the standard Application Insights data collectors use” …… Copied from here.
The above statement is very true and my experience of using Application Insights for custom events has been great. It is extremely powerful and easy to use. The challenge comes when you have to instrument a large number of classes and methods throughout your code to enable telemetry collection. Although the SDK provides some great out-of-the-box functionality for tracking page load time, external dependencies (database/web service) and code exceptions just by including the SDK, there are lots of scenarios where you must add code and use custom events.
I worked on a simple pattern that can simplify this to some degree by using Custom Attributes, a functionality that exists in .NET. I will illustrate my work here which is a very simple implementation of a Custom Attribute, that can be applied to any class or method in your solution, simply by scaffolding your class or method.
Read the rest on Nasir’s blog here.