This folder contains the source code for the Datadog .NET APM Profiler. The .NET Profiler runs in your application process to collect managed threads call stacks related to wall time, CPU consumption, exceptions, lock contention and allocations. Read the following posts explaining implementation details:
- Architecture and interations with the .NET CLR
- CPU and walltime profiling
- Exception and lock contention
- Memory usage profiling
Configure the Datadog Agent for APM as described in our documentation. To install and enable the .NET Profiler follow the steps as described in our documentation.
You can develop the profiler on various environments.
- Visual Studio 2022
- Workloads
- Desktop development with C++
- .NET desktop development
- .NET Core cross-platform development
- Individual components
- .NET Framework 4.7 targeting pack
- C++ for Linux Development
- Windows 10 SDK (10.0.18362)
- Workloads
Open the solution dd-trace-dotnet\Datadog.Profiler.sln
and build the projects Datadog.Profiler.Native.Windows
(C++).
Go to the Tracer folder and use the NUKE build.cmd script
..\tracer\build.cmd BuildProfilerHome BuildNativeLoader
Note: build Release binaries by default; use --buildConfiguration Debug
for debug build
In the generation solution dd-trace-dotnet\Datadog.Profiler.sln
, look at the C# projects under the Demos folder for specific scenarios:
- Samples.BuggyBits: web app updated from Tess Ferrandez repository that implements anti-patterns suc has too many allocations/exceptions, memory leak or outgoing HTTP requests
- Samples.Computer01: contains simple scenarios for end to end tests in worse case situations
In both cases, the Program.cs
file contains the list of scenarios. When you want to debug a list of scenarios, OR the corresponding enumeration values and add it after "CommandLineArgs": --scenario
it in the Properties\LaunchSettings.json
file.
As a final step, enable the profiler you would like to debug by setting the corresponding DD_PROFILING_xxx_ENABLED=1
Note:
- the .pprof files are generated in the folder given by the
DD_INTERNAL_PROFILING_OUTPUT_DIR
environment variable - the log files are stored in the
C:\ProgramData\Datadog .NET Tracer\logs
folder
To build C# projects
To build C++ projects
- Clang >= 9.0 (recommended)
- CMake >= 3.14
- Libtool
- liblzma
- libssl-dev
- autoconf
- git
Go to the Tracer folder and use the NUKE build.cmd script
../tracer/build.sh BuildProfilerHome BuildNativeLoader
You could also use the following to Build C++ projects and run the unit tests
CXX=clang++ CC=clang cmake -S dd-trace-dotnet -B _build
cd _build
make -j
ctest
Note: the clang compiler often finds errors that are not detected by Visual Studio