Skip to content

Commit 862ceb0

Browse files
committed
Address style feedback
1 parent 2cd3fac commit 862ceb0

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

docs/core/diagnostics/dotnet-trace.md

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ The `dotnet-trace` tool:
4343
* Is a cross-platform .NET Core tool.
4444
* Enables the collection of .NET Core traces of a running process without a native profiler.
4545
* Is built on [`EventPipe`](./eventpipe.md) of the .NET Core runtime.
46-
* Delivers the same experience on Windows, Linux, and macOS.
47-
* Offers an additional command on Linux to collect Linux perf events.
46+
* Supports two different ways of collecting traces:
47+
- The [`collect` verb](#dotnet-trace-collect) offers consistent functionality on any OS
48+
- The [`collect-linux` verb](#dotnet-trace-collect-linux) uses Linux-specific OS capabilities to provide additional features
49+
50+
| | collect | collect-linux |
51+
|------------------------------------------|----------|-----------------------------------|
52+
| Supported OS | Any | Linux only, kernel version >= 6.4 |
53+
| Requires Admin/Root Privilege | No | Yes |
54+
| Trace all processes simultaneously | No | Supported |
55+
| Capture native library and kernel events | No | Supported |
56+
| Event callstacks include native frames | No | Yes |
4857

4958
## Options
5059

@@ -213,9 +222,9 @@ dotnet-trace collect
213222
214223
- **`--profile <list-of-comma-separated-profile-names>`**
215224

216-
A comma-separated list of named, pre-defined set of provider configurations for common tracing scenarios. Providers configured through `--providers` will override the profile's configuration. Similarly, if any profile configures the CLR runtime provider, it will override any configurations prescribed through `--clrevents`.
225+
In this context, a profile is a pre-defined set of provider configurations for common tracing scenarios. Multiple profiles can be specified at a time, delimited by commas. Providers configured through `--providers` will override the profile's configuration. Similarly, if any profile configures the CLR runtime provider, it will override any configurations prescribed through `--clrevents`.
217226

218-
Default behavior (when `--profile`, `--providers`, and `--clrevents` are omitted): dotnet-trace enables a useful, low-overhead composition: `dotnet-common` + `dotnet-sampled-thread-time`.
227+
When `--profile`, `--providers`, and `--clrevents` are all omitted, `dotnet-trace collect` enables profiles `dotnet-common` and `dotnet-sampled-thread-time` by default.
219228

220229
Available profiles:
221230

@@ -228,7 +237,7 @@ dotnet-trace collect
228237
|`database`|Captures ADO.NET and Entity Framework database commands.|
229238

230239
> [!NOTE]
231-
> The former default `cpu-sampling` profile is now `--profile dotnet-sampled-thread-time` + `--providers "Microsoft-Windows-DotNETRuntime:0x14C14FCCBD:4"`.
240+
> In past versions of the dotnet-trace tool, the collect verb supported a profile called `cpu-sampling`. This profile was removed because the name was misleading. It sampled all threads regardless of their CPU usage. You can achieve a similar result now using `--profile dotnet-sampled-thread-time,dotnet-common`. If you need to match the former `cpu-sampling` behavior exactly use `--profile dotnet-sampled-thread-time --providers "Microsoft-Windows-DotNETRuntime:0x14C14FCCBD:4"`.
232241
233242
- **`--providers <list-of-comma-separated-providers>`**
234243

@@ -237,7 +246,7 @@ dotnet-trace collect
237246
This list of providers is in the form:
238247

239248
- `Provider[,Provider]`
240-
- `Provider` is in the form: `KnownProviderName[:Flags[:Level][:KeyValueArgs]]`.
249+
- `Provider` is in the form: `KnownProviderName[:Flags[:Level[:KeyValueArgs]]]`.
241250
- `KeyValueArgs` is in the form: `[key1=value1][;key2=value2]`.
242251

243252
To learn more about some of the well-known providers in .NET, refer to [Well-known Event Providers](./well-known-event-providers.md).
@@ -282,35 +291,28 @@ dotnet-trace collect
282291
## dotnet-trace collect-linux
283292

284293
> [!NOTE]
285-
> The collect-linux verb is a new preview feature and relies on an updated version of the .nettrace file format. The latest PerfView release supports these trace files but other ways of using the trace file may not work yet.
294+
> The collect-linux verb is a new preview feature and relies on an updated version of the .nettrace file format. The latest PerfView release supports these trace files but other ways of using the trace file such as [`convert`](#dotnet-trace-convert) and [`report`](#dotnet-trace-report) may not work yet.
286295
287-
> [!NOTE]
288-
> Currently supported Linux RIDs are linux-x64 and linux-arm64.
289-
290-
> [!NOTE]
291-
> The generated NetTrace is not fully compatible with [`convert`](#dotnet-trace-convert) and [`report`](#dotnet-trace-report).
292-
293-
Collects diagnostic traces using perf_events, a Linux OS technology. `collect-linux` requires admin privileges to capture kernel- and user-mode events, and by default, captures events from all processes.
294-
295-
This Linux-only command includes the same .NET events as [`dotnet-trace collect`](#dotnet-trace-collect), and it uses the kernel’s user_events mechanism to emit .NET events as perf events, enabling unification of user-space .NET events with kernel-space system events.
296-
297-
### Default collection behavior
298-
299-
When `--providers`, `--profile`, `--clrevents`, and `--perf-events` aren’t specified, `collect-linux` enables the default `profile` providing the comprehensive composition:
300-
301-
- `dotnet-common` — lightweight .NET runtime diagnostics.
302-
- `cpu-sampling` — kernel CPU sampling (perf-based) via `Universal.Events/cpu`.
296+
Collects diagnostic traces using perf_events, a Linux OS technology. `collect-linux` enables the following additional features over [`collect`](#dotnet-trace-collect).
303297

304-
By default, a machine-wide trace will be collected. .NET Processes are discovered through their diagnostics ports, which are located under the `TMPDIR` environment variable when set and otherwise under `/tmp`.
305-
306-
If collecting events from all .NET Processes is undesired, `-n, --name <name>` or `-p|--process-id <PID>` can be used to specify a particular process.
298+
| | collect | collect-linux |
299+
|------------------------------------------|----------|-----------------------------------|
300+
| Supported OS | Any | Linux only, kernel version >= 6.4 |
301+
| Requires Admin/Root Privilege | No | Yes |
302+
| Trace all processes simultaneously | No | Supported |
303+
| Capture native library and kernel events | No | Supported |
304+
| Event callstacks include native frames | No | Yes |
307305

308306
### Prerequisites
309307

310308
- Linux kernel with `CONFIG_USER_EVENTS=y` support (kernel 6.4+)
311309
- Root permissions
312310
- .NET 10+
313311

312+
> [!NOTE]
313+
> The current set of supported Linux RIDs is { linux-x64, linux-arm64 }.
314+
> The underlying trace recording library currently requires glibc 2.35+.
315+
314316
### Synopsis
315317

316318
```dotnetcli
@@ -333,6 +335,15 @@ dotnet-trace collect-linux
333335
[-p|--process-id <pid>]
334336
```
335337

338+
### Default collection behavior
339+
340+
When `--providers`, `--profile`, `--clrevents`, and `--perf-events` aren’t specified, `collect-linux` enables these profiles by default:
341+
342+
- `dotnet-common` — lightweight .NET runtime diagnostics.
343+
- `cpu-sampling` — kernel CPU sampling.
344+
345+
By default all processes on the machine will be traced. Use `-n, --name <name>` or `-p|--process-id <PID>` to trace only one process.
346+
336347
### Options
337348

338349
#### Provider/Event Specification Options
@@ -344,7 +355,7 @@ dotnet-trace collect-linux
344355
This list of providers is in the form:
345356

346357
- `Provider[,Provider]`
347-
- `Provider` is in the form: `KnownProviderName[:Flags[:Level][:KeyValueArgs]]`.
358+
- `Provider` is in the form: `KnownProviderName[:Flags[:Level[:KeyValueArgs]]]`.
348359
- `KeyValueArgs` is in the form: `[key1=value1][;key2=value2]`.
349360

350361
To learn more about some of the well-known providers in .NET, refer to [Well-known Event Providers](./well-known-event-providers.md).
@@ -413,15 +424,15 @@ dotnet-trace collect-linux
413424

414425
- **`--perf-events <list-of-perf-events>`**
415426

416-
A comma-separated list of perf events to include in the trace. Available events can be found under tracefs, which is typically mounted at `/sys/kernel/tracing`, through `available_events` for all available events or through the `events/` subdirectory for categorized events.
427+
A comma-separated list of perf events to include in the trace. Available events can be found under [tracefs](https://lwn.net/Articles/630526/), which is typically mounted at `/sys/kernel/tracing`, through `available_events` for all available events or through the `events/` subdirectory for categorized events.
417428

418429
Example: `--perf-events syscalls:sys_enter_execve,sched:sched_switch,sched:sched_wakeup`
419430

420431
- **`--profile <list-of-comma-separated-profile-names>`**
421432

422-
A comma-separated list of named, pre-defined set of provider configurations for common tracing scenarios. Providers configured through `--providers` will override the profile's configuration. Similarly, if any profile configures the CLR runtime provider, it will override any configurations prescribed through `--clrevents`.
433+
In this context, a profile is a pre-defined set of provider configurations for common tracing scenarios. Multiple profiles can be specified at a time, delimited by commas. Providers configured through `--providers` will override the profile's configuration. Similarly, if any profile configures the CLR runtime provider, it will override any configurations prescribed through `--clrevents`.
423434

424-
Default behavior (when `--profile`, `--providers`, `--clrevents`, and `--perf-events` are omitted): dotnet-trace enables a useful, low-overhead composition: `dotnet-common` + `cpu-sampling`.
435+
When `--profile`, `--providers`, `--clrevents`, and `--perf-events` are all omitted, `dotnet-trace collect-linux` enables profiles `dotnet-common` and `cpu-sampling` by default.
425436

426437
Available profiles:
427438

@@ -675,9 +686,9 @@ However, when you want to gain a finer control over the lifetime of the app bein
675686
> [!IMPORTANT]
676687
> 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.
677688
678-
## (Linux-only) Collect a trace with Linux perf events using dotnet-trace
689+
## (Linux-only) Collect a machine-wide trace using dotnet-trace
679690
680-
To collect traces using `dotnet-trace collect-linux`:
691+
This example captures CPU samples for all processes on the machine. Any processes running .NET 10+ will also include some additional lightweight events describing GC, JIT, and Assembly loading behavior.
681692
682693
```output
683694
$ sudo dotnet-trace collect-linux

0 commit comments

Comments
 (0)