Skip to content

Commit 54d662b

Browse files
committed
Add collect-linux example
1 parent 72027e3 commit 54d662b

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

docs/core/diagnostics/dotnet-trace.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ Output the parameters of each method in full. If not specified, parameters will
541541

542542
## Collect a trace with dotnet-trace
543543

544-
To collect traces using `dotnet-trace`:
544+
To collect traces using `dotnet-trace collect`:
545545

546546
- Get the process identifier (PID) of the .NET Core application to collect traces from.
547547

@@ -558,14 +558,22 @@ To collect traces using `dotnet-trace`:
558558
The preceding command generates output similar to the following:
559559

560560
```output
561-
Press <Enter> to exit...
562-
Connecting to process: <Full-Path-To-Process-Being-Profiled>/dotnet.exe
563-
Collecting to file: <Full-Path-To-Trace>/trace.nettrace
564-
Session Id: <SessionId>
565-
Recording trace 721.025 (KB)
561+
No profile or providers specified, defaulting to trace profiles 'dotnet-common' + 'dotnet-sampled-thread-time'.
562+
563+
Provider Name Keywords Level Enabled By
564+
Microsoft-Windows-DotNETRuntime 0x000000100003801D Informational(4) --profile
565+
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
566+
567+
Process : <full-path-to-process-being-trace>
568+
Output File : <process>_20251007_154557.nettrace
569+
[00:00:00:02] Recording trace 178.172 (KB)
570+
Press <Enter> or <Ctrl+C> to exit...
571+
Stopping the trace. This may take several minutes depending on the application being traced.
572+
573+
Trace completed.
566574
```
567575

568-
- Stop collection by pressing the `<Enter>` key. `dotnet-trace` will finish logging events to the *trace.nettrace* file.
576+
- Stop collection by pressing the `<Enter>` key. `dotnet-trace` will finish logging events to the `.nettrace` file.
569577

570578
## Launch a child application and collect a trace from its startup using dotnet-trace
571579

@@ -580,11 +588,11 @@ dotnet-trace collect -- hello.exe arg1 arg2
580588
The preceding command generates output similar to the following:
581589

582590
```output
583-
No profile or providers specified. Using default composition: dotnet-common + dotnet-thread-time
591+
No profile or providers specified, defaulting to trace profiles 'dotnet-common' + 'dotnet-sampled-thread-time'.
584592
585593
Provider Name Keywords Level Enabled By
594+
Microsoft-Windows-DotNETRuntime 0x000000100003801D Informational(4) --profile
586595
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
587-
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
588596
589597
Process : E:\temp\gcperfsim\bin\Debug\net5.0\gcperfsim.exe
590598
Output File : E:\temp\gcperfsim\trace.nettrace
@@ -640,6 +648,29 @@ However, when you want to gain a finer control over the lifetime of the app bein
640648
> [!IMPORTANT]
641649
> Launching your app with `dotnet run` can be problematic because the dotnet CLI may spawn many child processes that are not your app and they can connect to `dotnet-trace` before your app, leaving your app to be suspended at run time. It is recommended you directly use a self-contained version of the app or use `dotnet exec` to launch the application.
642650
651+
## (Linux-only) Collect a trace with Linux perf events using dotnet-trace
652+
653+
To collect traces using `dotnet-trace collect-linux`:
654+
655+
```output
656+
$ sudo dotnet-trace collect-linux
657+
No providers, profiles, ClrEvents, or PerfEvents were specified, defaulting to trace profiles 'dotnet-common' + 'cpu-sampling'.
658+
659+
Provider Name Keywords Level Enabled By
660+
Microsoft-Windows-DotNETRuntime 0x000000100003801D Informational(4) --profile
661+
662+
Linux Events Enabled By
663+
cpu-sampling --profile
664+
665+
[00:00:00:04] Recording trace.
666+
Press <Enter> or <Ctrl-C> to exit...
667+
668+
Recording stopped.
669+
Resolving symbols.
670+
Finished recording trace.
671+
Trace written to trace_20251007_160232.nettrace
672+
```
673+
643674
## View the trace captured from dotnet-trace
644675

645676
On Windows, you can view *.nettrace* files in [Visual Studio](/visualstudio/profiling/beginners-guide-to-performance-profiling?#step-2-analyze-cpu-usage-data) or [PerfView](https://github.com/microsoft/perfview) for analysis.

0 commit comments

Comments
 (0)