AppInsight Correlation
When we develop for Azure, normally there will be a lot of services interacting together to complete one meaningful business function. Business functions such as loading a web page or a queued operation may have a lot of dependencies which are expected to work together to get success. Often when we use traditional logging framework, they tend to log only till the boundary of a process. We may not be able to correlate with what is happening in the next process when troubleshooting. We can do that by adding some custom code but AppInsight brings it out of the box. Out of the box means the internal data structure supports it and most of the SDKs too support it. More details on end to end correlation can be found here in my previous post.
Dependency correlation
When we enable AppInsight, we want all the events happening inside correlated together. One major item is Dependency telemetry. If we use AppInsight SDK below 2.4, we don't get any out going http requests via HttpClient correlated. In the same time if we have used WebClient it get correlated as dependency.
Problem
The problem is that when the HttpClient calls are not logged as dependencies our troubleshooting may go wrong or take more time. One possible reason why AppInsight SDK is not able to hook into HttpClient class is that AppInsight below 2.4 version don't know the class HttpClient. HttpClient is relatively new to the .Net's list of API used to make http calls.
Ideally it is interesting to identify how the AppInsight SDK subscribe to the WebClient and HttpClient classes so that it gets notified when there are outbound requests. Something for new post.
Solution
Better solution is to upgrade AppInsight SDK to latest and use HttpClient which is recommended for modern async programming.. If AppInsight SDK change is difficult, change HttpClient usage to WebClient.
Happy Coding...
No comments:
Post a Comment