Skip to content

Add items to the Settings Window for Long Running Queries alerts#408

Closed
HannahVernon wants to merge 21 commits into
erikdarlingdata:devfrom
HannahVernon:dev
Closed

Add items to the Settings Window for Long Running Queries alerts#408
HannahVernon wants to merge 21 commits into
erikdarlingdata:devfrom
HannahVernon:dev

Conversation

@HannahVernon
Copy link
Copy Markdown
Contributor

Adds config options to control various aspects of GetLongRunningQueriesAsync() method.
Which component(s) does this affect?

[✅] Full Dashboard
[✅] Lite Dashboard

How was this tested?

Tested against SQL Server 2019 and SQL Server 2022 standalone instances.

Checklist

[✅] I have read the [contributing guide](https://github.com/erikdarlingdata/PerformanceMonitor/blob/main/CONTRIBUTING.md)
[✅] My code builds with zero warnings (dotnet build -c Debug)
[✅] I have tested my changes against at least one SQL Server version
[✅] I have not introduced any hardcoded credentials or server names

HannahVernon and others added 21 commits February 27, 2026 14:26
…_DIAGNOSTIC wait types, and WAITFOR wait types.
…to allow future configurability on the number of long-running queries returned. Added optional parameter to control display of WAITFOR types in future.
…clusions

Feature/long running query exclusions
…c() method. Removed System.Collections.Generic using statement as it is unnecessary.
…KUPTHREAD-to-long-running-queries

Added exclusion for backup-related waits to GetLongRunningQueriesAsync() method.
…dded miscWaitsFilter to exclude XE_LIVE_TARGET_TVF waits. Removed unused parameters. Corrected minimum value for maxLongRunningQueryCount (minimum 1 instead of 5).
…KUPTHREAD-to-long-running-queries

Feature/add exclusion for backupthread to long running queries
…ITFOR, BACKUPTHREAD, BACKUPIO, and XE_LIVE_TARGET_TVF wait types in Lite/Services/LocalDataService.WaitStats.cs
…ries-monitor-changes-to-lite

Added filtering for various wait types to long running query code in Lite.
Adds LongRunningQueryMaxResults to UserPreferences (default 5) and
exposes it in the Settings UI alongside the existing duration threshold.
Threads the value through GetAlertHealthAsync and GetLongRunningQueriesAsync
to replace the hardcoded TOP(5) in the DMV query.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds Math.Clamp(1, int.MaxValue) guard to GetLongRunningQueriesAsync in
both Dashboard and Lite, and updates the Dashboard settings validation
to use an explicit range check with a descriptive error message.

Mirrors the LongRunningQueryMaxResults setting across the Lite project:
adds the App property, loads/saves it to settings.json, exposes it in
the Lite Settings UI, and passes it through to GetLongRunningQueriesAsync
to replace the hardcoded LIMIT 5.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Prevents an OverflowException if the value in settings.json is outside
the int32 range. The value is read as long, clamped to [1, int.MaxValue],
then cast back to int.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces hardcoded wait type exclusions in GetLongRunningQueriesAsync
with user-configurable booleans for SP_SERVER_DIAGNOSTICS, WAITFOR /
BROKER_RECEIVE_WAITFOR, backup waits, and miscellaneous waits. All
four filters default to true (existing behavior preserved). Settings
are exposed in the Notifications section of both Dashboard and Lite
Settings UIs and persisted to UserPreferences / settings.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…config-settings

Feature/long running queries config settings
…config-settings

Feature/long running queries config settings
Copy link
Copy Markdown
Owner

@erikdarlingdata erikdarlingdata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Hannah — clean implementation, both apps stay in sync, and defaults preserve backward compatibility.

A few notes:

1. maxResults clamp is a no-op

Math.Clamp(maxResults, 1, int.MaxValue) doesn't do anything since an int can never exceed int.MaxValue. Same with the Dashboard validation check lrqMaxResults <= int.MaxValue — always true. Should probably cap at something reasonable like 100 or 1000 so someone doesn't accidentally type 999999999 and blow up their alert check.

2. maxResults could be parameterized

The value is interpolated directly into the query string (SELECT TOP({maxResults}) in Dashboard, LIMIT {maxResults} in Lite). It's an int so it's safe in practice, but parameterizing it would be more consistent with how thresholdMinutes is handled.

3. PR branch

Head and base are both dev — this will need to come from a feature branch to actually merge.

4. Minor

Extra blank line in LocalDataService.WaitStats.cs after the filter assignments (around line 226).

@HannahVernon
Copy link
Copy Markdown
Contributor Author

Regarding maxResults clamp -> value might be negative, which is also eliminated by the .Clamp(), so it's not quite a no-op. But, i agree a sensible upper limit that is far less than int.MaxValue() is a good idea. 1,000 perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants