Get-DbaWaitStatistic Should Allow Filtering In/Out Extra Waits
Summarize Functionality
As it stands, the only control that users have over the waits considered by Get-DbaWaitStatistic is the IncludeIgnorable switch. If a user wants to add or remove a particular wait type by name, then the current method would be to either submit a pull request or faff around with the source code's SQL. Given that the list of waits to ignore is just a collection of strings, this feels needlessly restrictive. Users should be able to provide their own list of strings to either add or remove from the $ignorable variable.
A typical use case for what I'm suggesting would be the parallelism waits. Some people care about those and some people don't, so the control over which are ignored should be passed over to users. Paul's script which inspired Get-DbaWaitStatistic even mentions that users may want to comment out CXCONSUMER.
Is there a command that is similiar or close to what you are looking for?
Yes
Technical Details
I imagine that this would be very easy to implement, but I don't know what means would be most consistent with dbatools' architecture and interface. Regardless, it's ultimately just either a union or set difference of the user's list of strings and the $ignorable variable.
seems reasonable @claude pls implement
Claude finished @potatoqualitee's task —— View job • claude/issue-9250-20251128-1657 • Create PR ➔
Implementation Complete ✓
I've successfully implemented the requested filtering functionality for Get-DbaWaitStatistic.
Changes Made
Added two new parameters that give users fine-grained control over wait type filtering:
-ExcludeWaitType - Excludes additional wait types beyond the default ignorable list
- Accepts an array of wait type names (e.g.,
"CXPACKET", "CXCONSUMER") - Perfect for filtering out parallelism waits or other waits that aren't relevant to your analysis
- Example:
Get-DbaWaitStatistic -SqlInstance sql2016 -ExcludeWaitType "CXPACKET", "CXCONSUMER"
-IncludeWaitType - Ensures specific wait types are included even if they're in the ignorable list
- Accepts an array of wait type names
- Useful when you need to see a particular wait that's normally filtered out
- Example:
Get-DbaWaitStatistic -SqlInstance sql2016 -IncludeWaitType "BROKER_RECEIVE_WAITFOR"
Implementation Details
- Maintains full backward compatibility - existing scripts continue to work unchanged
- The default ignorable list is preserved as
$defaultIgnorable - User-specified exclusions are added to the effective
$ignorablelist - User-specified inclusions are removed from the
$ignorablelist - Updated parameter validation tests
- Added integration tests for both new parameters
This addresses the exact use case mentioned in the issue - users can now easily control parallelism waits and other wait types without editing source code.
Testing
All tests have been updated:
- Parameter validation test now expects the two new parameters
- Integration test for
-ExcludeWaitTypeverifies excluded waits don't appear - Integration test for
-IncludeWaitTypeverifies included waits appear when present