Skip to main content

.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 platforms#

Spy NameTypeLinuxmacOSWindowsDocker

Running .NET profiler#

  1. Download and from latest release

  2. Set the following required environment variables to enable profiler


Dynamic labels#

It is possible to add labels to the profiling data. These labels can be used to filter the data in the UI.

  1. Add dependency
dotnet add package Pyroscope
  1. 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();});


PYROSCOPE_PROFILING_LOG_DIRStringSets the directory for .NET Profiler logs. Defaults to /var/log/pyroscope/ .
PYROSCOPE_LABELSStringStatic 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_ENABLEDBooleanIf set to true, enables the .NET Profiler. Defaults to false.
PYROSCOPE_PROFILING_WALLTIME_ENABLEDBooleanIf set to false, disables the Wall time profiling. Defaults to true.
PYROSCOPE_PROFILING_CPU_ENABLEDBooleanIf set to false, disables the CPU profiling. Defaults to true.
PYROSCOPE_PROFILING_EXCEPTION_ENABLEDBooleanIf set to true, enables the Exceptions profiling (beta). Defaults to false.
PYROSCOPE_PROFILING_ALLOCATION_ENABLEDBooleanIf set to true, enables the Allocations profiling (beta). Defaults to false.
PYROSCOPE_PROFILING_LOCK_ENABLEDBooleanIf set to true, enables the Lock Contention profiling (beta). Defaults to false.