Created
May 14, 2021 13:58
-
-
Save dasiths/2c4962dd2abab57dc6652ad7cb1b157d to your computer and use it in GitHub Desktop.
Tracing + Telemetry using .NET and Application Insights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reading | |
// https://tsuyoshiushio.medium.com/correlation-with-activity-with-application-insights-1-overview-753a48a645fb | |
// https://tsuyoshiushio.medium.com/correlation-with-activity-with-application-insights-2-activity-deep-dive-2a4147919659 | |
// https://medium.com/prospa-engineering/implementing-distributed-tracing-with-azures-application-insights-5a09cc1c200c | |
var activity = new Activity("Call to CosmosDB"); | |
// activity.SetParentId("correlation id from request") | |
//RequestTelemetry for Request, DependencyTelemtry for Dependencies | |
using var operation = telemetryClient.StartOperation<DependencyTelemetry>(activity); | |
Try { | |
// call cosmos db | |
} Catch (Exception e) { | |
operation.Telemetry.Success = false; | |
telemetryClient.TrackException(e); | |
} | |
Finally { | |
telemetryClient.StopOperation(operation); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment