The standard dependency-tracking module automatically discovers external dependencies such as databases and REST APIs. But you might want some additional components to be treated in the same way. You can write code that sends dependency information, using the same TrackDependency API that is used by the standard modules.
Use the TrackDependency call to track the response times and success rates of calls to an external piece of code. The results appear in the dependency charts in the portal.
Snippet in C#
var success = false;
var startTime = DateTime.UtcNow;
var timer = System.Diagnostics.Stopwatch.StartNew();
try
{
success = dependency.Call();
}
finally
{
timer.Stop();
telemetry.TrackDependency("myDependency", "myCall", startTime, timer.Elapsed, success);
// With the Latest SDK follow the below format:
// TrackDependency (string dependencyTypeName, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success);
}
Documentation Reference
Hope this helps.