Skip to content

Commit bc293c0

Browse files
committed
[Diagnostics][dotnet-trace] Add event filter option
1 parent 152ae79 commit bc293c0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/core/diagnostics/dotnet-trace.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ dotnet-trace collect
9393
[--stopping-event-provider-name <stoppingEventProviderName>]
9494
[--stopping-event-event-name <stoppingEventEventName>]
9595
[--stopping-event-payload-filter <stoppingEventPayloadFilter>]
96+
[--event-filters <list-of-comma-separated-event-filters>]
9697
```
9798

9899
### Options
@@ -256,6 +257,34 @@ dotnet-trace collect
256257

257258
A string, parsed as [payload_field_name]:[payload_field_value] pairs separated by commas, that will stop the trace upon hitting an event containing all specified payload pairs. Requires `--stopping-event-provider-name` and `--stopping-event-event-name` to be set. for example, `--stopping-event-provider-name Microsoft-Windows-DotNETRuntime --stopping-event-event-name Method/JittingStarted --stopping-event-payload-filter MethodNameSpace:Program,MethodName:OnButtonClick` to stop the trace upon the first `Method/JittingStarted` event for the method `OnButtonClick` in the `Program` namespace emitted by the `Microsoft-Windows-DotNETRuntime` event provider.
258259

260+
- **`--event-filters <list-of-comma-separated-event-filters>`**
261+
262+
Defines an additional optional filter for each provider's events. When no `--event-filters` is specified for a provider, all events allowed by the provider's keywords and level configuration are collected. Event filters provide additional granular control beyond the keyword/level filtering.
263+
264+
**Format:** `ProviderName:<Enable>:<EventIds>`
265+
266+
Where:
267+
- `ProviderName`: The EventPipe provider name (e.g., `Microsoft-Windows-DotNETRuntime`)
268+
- `Enable` : Boolean value indicating whether EventIds will be enabled or disabled, defaults to false
269+
- `EventIds`: Plus-delimited event IDs to enable or disable, defaults to empty.
270+
271+
**Examples:**
272+
```bash
273+
# Scenario: Disable specific events from Microsoft-Windows-DotNETRuntime
274+
--event-filters "Microsoft-Windows-DotNETRuntime:false:1+2+3+4+5+6+7+8+9"
275+
276+
# Scenario: Enable specific events from a provider
277+
--event-filters "Microsoft-Windows-DotNETRuntime:true:80+129+130+250"
278+
# Only events 80, 129, 130, and 250 will be collected from this provider (others are filtered out)
279+
280+
# Scenario: Multiple providers with mixed filtering - some providers have no filters
281+
--providers "Microsoft-Windows-DotNETRuntime:0xFFFFFFFF:5,System.Threading.Tasks.TplEventSource:0xFFFFFFFF:5,MyCustomProvider:0xFFFFFFFF:5"
282+
--event-filters "Microsoft-Windows-DotNETRuntime:false:1+2+3,System.Threading.Tasks.TplEventSource:true:7+8+9"
283+
# Microsoft-Windows-DotNETRuntime: All events EXCEPT 1,2,3 are collected
284+
# System.Threading.Tasks.TplEventSource: ONLY events 7,8,9 are collected
285+
# MyCustomProvider: ALL events are collected (no filter specified - follows provider keywords/level)
286+
```
287+
259288
> [!NOTE]
260289
261290
> - 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.
@@ -300,6 +329,7 @@ dotnet-trace collect-linux
300329
[--stopping-event-provider-name <stoppingEventProviderName>]
301330
[--stopping-event-event-name <stoppingEventEventName>]
302331
[--stopping-event-payload-filter <stoppingEventPayloadFilter>]
332+
[--event-filters <list-of-comma-separated-event-filters>]
303333
[--tracepoint-configs <list-of-comma-separated-tracepoint-configs>]
304334
[--kernel-events <list-of-kernel-events>]
305335
```
@@ -323,6 +353,9 @@ dotnet-trace collect-linux
323353
> [!NOTE]
324354
> 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`.
325355
356+
> [!TIP]
357+
> Use `--event-filters` to disable specific events before they are routed to tracepoints. Event filtering happens before tracepoint routing - only events that pass the filter will be sent to their assigned tracepoints.
358+
326359
**Examples:**
327360
```bash
328361
# Scenario: All events from provider go to a default tracepoint

0 commit comments

Comments
 (0)