-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Problem Statement
Currently, diagnostics collection requires SDK-level interception. The diagnostics app uses adapters like RecordingStorageAdapter (JS) and RustClientInterceptor (Rust) that wrap storage adapters to track bucket (size, operations, status) and table (row counts, data sizes) diagnostics.
This approach has limitations:
- SDK-specific: Each SDK must implement its own interception layer
- Inconsistency: Different SDKs may collect different metrics
- Complexity: Requires wrapping/hijacking storage adapters
Proposed Solution
Move diagnostics collection into sqlite-core by:
- Adding a SQL function (e.g.,
powersync_enable_diagnostics(enable BOOLEAN)) to enable/disable collection - Creating internal diagnostics tables (e.g.,
ps_diagnostics_buckets,ps_diagnostics_tables) that are automatically populated - Using SQLite hooks/triggers to collect metrics from existing PowerSync operations
Benefits
- Universal: All SDKs benefit automatically
- Simple: SDKs only need to invoke the function if a flag is present, then query the tables
- Consistent: Same diagnostics across all platforms
- Maintainable: Single implementation in sqlite-core
- Performance: Can be optimized at the core level
- Platform-agnostic tooling: Enables consistent diagnostics across platforms (diagnostics app, Nuxt module, future Chrome extension, Flutter devtools) without platform-specific interception
Possible API
-- Enable diagnostics
SELECT powersync_enable_diagnostics(1);
-- Disable diagnostics (stops collection, tables remain)
SELECT powersync_enable_diagnostics(0);
-- Enable diagnostics (with optional clear)
SELECT powersync_enable_diagnostics(1, 1); -- enable and clear existing data
SELECT powersync_enable_diagnostics(1, 0); -- enable without clearing
-- Clear all diagnostics
SELECT powersync_clear_diagnostics();
-- Or clear specific tables (if needed)
SELECT powersync_clear_diagnostics('buckets');
SELECT powersync_clear_diagnostics('tables');Metadata
Metadata
Assignees
Labels
No labels