.NET

.NET is a free, cross-platform, open source developer platform for building many different types of applications.

Pyroscope Agent uses Diagnostic IPC Protocol client to communicate to .NET runtime and gather trace events. It is important to note that only managed code is accounted. Refer to dotnetdiag package for implementation details.

Supported .NET versions:

  • .NET 5.0
  • .NET Core 3.1

Supported platforms

Spy NameTypeLinuxmacOSWindowsDocker
dotnetspyembedded

Running .NET profiler

Interactively

To start profiling a .NET application, add pyroscope exec before the command. Run in PowerShell:

$env:PYROSCOPE_SPY_NAME="dotnetspy";
$env:PYROSCOPE_APPLICATION_NAME="my.dotnet.app";
$env:PYROSCOPE_SERVER_ADDRESS="http://pyroscope-server:4040";
pyroscope exec dotnet myapp.dll

Or, if your application is an executable file:

pyroscope exec myapp.exe "arg1" "arg2"

You can also attach pyroscope to already running process using pyroscope connect:

pyroscope connect -pid {my-app-pid}

Windows Service

On Windows, Pyroscope Agent runs as a Windows service (with pyroscope agent command). Therefore if you are going to continuously profile Windows services, you may find it handy to pre-define targets in the configuration file (by default, the configuration file path is C:\Program Files\Pyroscope\Pyroscope Agent\agent.yml):

---
log-level: "info"
server-address: http://pyroscope-server:4040
targets:
- application-name: my.dotnet.svc
spy-name: dotnetspy
service-name: MyService

After the pyroscope configuration is changed, pyroscope service should be restarted for changes to take effect. Run in PowerShell as Administrator:

Get-Service pyroscope | Restart-Service

Refer to Configuration page to learn more about Pyroscop Agent and how to configure it.