Skip to content

Per-database exclusions for collectors — Lite side (closes #887)#906

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/887-lite-per-database-exclusions
Apr 28, 2026
Merged

Per-database exclusions for collectors — Lite side (closes #887)#906
erikdarlingdata merged 1 commit intodevfrom
feature/887-lite-per-database-exclusions

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Lite-side companion to PR #905. Gives Lite users the same per-server "skip these databases" feature now available in the Dashboard — but stored client-side since Lite doesn't install on targets.

Storage

  • New `ExcludedDatabases` (List) on `ServerConnection`, persisted via the existing `servers.json` round-trip.

Collector wiring (9 collectors)

`query_stats`, `query_store`, `procedure_stats`, `query_snapshots`, `file_io_stats`, `waiting_tasks`, `database_configuration`, `database_scoped_configurations`, `database_size`. Azure-mode collectors that route through `GetAzureDatabaseListAsync` get exclusions automatically since the helper now applies the filter centrally.

Two SQL helpers on `RemoteCollectorService`

  • `BuildDatabaseExclusionFilter` — parameterized `AND NOT IN (@excl_db_N)`. Used by every collector whose query is plain (non-dynamic) T-SQL. Deliberately avoids `OPENJSON` / `STRING_SPLIT` because both require compat 130+ on the connection database (e.g. `master` often lags).
  • `BuildDatabaseExclusionLiteralClause` — `N'name'` literals with single-quote escaping (and a `forNestedDynamicSql=true` mode that doubles the escape). Used by `procedure_stats` which builds `@sql` and passes it to `sp_executesql`. Names come from a user-picked checklist of existing DBs, escaped against `'` injection.

UI

  • `ManageServersWindow`: new Excluded Databases button between Edit and Delete.
  • Right-click menu now mirrors the buttons: Edit / Excluded Databases / Delete (red) on top, then a separator, then existing Copy / Export items.
  • New `ExcludedDatabasesDialog` matches the Dashboard version: live-queries `sys.databases`, hides system DBs, pre-checks current exclusions, shows stale entries greyed with `(missing)` tag. Save calls `ServerManager.UpdateServer` to persist via `servers.json`.

Test plan

  • Lite builds clean.
  • Manage Servers window: button visible, context menu reorganized.
  • Excluded Databases dialog: opens, lists user DBs, hides system DBs.
  • Save round-trips to `servers.json`.
  • Manual: add an exclusion, watch the next collection cycle skip the DB in the local DuckDB tables.

Closes #887 (paired with #905 for Dashboard).

Lite-side companion to PR #905 — gives users a per-server way to skip
specific databases in the per-database collectors.

Storage: ExcludedDatabases (List<string>) added to ServerConnection,
persisted via the existing servers.json round-trip. Lite doesn't install
on targets, so the list lives client-side instead of in a remote
config.collector_database_exclusions table the way Dashboard does it.

Wiring: 9 collectors get the filter — query_stats, query_store,
procedure_stats, query_snapshots, file_io_stats, waiting_tasks,
database_configuration, database_scoped_configurations, database_size.
Azure-mode collectors that route through GetAzureDatabaseListAsync get
exclusions automatically since the helper now applies the filter
centrally.

Two SQL helpers on RemoteCollectorService:
- BuildDatabaseExclusionFilter — parameterized AND <col> NOT IN (@excl_db_N).
  Used by every collector whose query is plain (non-dynamic) T-SQL.
  No compatibility-level dependency (avoids OPENJSON / STRING_SPLIT which
  require compat 130+ on the connection database).
- BuildDatabaseExclusionLiteralClause — N'name' literals with single-quote
  escaping (and a forNestedDynamicSql=true mode that doubles the escape).
  Used by procedure_stats which builds @SQL then passes to sp_executesql,
  where parameter binding inside the dynamic statement is awkward.
  Names come from a user-picked checklist, so literal interpolation with
  proper escaping is safe.

UI: ManageServersWindow gets a new "Excluded Databases" button between
Edit and Delete. Right-click context menu now mirrors the buttons —
Edit / Excluded Databases / Delete on top, then the existing
Copy/Export items below a separator. New ExcludedDatabasesDialog
mirrors the Dashboard version: live-queries sys.databases, hides system
DBs, pre-checks current exclusions, shows stale entries (in list but not
on server) greyed with "(missing)" tag. Save calls
ServerManager.UpdateServer to persist via servers.json.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit add515e into dev Apr 28, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/887-lite-per-database-exclusions branch April 28, 2026 02:45
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.

1 participant