.NET beta
This is a documentation for a new beta version of our new dotnet integration. It is based on dd-trace-dotnet.
The new features are:
- support for memory profiling
- support for wall (wall-clock) time profiling
- support for exceptions profiling
- support for dynamic tags
#
Supported .NET versions:- .NET 6.0
#
Supported platformsSpy Name | Type | Linux | macOS | Windows | Docker |
---|---|---|---|---|---|
dotnetspy | embedded | โ |
#
Running .NET profiler- Linux
Download
Pyroscope.Profiler.Native.so
andPyroscope.Linux.ApiWrapper.x64.so
from latest releaseSet the following required environment variables to enable profiler
PYROSCOPE_APPLICATION_NAME=rideshare.dotnet.appPYROSCOPE_SERVER_ADDRESS=http://localhost:4040PYROSCOPE_AUTH_TOKEN="psx-..." # optional auth tokenPYROSCOPE_PROFILING_ENABLED=1CORECLR_ENABLE_PROFILING=1CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A}CORECLR_PROFILER_PATH=Pyroscope.Profiler.Native.soLD_PRELOAD=Pyroscope.Linux.ApiWrapper.x64.so
#
Dynamic labelsIt is possible to add labels to the profiling data. These labels can be used to filter the data in the UI.
- Add dependency
dotnet add package Pyroscope
- Create a LabelSet and wrap a piece of code with Pyroscope.LabelsWrapper
var labels = Pyroscope.LabelSet.Empty.BuildUpon() .Add("key1", "value1") .Build();Pyroscope.LabelsWrapper.Do(labels, () =>{ SlowCode();});
Labels can be nested. For nesting LabelSets use LabelSet.BuildUpon
on non-empty set.
var labels = Pyroscope.LabelSet.Empty.BuildUpon() .Add("key1", "value1") .Build();Pyroscope.LabelsWrapper.Do(labels, () =>{ var labels2 = labels.BuildUpon() .Add("key2", "value2") .Build(); Pyroscope.LabelsWrapper.Do(labels2, () => { SlowCode(); }); FastCode();});
#
ConfigurationENVIRONMENT VARIABLE | Type | DESCRIPTION |
---|---|---|
PYROSCOPE_PROFILING_LOG_DIR | String | Sets the directory for .NET Profiler logs. Defaults to /var/log/pyroscope/ . |
PYROSCOPE_LABELS | String | Static labels to apply to an uploaded profile. Must be a list of key:value separated by commas such as: layer:api,team:intake. |
PYROSCOPE_PROFILING_ENABLED | Boolean | If set to true, enables the .NET Profiler. Defaults to false. |
PYROSCOPE_PROFILING_WALLTIME_ENABLED | Boolean | If set to false, disables the Wall time profiling. Defaults to true. |
PYROSCOPE_PROFILING_CPU_ENABLED | Boolean | If set to false, disables the CPU profiling. Defaults to true. |
PYROSCOPE_PROFILING_EXCEPTION_ENABLED | Boolean | If set to true, enables the Exceptions profiling (beta). Defaults to false. |
PYROSCOPE_PROFILING_ALLOCATION_ENABLED | Boolean | If set to true, enables the Allocations profiling (beta). Defaults to false. |
PYROSCOPE_PROFILING_LOCK_ENABLED | Boolean | If set to true, enables the Lock Contention profiling (beta). Defaults to false. |