You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Enables the collection of .NET Core traces of a running process without a native profiler.
45
45
* Is built on [`EventPipe`](./eventpipe.md) of the .NET Core runtime.
46
-
* On Linux, provides additional integration with kernel user_events for native tracing tool compatibility.
46
+
* Delivers the same experience on Windows, Linux, and macOS.
47
+
* Offers an additional command on Linux to collect Linux perf events.
47
48
48
49
## Options
49
50
@@ -126,7 +127,7 @@ dotnet-trace collect
126
127
| ------------ | ------------------- |
127
128
|`gc`|`0x1`|
128
129
|`gchandle`|`0x2`|
129
-
|`fusion`|`0x4`|
130
+
|`assemblyloader`|`0x4`|
130
131
|`loader`|`0x8`|
131
132
|`jit`|`0x10`|
132
133
|`ngen`|`0x20`|
@@ -145,7 +146,7 @@ dotnet-trace collect
145
146
|`gcheapdump`|`0x100000`|
146
147
|`gcsampledobjectallocationhigh`|`0x200000`|
147
148
|`gcheapsurvivalandmovement`|`0x400000`|
148
-
|`gcheapcollect`|`0x800000`|
149
+
|`managedheapcollect`|`0x800000`|
149
150
|`gcheapandtypenames`|`0x1000000`|
150
151
|`gcsampledobjectallocationlow`|`0x2000000`|
151
152
|`perftrack`|`0x20000000`|
@@ -159,7 +160,10 @@ dotnet-trace collect
159
160
|`compilationdiagnostic`|`0x2000000000`|
160
161
|`methoddiagnostic`|`0x4000000000`|
161
162
|`typediagnostic`|`0x8000000000`|
163
+
|`jitinstrumentationdata`|`0x10000000000`|
164
+
|`profiler`|`0x20000000000`|
162
165
|`waithandle`|`0x40000000000`|
166
+
|`allocationsampling`|`0x80000000000`|
163
167
164
168
You can read about the CLR provider more in detail on the [.NET runtime provider reference documentation](../../fundamentals/diagnostics/runtime-events.md).
165
169
@@ -213,7 +217,9 @@ dotnet-trace collect
213
217
214
218
| Profile | Description |
215
219
|---------|-------------|
216
-
|`cpu-sampling`|Useful for tracking CPU usage and general .NET runtime information. This is the default option if no profile or providers are specified.|
220
+
|`dotnet-default`|Combination of `dotnet-thread-time` and `dotnet-clr-default`. This is the default profile used when no other provider/event/profile options are specified.|
221
+
|`dotnet-thread-time`|Useful for tracking .NET thread-time information. This is the default profile used when no other provider/event/profile options are specified.|
222
+
|`dotnet-clr-default`|Useful for tracking a multitude of .NET events.|
217
223
|`gc-verbose`|Tracks GC collections and samples object allocations.|
218
224
|`gc-collect`|Tracks GC collections only at very low overhead.|
219
225
@@ -268,131 +274,184 @@ dotnet-trace collect
268
274
269
275
## dotnet-trace collect-linux
270
276
271
-
Collects diagnostic traces from .NET applications using Linux user_events as a transport layer. This command provides the same functionality as [`dotnet-trace collect`](#dotnet-trace-collect) but routes .NET runtime events through the Linux kernel's user_events subsystem before writing them to `.nettrace` files.
277
+
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.
272
278
273
-
This transport approach enables automatic unification of user-space .NET events with kernel-space system events, since both are captured in the same kernel tracing infrastructure. Linux tools like `perf` and `ftrace` can monitor events in real-time while maintaining full compatibility with existing .NET profiling workflows.
279
+
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.
274
280
275
281
### Prerequisites
276
282
277
283
- Linux kernel with `CONFIG_USER_EVENTS=y` support (kernel 6.4+)
278
-
-Appropriate permissions to access `/sys/kernel/tracing/user_events_data`
`dotnet-trace collect-linux` supports all the same options as [`dotnet-trace collect`](#dotnet-trace-collect), excluding `--dsrouter`, and additionally offers:
Defines the explicit mapping between EventPipe providers and kernel tracepoints. Each provider in `--providers` must have a corresponding entry in `--tracepoint-configs`
318
+
A comma-separated list of `EventPipe` providers to be enabled. These providers supplement any providers implied by `--profile <profile-name>`. If there's any inconsistency for a particular provider, this configuration takes precedence over the implicit configuration from the profile.
-`EventIds`: Plus-delimited event IDs to route to that tracepoint
322
+
-`Provider[,Provider]`
323
+
-`Provider` is in the form: `KnownProviderName[:Flags[:Level][:KeyValueArgs]]`.
324
+
-`KeyValueArgs` is in the form: `[key1=value1][;key2=value2]`.
322
325
323
-
> [!NOTE]
324
-
> All tracepoint names are automatically prefixed with the provider name to avoid collisions. For example, `gc_events` for the `Microsoft-Windows-DotNETRuntime` provider becomes `Microsoft_Windows_DotNETRuntime_gc_events`.
326
+
To learn more about some of the well-known providers in .NET, refer to [Well-known Event Providers](./well-known-event-providers.md).
325
327
326
-
**Examples:**
327
-
```
328
-
# Scenario: All events from provider go to a default tracepoint
# EventIds 1, 2, and 3 from Microsoft-Windows-DotNETRuntime will be written to Microsoft_Windows_DotNETRuntime_gc_events
340
-
# All enabled events from MyCustomProvider will be written to MyCustomProvider_custom_events
341
-
```
328
+
-**`--clreventlevel <clreventlevel>`**
329
+
330
+
Verbosity of CLR events to be emitted.
331
+
The following table shows the available event levels.
332
+
333
+
| String value | Numeric value |
334
+
| --------------- | :-----------: |
335
+
|`logalways`|`0`|
336
+
|`critical`|`1`|
337
+
|`error`|`2`|
338
+
|`warning`|`3`|
339
+
|`informational`|`4`|
340
+
|`verbose`|`5`|
341
+
342
+
-**`--clrevents <clrevents>`**
343
+
344
+
A list of CLR runtime provider keywords to enable separated by `+` signs. This is a simple mapping that lets you specify event keywords via string aliases rather than their hex values. For example, `dotnet-trace collect-linux --providers Microsoft-Windows-DotNETRuntime:3:4` requests the same set of events as `dotnet-trace collect-linux --clrevents gc+gchandle --clreventlevel informational`. The table below shows the list of available keywords:
345
+
346
+
| Keyword String Alias | Keyword Hex Value |
347
+
| ------------ | ------------------- |
348
+
|`gc`|`0x1`|
349
+
|`gchandle`|`0x2`|
350
+
|`assemblyloader`|`0x4`|
351
+
|`loader`|`0x8`|
352
+
|`jit`|`0x10`|
353
+
|`ngen`|`0x20`|
354
+
|`startenumeration`|`0x40`|
355
+
|`endenumeration`|`0x80`|
356
+
|`security`|`0x400`|
357
+
|`appdomainresourcemanagement`|`0x800`|
358
+
|`jittracing`|`0x1000`|
359
+
|`interop`|`0x2000`|
360
+
|`contention`|`0x4000`|
361
+
|`exception`|`0x8000`|
362
+
|`threading`|`0x10000`|
363
+
|`jittedmethodiltonativemap`|`0x20000`|
364
+
|`overrideandsuppressngenevents`|`0x40000`|
365
+
|`type`|`0x80000`|
366
+
|`gcheapdump`|`0x100000`|
367
+
|`gcsampledobjectallocationhigh`|`0x200000`|
368
+
|`gcheapsurvivalandmovement`|`0x400000`|
369
+
|`managedheapcollect`|`0x800000`|
370
+
|`gcheapandtypenames`|`0x1000000`|
371
+
|`gcsampledobjectallocationlow`|`0x2000000`|
372
+
|`perftrack`|`0x20000000`|
373
+
|`stack`|`0x40000000`|
374
+
|`threadtransfer`|`0x80000000`|
375
+
|`debugger`|`0x100000000`|
376
+
|`monitoring`|`0x200000000`|
377
+
|`codesymbols`|`0x400000000`|
378
+
|`eventsource`|`0x800000000`|
379
+
|`compilation`|`0x1000000000`|
380
+
|`compilationdiagnostic`|`0x2000000000`|
381
+
|`methoddiagnostic`|`0x4000000000`|
382
+
|`typediagnostic`|`0x8000000000`|
383
+
|`jitinstrumentationdata`|`0x10000000000`|
384
+
|`profiler`|`0x20000000000`|
385
+
|`waithandle`|`0x40000000000`|
386
+
|`allocationsampling`|`0x80000000000`|
387
+
388
+
You can read about the CLR provider more in detail on the [.NET runtime provider reference documentation](../../fundamentals/diagnostics/runtime-events.md).
A comma-separated list of kernel perf event tracepoints to include in the trace. Available kernel events can be found under tracefs, which is typically mounted at `/sys/kernel/tracing`, through `available_events` for all available tracepoints or through the `events/` subdirectory for categorized events.
A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly. The following profiles are available:
399
+
400
+
| Profile | Description |
401
+
|---------|-------------|
402
+
|`dotnet-default`|Combination of `dotnet-thread-time` and `dotnet-clr-default`. This is the default profile used when no other provider/event/profile options are specified.|
403
+
|`dotnet-thread-time`|Useful for tracking .NET thread-time information. This is the default profile used when no other provider/event/profile options are specified.|
404
+
|`dotnet-clr-default`|Useful for tracking a multitude of .NET events.|
405
+
|`gc-verbose`|Tracks GC collections and samples object allocations.|
406
+
|`gc-collect`|Tracks GC collections only at very low overhead.|
A comma-separated list of kernel event categories to include in the trace. These events are automatically grouped into kernel-named tracepoints. Available categories include:
411
+
-**`--format {Chromium|NetTrace|Speedscope}`**
346
412
347
-
| Category | Description | Linux Tracepoints |
348
-
|----------|-------------|-------------------|
349
-
|`syscalls`| System call entry/exit events |`syscalls:sys_enter_*`, `syscalls:sys_exit_*`|
350
-
|`sched`| Process scheduling events |`sched:sched_switch`, `sched:sched_wakeup`|
Sets the output format for the trace file conversion. The default is `NetTrace`.
354
414
355
-
These events correspond to Linux kernel tracepoints documented in the [Linux kernel tracing documentation](https://www.kernel.org/doc/html/latest/trace/index.html). For more details on available tracepoints, see [ftrace](https://www.kernel.org/doc/html/latest/trace/ftrace.html) and [tracepoints](https://www.kernel.org/doc/html/latest/trace/tracepoints.html).
415
+
-**`-o|--output <trace-file-path>`**
356
416
357
-
Example: `--kernel-events syscalls,sched,net`
417
+
The output path for the collected trace data. If not specified it defaults to `<appname>_<yyyyMMdd>_<HHmmss>.nettrace`, for example, `myapp_20210315_111514.nettrace``.
358
418
359
-
### Linux Integration
419
+
-**`--duration <time-to-run>`**
360
420
361
-
**Tracepoint Configuration Requirements:**
421
+
The time for the trace to run. Use the `dd:hh:mm:ss` format. For example `00:00:00:05` will run it for 5 seconds.
362
422
363
-
-**Mandatory Mapping**: Every provider must be explicitly mapped to at least a default tracepoint and/or exclusive tracepoint sets via `--tracepoint-configs`
364
-
-**Tracepoint Isolation**: Each tracepoint can only receive events from one provider
365
-
-**Event Routing**: Different event IDs within a provider can be routed to different tracepoints for granular control
366
-
-**Automatic Prefixing**: All tracepoint names are prefixed with the provider name to avoid collisions
423
+
#### .NET Process Target Options
367
424
368
-
**Kernel Integration Points:**
425
+
> ![NOTE]
426
+
> The default behavior for collect-linux is to collect .NET events and perf event tracepoints from ALL discoverable processes.
369
427
370
-
The kernel tracepoints can be accessed through standard Linux tracing interfaces:
-**perf**: Use `perf list user_events*` to see available events
374
-
-**System monitoring tools**: Any tool that can consume Linux tracepoints
430
+
The name of the process to collect the trace from.
375
431
376
-
### Examples
432
+
> [!NOTE]
433
+
> By default, `/tmp` will be searched to discover .NET processes diagnostics ports. Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
> By default, `/tmp` will be searched to discover .NET processes diagnostics ports. Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
441
+
442
+
-**`-- <command>`**
443
+
444
+
After the collection configuration parameters, the user can append `--` followed by a command to start a .NET application. This may be helpful when diagnosing issues that happen early in the process, such as startup performance issue or assembly loader and binder errors.
445
+
446
+
-**`--show-child-io`**
447
+
448
+
Only applicable when `-- <command>` is used. Shows the input and output streams of a launched child process in the current console.
449
+
450
+
> [!NOTE]
451
+
452
+
> - Stopping the trace may take a long time (up to minutes) for large applications. The runtime needs to send over the type cache for all managed code that was captured in the trace.
453
+
454
+
> - To collect a trace using `dotnet-trace collect-linux`, it needs to be run with root permissions (`CAP_PERFMON`/`CAP_SYS_ADMIN`). Otherwise, the tool will fail to collect events.
Copy file name to clipboardExpand all lines: docs/core/diagnostics/eventsource-collect-and-view-traces.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -214,7 +214,7 @@ into other formats, such as Chromium or [Speedscope](https://www.speedscope.app/
214
214
Trace completed.
215
215
```
216
216
217
-
dotnet-trace uses a comma-delimited variant of the [conventional text format](#conventions-for-describing-provider-configuration) for describing provider configuration in
217
+
dotnet-trace uses the [conventional text format](#conventions-for-describing-provider-configuration) for describing provider configuration in
218
218
the `--providers` argument. For more options on how to take traces using dotnet-trace, see the
0 commit comments