.NET Continuous Profiler: Exception and lock contention | Datadog
Apr 4, 2024Christophe Nasarre

Summary
This post details the implementation of exception and lock contention profiling within Datadog's .NET continuous profiler. For exceptions, it describes fetching details like type, message, and location using `ICorProfilerCallback::ExceptionThrown` and `ICorProfilerInfo::GetClassFromObject`. For lock contention, it explains how CLR events like `ContentionStart` and `ContentionStop` are captured, and how duration is computed, including recent contributions to the .NET runtime for richer `ContentionStart` event data. It also outlines strategies for older .NET versions using EventPipe and ETW.
More from the Java CPU Profiling trail
- How we built an async-aware Python profiler | Datadog
- Unbiased Java CPU profiling with JFR in JDK 25 | Datadog
- From hand-tuned Go to self-optimizing code: Building BitsEvolve | Datadog
- How we tracked down a Go 1.24 memory regression across hundreds of pods | Datadog
- .NET Continuous Profiler: CPU and wall time profiling | Datadog