solid_observer 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -0
  3. data/README.md +157 -28
  4. data/app/assets/javascripts/solid_observer/live_poll.js +376 -0
  5. data/app/controllers/concerns/solid_observer/paginatable.rb +17 -0
  6. data/app/controllers/concerns/solid_observer/require_persistence_mode.rb +19 -0
  7. data/app/controllers/concerns/solid_observer/require_solid_queue.rb +19 -0
  8. data/app/controllers/solid_observer/application_controller.rb +69 -0
  9. data/app/controllers/solid_observer/dashboard_controller.rb +79 -0
  10. data/app/controllers/solid_observer/events_controller.rb +50 -0
  11. data/app/controllers/solid_observer/jobs_controller.rb +85 -0
  12. data/app/controllers/solid_observer/storages_controller.rb +12 -0
  13. data/app/helpers/solid_observer/application_helper.rb +95 -0
  14. data/app/helpers/solid_observer/dashboard_helper.rb +39 -0
  15. data/app/models/solid_observer/queue_event.rb +134 -0
  16. data/app/models/solid_observer/queue_metric.rb +1 -1
  17. data/app/presenters/solid_observer/execution_presenter.rb +50 -0
  18. data/app/views/layouts/solid_observer/application.html.erb +470 -0
  19. data/app/views/solid_observer/dashboard/_chart.html.erb +28 -0
  20. data/app/views/solid_observer/dashboard/_live_state.html.erb +20 -0
  21. data/app/views/solid_observer/dashboard/_queue_table.html.erb +34 -0
  22. data/app/views/solid_observer/dashboard/_right_now.html.erb +3 -0
  23. data/app/views/solid_observer/dashboard/_throughput.html.erb +32 -0
  24. data/app/views/solid_observer/dashboard/index.html.erb +113 -0
  25. data/app/views/solid_observer/errors/storage_unavailable.html.erb +27 -0
  26. data/app/views/solid_observer/events/index.html.erb +53 -0
  27. data/app/views/solid_observer/events/show.html.erb +47 -0
  28. data/app/views/solid_observer/jobs/index.html.erb +61 -0
  29. data/app/views/solid_observer/jobs/show.html.erb +71 -0
  30. data/app/views/solid_observer/shared/_empty_state.html.erb +5 -0
  31. data/app/views/solid_observer/shared/_pagination.html.erb +17 -0
  32. data/app/views/solid_observer/shared/_stat_card.html.erb +9 -0
  33. data/app/views/solid_observer/storages/show.html.erb +39 -0
  34. data/bin/quality_gate +95 -0
  35. data/config/routes.rb +17 -0
  36. data/db/migrate/20260424000001_add_composite_indexes_to_queue_events.rb +30 -0
  37. data/lib/generators/solid_observer/install_generator.rb +12 -25
  38. data/lib/generators/solid_observer/templates/initializer.rb.tt +5 -6
  39. data/lib/solid_observer/base_metric.rb +1 -1
  40. data/lib/solid_observer/chart_buffer.rb +83 -0
  41. data/lib/solid_observer/cli/base.rb +2 -2
  42. data/lib/solid_observer/cli/jobs.rb +2 -2
  43. data/lib/solid_observer/cli/status.rb +20 -2
  44. data/lib/solid_observer/cli/storage.rb +41 -40
  45. data/lib/solid_observer/configuration.rb +47 -37
  46. data/lib/solid_observer/correlation_id_resolver.rb +8 -6
  47. data/lib/solid_observer/engine.rb +72 -17
  48. data/lib/solid_observer/params/events_filter.rb +37 -0
  49. data/lib/solid_observer/params/jobs_filter.rb +35 -0
  50. data/lib/solid_observer/queries/events_query.rb +27 -0
  51. data/lib/solid_observer/queries/execution_finder.rb +42 -0
  52. data/lib/solid_observer/queries/job_executions_query.rb +73 -0
  53. data/lib/solid_observer/queue_event_buffer.rb +163 -25
  54. data/lib/solid_observer/queue_stats.rb +165 -19
  55. data/lib/solid_observer/services/cleanup_storage.rb +58 -42
  56. data/lib/solid_observer/services/database_size.rb +86 -0
  57. data/lib/solid_observer/services/flush_event_buffer.rb +31 -15
  58. data/lib/solid_observer/services/install_migrations.rb +49 -0
  59. data/lib/solid_observer/services/record_event.rb +51 -14
  60. data/lib/solid_observer/services/ui_auth_check.rb +65 -0
  61. data/lib/solid_observer/subscriber.rb +15 -8
  62. data/lib/solid_observer/version.rb +1 -1
  63. data/lib/solid_observer.rb +7 -0
  64. data/lib/tasks/solid_observer.rake +10 -2
  65. metadata +55 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2e83e38f795537bcacb9a431fe39543476b615cb205904fd5af324a4a1886e8
4
- data.tar.gz: cf501ff1b33535eb7a2b4f4858289bea3c93af7371af83bb867255b3f00de462
3
+ metadata.gz: a745bb3571f70b207e14f2e88f6162db6b2322a889d42f5ebd2a50e80c5b8014
4
+ data.tar.gz: d05f835df0503f04f88223c0879145a2dab13279cd5bfc59346545c0e8263f1c
5
5
  SHA512:
6
- metadata.gz: 58fb350eda47268f65f13b71ac4f317fe7a9cd6274a05c636a4d7a91477ad5a6269a652a7bb537255cbce8e690231c6bd33507530baf6fb626e672b738bf175b
7
- data.tar.gz: 9042759cdeca68bf9fd50a0c62493c6e9d057915b714cb8d68ef81f36028e6437c8f85dfeab8bac971419bc8471b147840051aa881a01871f720640f4abdfdb9
6
+ metadata.gz: 8417c8013a7c9ff03a9d52481af63889adaba093abf0c9b041842664af7fb15edde929f7c7b94c6df12cbac00ca41d2aeee0f488fd7ffe831abf9d5f873bff09
7
+ data.tar.gz: 92147e32675291ec743e055c55382bf719a9ab6dd10e2e507789d0163b703e06490ad97dbb785e0a9c0b51b8eb72eb7a849d95504ac52c8680e53a137b50e4e4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,66 @@
1
+ ## [0.3.0] - 2026-05-25
2
+
3
+ > Note: there is no separate `0.2.0` gem release — work originally scoped for v0.2.0 (stability + refactoring, SO-040 through SO-049) was folded into this release.
4
+
5
+ Headline: **Web UI Dashboard** + stability hardening from pre-release review.
6
+
7
+ ### Added
8
+ - Web UI dashboard at `/solid_observer` — queue stats, jobs browser, events log, storage info, responsive layout, optional HTTP Basic Auth
9
+ - Web UI config: `ui_enabled`, `ui_username`, `ui_password`, `ui_base_controller`, `ui_refresh_interval`
10
+ - Dashboard "Live" toggle: when enabled, only the Right-Now card region (`so_right_now` Turbo Frame) reloads on the configured cadence (`SolidObserver.config.ui_refresh_interval`). Scoped cards stay frozen until the range selector changes. Toggle state lives in the `?live=on` URL param so it survives range navigations.
11
+ - Dashboard now supports a Time-Range selector (`15m`, `30m`, `1h`, `7h`, `1d`, `7d`, `14d`, default `1h`) that scopes the new "Last <range>" card region (Performed / Failed / Enqueue rate). The "Right Now" region (Ready / Scheduled / Claimed / Failed-awaiting-retry / Workers) is unaffected by the range and reflects current SolidQueue state.
12
+ - Retry / discard actions with confirmation dialogs and CSRF protection
13
+ - `QueueEventBuffer#metrics` and `#shutdown` (graceful drain on app exit)
14
+ - Configuration: `max_buffer_size` (default 10_000), `buffer_overflow_strategy` (`:drop_old` / `:drop_new`), `filter_cache_ttl`
15
+ - `Services::DatabaseSize` for cross-adapter table-size measurement; composite indexes and `distinct_job_classes` / `distinct_queue_names` scopes
16
+ - Dashboard now shows three throughput counters (Performed last hour, Failed last 24h, Enqueue rate last 5 min) sourced from the events table, alongside existing point-in-time counters. Throughput counters are persistence-mode only.
17
+ - Stat counter subtitles ("queued" / "future runs" / "in progress" / "awaiting retry" / "active processes") clarify SolidQueue lifecycle terminology.
18
+ - Conceptual hint banner on the dashboard explains the difference between Jobs tab (in-flight + failed) and Events tab (historical record).
19
+ - Jobs tab now has an empty state with a hint pointing to Events tab for completed-job history.
20
+ - Dashboard polled chart strip and unified card grid: a JSON-fed polling client refreshes six stat cards (Ready, Scheduled, Claimed, Workers, Failed, Enqueue Rate) and three sparklines (Performed/min, Ready depth, Failed/min) every `SolidObserver.config.ui_refresh_interval` seconds (default `30`, `0` disables polling). In realtime mode only the Ready sparkline renders and the Enqueue Rate card is omitted. Toggle in the dashboard top bar enables/disables polling; state lives in `?live=on` URL param. Hand-rolled inline-SVG sparklines, no JS framework, no external chart library.
21
+
22
+ ### Fixed
23
+ - **Duration was displayed off by 1000x.** `RecordEvent` stored `ActiveSupport::Notifications::Event#duration` (milliseconds) directly; `format_duration` interpreted it as seconds. Fixed by converting ms → seconds at write time. No data migration needed (fixed before v0.3.0 release); run `bin/rails solid_observer:storage:purge` to clear pre-fix local data.
24
+ - **Dashboard chart strip renders populated polylines on first paint** instead of empty placeholders. Server-side `spark_points` helper mirrors the JS `Sparkline.render` projection formula so the first HTML response ships with real data; the first JS poll appends one additional segment with no visible "empty → full" transition.
25
+ - **Live toggle cadence label stays in sync with toggle state.** The `.so-toggle__cadence` span now carries `aria-live="polite"` and is updated in the same synchronous tick as the `--on` class toggle. Server-side ERB hardcodes `"5s"` / `"off"` matching the JS literals.
26
+ - Jobs details page no longer crashes for `SolidQueue::FailedExecution`; Queue and Priority now fall back to underlying `SolidQueue::Job` values and show `N/A` when unavailable.
27
+ - Web UI now works on API-only Rails hosts. The engine ships its own Cookies / Session::CookieStore (`key: "_solid_observer_session"`) / Flash middleware stack, so requests routed to `/solid_observer/*` get the middleware they need regardless of whether the host app strips them via `config.api_only = true`. Previously, API-only hosts hit `NoMethodError: undefined method 'flash' for an instance of ActionDispatch::Request` rendering the dashboard layout.
28
+ - `bin/rails solid_observer:install:migrations` now respects `migrations_paths` from the `solid_observer_queue` connection in `config/database.yml`. When the host configures a dedicated migration folder (e.g. `db/solid_observer_migrate`), the install task copies migrations directly there instead of `db/migrate/`. Previously, operators in multi-database setups had to manually move the files after install to prevent cross-database migration contamination.
29
+ - Web UI now degrades gracefully when the `solid_observer_queue` database is missing or unreachable at request time. Previously, requests to `/solid_observer/*` raised `ActiveRecord::NoDatabaseError` / `ConnectionNotEstablished` with a raw 500 stack trace. The engine now renders a 503 "Storage unavailable" page using the dashboard layout, with an actionable hint to run migrations or check `database.yml`. Realtime mode is unaffected. Boot-time resilience (Engine activation skip) was already in place; this closes the equivalent gap at request time.
30
+ - Engine boot no longer requires a live DB (Docker/CI/K8s safe); table check uses `BaseEvent.connection_pool` (multi-DB safe); broader rescue covering adapter-specific connection errors
31
+ - `QueueEventBuffer` hard-caps at `max_buffer_size` with overflow strategy; uses a single persistent `Concurrent::TimerTask` instead of spawning a thread per flush
32
+ - Storage monitoring uses adapter-native size queries (SQLite / PostgreSQL / MySQL / Trilogy) — fixes `0 MB` readings off SQLite
33
+ - `EventsController` and `JobsController` filter dropdowns no longer full-table-scan on every request (cached via `filter_cache_ttl`)
34
+ - `RecordEvent` correctly handles real `ActiveJob::Base` payload objects (with hash fallback)
35
+
36
+ ### Security
37
+ - Job arguments removed from persisted event metadata and the jobs detail view (PII reduction)
38
+ - Web UI HTTP Basic Auth now requires **both** `ui_username` and `ui_password` to be configured. Previously, setting only `ui_username` (with `ui_password` missing or `nil`) would still trigger an auth challenge that any blank-password request would pass `secure_compare("", "")`, granting unauthenticated access. The README's "both must be set" guidance now matches the implementation; misconfigured auth now ships unauthenticated rather than allowing a bypass.
39
+ - Boot-time `Engine.check_ui_authentication` now warns on partial misconfiguration (exactly one of `ui_username` / `ui_password` set), naming the missing credential. Previously the check exited silently as soon as `ui_username.present?`, hiding the fail-open auth misconfiguration from operators.
40
+
41
+ ### Documentation
42
+ - Documented multi-adapter installation (PG host + SQLite observer DB) inline in Database Setup, with explicit `adapter:` override, `gem "sqlite3"` Bundler note, `migrations_paths` migration-isolation guidance, and cross-reference from the install steps.
43
+
44
+ ### Removed
45
+ - Removed the legacy implicit dashboard auto-refresh (`<meta http-equiv="refresh">` plus inline fetch/DOM-swap script for `.so-content`). Replaced by explicit, opt-in Live Mode targeting only the Right-Now frame.
46
+ - Removed the legacy `GET /solid_observer/right_now` HTML endpoint and its action template (it was the SO-060-era polling target that returned a partial-only HTML response wrapped in a turbo-frame). Replaced by `GET /solid_observer/poll_data` which returns JSON for the polling client. The `live_poll.js` script-delivery route is unchanged.
47
+ - **Removed `SolidObserver.config.ui_refresh_interval`** (was unreliable; cadence is now hardcoded at 5s). Upgrade note: remove the line from your initializer or boot will raise `NoMethodError`.
48
+
49
+ ### Changed
50
+ - Web UI controllers refactored to thin actions + query/param/presenter objects; Rails built-in number helpers replace custom ones
51
+ - Specs: `allow_any_instance_of` → `instance_double`; sleep-based timer specs use deterministic synchronisation; dead private-method `describe` blocks removed
52
+ - `.reek.yml` suppressions trimmed; hot-path services/buffer/engine methods refactored to pass `TooManyStatements` without new suppressions
53
+ - `SolidObserver.config.ui_refresh_interval` now controls Live Mode polling cadence instead of implicit full-page dashboard refresh. Default value is unchanged.
54
+ - Dashboard default range is `15m` (was `1h`); aligns with poll default.
55
+ - Live polling pauses while the tab is hidden and resumes on return (one immediate tick on visibility return so the user doesn't wait up to 5s for fresh data).
56
+ - Jobs tab default filter changed from `status=ready` to `status=all_active` (ready + scheduled + claimed + failed).
57
+ - Duration values on the Events index and detail pages now use per-event-type semantic context via `<abbr title="...">` tooltips so operators can distinguish enqueue call latency (`job_enqueued`) from perform-time duration (`job_completed` / `job_failed` / `job_discarded`).
58
+ - Refreshed the engine UI to a minimalist visual language: light surfaces, near-black text, restrained semantic colour accents reserved for badges/state, hairline separators, consistent rounding. Sidebar moves from dark slate to a light surface. No external CSS dependencies, no JS, no dark mode (single light theme).
59
+ - Dashboard: replaced the multi-line "Recent Failures" panel with a single-line **Stability** indicator (pill badge + summary + "View failures" link). Three states based on rolling failure counts: **Stable** (no failures in last 24h), **Degraded** (failures in last 24h but none in last hour), **Critical** (any failure in the last hour). Click-through targets the Events page filtered to `job_failed`.
60
+ - Dashboard: removed the "Jobs tab / Events tab" orientation banner. The distinction is discoverable via navigation; the dashboard is reserved for signal.
61
+ - Dashboard layout consolidated: dropped the previous two-frame split (Right-Now + Scoped) and the redundant Performed-in-range / Failed-in-range cards (those metrics now live in the polled sparkline strip).
62
+ - Live toggle restyled as a pill switch with cadence visible in-line ("Live · 2s" / "Live · off") and a pulsing dot when active.
63
+
1
64
  ## [0.1.1] - 2026-02-10
2
65
 
3
66
  ### Added
data/README.md CHANGED
@@ -2,33 +2,33 @@
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset=".github/solid_logo_dark.svg">
4
4
  <source media="(prefers-color-scheme: light)" srcset=".github/solid_logo_light.svg">
5
- <img alt="SolidObserver" src=".github/solid_logo_light.svg" width="250">
5
+ <img alt="SolidObserver" src=".github/solid_logo_light.svg" width="220">
6
6
  </picture>
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <strong>Observe your Solid Stack like a pro!</strong>
11
- </p>
12
-
13
- <p align="center">
14
- <a href="https://github.com/bart-oz/solid_observer/releases"><img src="https://img.shields.io/badge/version-0.1.1-blue.svg" alt="Version"></a>
10
+ <a href="https://github.com/bart-oz/solid_observer/releases"><img src="https://img.shields.io/badge/version-0.3.0-blue.svg" alt="Version"></a>
15
11
  <a href="LICENSE.txt"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
16
12
  <a href="https://github.com/bart-oz/solid_observer/actions"><img src="https://img.shields.io/badge/tests-passing-brightgreen.svg" alt="Tests"></a>
17
- <a href="https://github.com/bart-oz/solid_observer/actions"><img src="https://img.shields.io/badge/coverage-93.06%25-brightgreen.svg" alt="Coverage"></a>
13
+ <a href="https://github.com/bart-oz/solid_observer/actions"><img src="https://img.shields.io/badge/coverage-96.98%25-brightgreen.svg" alt="Coverage"></a>
18
14
  </p>
19
15
 
20
16
  ---
17
+ <p align="center">
18
+ <img src=".github/assets/dash_1.png" alt="Dashboard overview" width="700">
19
+ </p>
21
20
 
22
- SolidObserver is a production-grade observability solution for Rails 8's Solid Stack. Starting with **Solid Queue** monitoring in v0.1.0, it provides unified visibility into your background job processing with CLI tools, metrics collection, and distributed tracing support.
21
+ SolidObserver is a production-grade observability solution for Rails 8's Solid Stack. Starting with **Solid Queue** monitoring in v0.3.0, it provides unified visibility into your background job processing with a Web UI dashboard, CLI tools, metrics collection, and distributed tracing support.
23
22
 
24
- ## Features (v0.1.1)
23
+ ## Features (v0.3.0)
25
24
 
25
+ - 🖥️ **Web UI Dashboard** — Live queue stats, job browser, event log, and storage info
26
26
  - 📊 **Real-time Queue Status** — Monitor jobs across all states (ready, scheduled, claimed, failed)
27
27
  - 🔍 **Job Management CLI** — List, inspect, retry, and discard failed jobs
28
28
  - 💾 **Storage Monitoring** — Track database size and event counts
29
29
  - 🔗 **Distributed Tracing** — Correlate jobs with APM tools (Datadog, Sentry, OpenTelemetry)
30
30
  - ⚡ **High Performance** — Buffered writes, configurable sampling, minimal overhead
31
- - 🛡️ **Production Ready** — Automatic cleanup, size limits, retention policies
31
+ - 🛡️ **Production Ready** — Docker/CI/K8s safe boot, automatic cleanup, size limits, retention policies
32
32
  - 🚀 **Two Operating Modes** — Real-time (no migrations) or persistence (full event history)
33
33
 
34
34
  ## Requirements
@@ -69,7 +69,9 @@ That's it. You now have access to queue status, job listing, retry, and discard
69
69
 
70
70
  ### Persistence Mode (default)
71
71
 
72
- Store event history, metrics, and storage snapshots in a dedicated SQLite database. This gives you everything in real-time mode plus long-term event tracking, buffered writes, and retention-based cleanup.
72
+ Store event history, metrics, and storage snapshots in a dedicated observer database. This gives you everything in real-time mode plus long-term event tracking, buffered writes, and retention-based cleanup. The install generator defaults to SQLite; the database can use any Rails-supported adapter for record persistence, and storage-size monitoring is implemented for SQLite, PostgreSQL/PostGIS, MySQL, and Trilogy. See [Database Setup](#database-setup-persistence-mode) below.
73
+
74
+ > If your host app uses a different adapter than SQLite (e.g. PostgreSQL or MySQL), see [Multi-adapter setup](#multi-adapter-setup) before running these commands.
73
75
 
74
76
  ```bash
75
77
  bin/rails solid_observer:install:migrations
@@ -77,7 +79,7 @@ bin/rails db:create
77
79
  bin/rails db:migrate
78
80
  ```
79
81
 
80
- No additional configuration needed — persistence is the default `storage_mode`.
82
+ For SQLite-default apps, no further configuration is needed — persistence is the default `storage_mode`.
81
83
 
82
84
  ## Quick Start
83
85
 
@@ -134,8 +136,17 @@ bin/rails "solid_observer:jobs:retry[JOB_ID]"
134
136
  bin/rails "solid_observer:jobs:discard[JOB_ID]"
135
137
  ```
136
138
 
139
+ ### Events Page Filters (Web UI)
140
+
141
+ Filter dropdowns on `/solid_observer/events` (job class and queue) are cached for 1 minute by default and scoped to the configured retention window.
142
+ Tune the cache TTL with `config.filter_cache_ttl`.
143
+
137
144
  ### Check Storage (Persistence Mode)
138
145
 
146
+ Storage monitoring is cross-adapter: SQLite, PostgreSQL, MySQL, and Trilogy are supported.
147
+ SolidObserver uses adapter-native SQL queries to measure size (not filesystem `File.size`),
148
+ so production deployments report real values even when the database is remote.
149
+
139
150
  ```bash
140
151
  bin/rails solid_observer:storage
141
152
  ```
@@ -154,6 +165,76 @@ Configuration:
154
165
  Warning: 80% threshold
155
166
  ```
156
167
 
168
+ ## Web UI Dashboard
169
+
170
+ SolidObserver ships with a zero-dependency Web UI (no asset pipeline, no JS framework) at `/solid_observer`.
171
+
172
+ <table>
173
+ <tr>
174
+ <td align="center"><a href=".github/assets/dash_1.png"><img src=".github/assets/dash_1.png" alt="Dashboard overview" width="250"></a></td>
175
+ <td align="center"><a href=".github/assets/dash_2.png"><img src=".github/assets/dash_2.png" alt="Dashboard jobs and events" width="250"></a></td>
176
+ <td align="center"><a href=".github/assets/dash_3.png"><img src=".github/assets/dash_3.png" alt="Dashboard storage and details" width="250"></a></td>
177
+ </tr>
178
+ </table>
179
+
180
+ ### Mount
181
+
182
+ The install generator mounts it for you. To mount manually:
183
+
184
+ ```ruby
185
+ # config/routes.rb
186
+ mount SolidObserver::Engine, at: "/solid_observer"
187
+ ```
188
+
189
+ ### Configuration
190
+
191
+ ```ruby
192
+ SolidObserver.configure do |config|
193
+ config.ui_enabled = !Rails.env.production? # default: true outside production
194
+ config.ui_username = "admin" # HTTP Basic Auth: BOTH username AND password must be set
195
+ config.ui_password = ENV["SOLID_OBSERVER_PASSWORD"]
196
+ config.ui_base_controller = "ApplicationController" # name of your host app's base controller (used for API-only detection)
197
+ end
198
+ ```
199
+
200
+ | Option | Default | Purpose |
201
+ |---|---|---|
202
+ | `ui_enabled` | `!Rails.env.production?` | Master switch for the Web UI |
203
+ | `ui_username` / `ui_password` | `nil` | HTTP Basic Auth credentials. Auth is enabled only when **both** are set; if either is missing or `nil`, the UI is unauthenticated |
204
+ | `ui_base_controller` | `"ApplicationController"` | Name of your host app's base controller. SolidObserver does **not** inherit from it; the value is used to detect API-only apps so the engine can include the rendering modules its dashboard needs |
205
+
206
+ Live polling cadence is hardcoded at 5s.
207
+
208
+ ### Production hardening (recommended)
209
+
210
+ The snippet above silently disables auth if `ENV["SOLID_OBSERVER_PASSWORD"]` is unset (fail-open with a boot warning — see Caveats). For production, prefer one of these patterns so a missing env var fails loudly at boot rather than shipping an unauthenticated UI:
211
+
212
+ ```ruby
213
+ # Option A: fail at boot if the password env var is missing
214
+ SolidObserver.configure do |config|
215
+ config.ui_username = "admin"
216
+ config.ui_password = ENV.fetch("SOLID_OBSERVER_PASSWORD") # raises KeyError if unset
217
+ end
218
+
219
+ # Option B: only enable auth when the env var is present (no auth otherwise)
220
+ SolidObserver.configure do |config|
221
+ if (password = ENV["SOLID_OBSERVER_PASSWORD"]).present?
222
+ config.ui_username = "admin"
223
+ config.ui_password = password
224
+ end
225
+ end
226
+ ```
227
+
228
+ Option A is best when the UI must always be authenticated in production (a missing env var crashes boot — you find out immediately). Option B is best when the UI is optional in some environments.
229
+
230
+ ### Caveats
231
+
232
+ - **Realtime mode** (`storage_mode: :realtime`) — Events and Storage navigation links are hidden. Direct visits to `/solid_observer/events` or `/solid_observer/storage` redirect to the dashboard with a flash alert (`This page is not available in real-time mode`).
233
+ - **API-only apps** — the Web UI works in API-only Rails apps without manual configuration. SolidObserver's engine ships its own Cookies/Session/Flash middleware stack scoped to `/solid_observer/*` requests, so the dashboard renders, flash messages display, and retry/discard CSRF forms work even when the host app has `config.api_only = true`. The host app's middleware stack is not modified.
234
+ - **Custom API base controller** — if your host app's API base controller is **not** named `ApplicationController`, set `config.ui_base_controller` to its name (e.g. `"Api::BaseController"`). The engine uses this only to detect `ActionController::API` ancestry; if detected, it includes `ActionView::Layouts`, `ActionView::Rendering`, and `ActionController::RequestForgeryProtection` so layouts and CSRF forms render.
235
+ - **Host-app callbacks are not inherited.** SolidObserver does not run your host app's `before_action`s or authentication. Use `ui_username` / `ui_password` for the engine's built-in HTTP Basic Auth.
236
+ - **Auth misconfiguration is fail-open, but loud.** If you set `ui_username` but `ui_password` resolves to `nil` (e.g. an unset ENV var), the UI ships unauthenticated rather than locking everyone out — and the engine logs a `WARNING` at boot naming the missing credential. Verify both are set in production.
237
+
157
238
  ## Configuration
158
239
 
159
240
  After installation, configure SolidObserver in `config/initializers/solid_observer.rb`:
@@ -280,17 +361,54 @@ bin/rails solid_observer:storage:purge
280
361
 
281
362
  **SolidObserver works with any main application database** — PostgreSQL, MySQL, or SQLite.
282
363
 
283
- For its own monitoring data, SolidObserver uses a **separate SQLite database**. This keeps monitoring isolated from your main app and provides simple file-based storage that requires no additional infrastructure.
364
+ For its own monitoring data, the install generator defaults to a **separate SQLite database** file-based, no extra infrastructure needed. The example below is what `rails generate solid_observer:install` produces:
284
365
 
285
366
  ```yaml
286
- # config/database.yml
367
+ # config/database.yml (generator default)
287
368
  solid_observer_queue:
288
369
  <<: *default
289
- adapter: sqlite3 # Always SQLite for SolidObserver storage
370
+ adapter: sqlite3
290
371
  database: storage/<%= Rails.env %>_solid_observer_queue.sqlite3
291
372
  ```
292
373
 
293
- > **Note:** Your main app's `primary` database can be PostgreSQL, MySQL, or any Rails-supported adapter. Only the `solid_observer_queue` database needs to be SQLite.
374
+ > **Note:** SQLite is the generator default, not a requirement. The `solid_observer_queue` database can use any Rails-supported adapter for record persistence. Adapter-native **storage-size monitoring** is currently implemented for SQLite, PostgreSQL/PostGIS, MySQL, and Trilogy. On other adapters, the size query returns `nil` and the engine logs a single `[SolidObserver] Unknown adapter for DatabaseSize: …` warning — record persistence still works, but the size column on the dashboard will be empty until adapter support is added.
375
+
376
+ ### Multi-adapter setup
377
+
378
+ If your host application uses one database adapter (e.g. PostgreSQL) and you want SolidObserver to use a different adapter (e.g. SQLite — for isolation, simpler ops, or to avoid loading observability traffic onto your primary DB), keep the `solid_observer_queue` block **self-contained** — do not rely on `<<: *default`. The generator default (shown above) uses `<<: *default` with an explicit `adapter: sqlite3` override; that is safe on SQLite-primary hosts where the anchor is also SQLite. On a PostgreSQL host, merging `<<: *default` without an explicit adapter override pulls the PG adapter into the observer connection and fails at `db:create` with `PG::SyntaxError` (PG treating a SQLite file path as a database name). For multi-adapter connections, omit the merge entirely, as shown below.
379
+
380
+ ```yaml
381
+ # config/database.yml
382
+ default: &default
383
+ adapter: postgresql # host's adapter
384
+ encoding: unicode
385
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
386
+
387
+ development:
388
+ primary:
389
+ <<: *default
390
+ database: my_app_development
391
+ # ... cache / queue / cable on PG ...
392
+
393
+ solid_observer_queue:
394
+ adapter: sqlite3 # explicit override — do NOT merge *default
395
+ pool: 5
396
+ timeout: 5000
397
+ database: storage/development_solid_observer_queue.sqlite3
398
+ migrations_paths: db/solid_observer_migrate
399
+ ```
400
+
401
+ Apply the same pattern to `test:` and `production:`. For production with SQLite, ensure the `storage/` path is on persistent disk (not ephemeral container storage) — otherwise prefer PostgreSQL for the observer DB too.
402
+
403
+ **Bundler note (PG-only hosts):** if your `Gemfile` does not already include `sqlite3`, add it:
404
+
405
+ ```ruby
406
+ gem "sqlite3", "~> 2.0"
407
+ ```
408
+
409
+ then `bundle install`. SolidObserver does not declare `sqlite3` as a runtime dependency — adapter choice is yours.
410
+
411
+ **`migrations_paths` is recommended** to isolate SolidObserver's migrations from the host's primary `db/migrate/` folder. This prevents Rails from running SolidObserver's migrations against your primary database (which would create an unused `solid_observer_queue_events` table there). When `migrations_paths` is set on `solid_observer_queue`, `bin/rails solid_observer:install:migrations` copies migrations to that path automatically — no manual `mv` required.
294
412
 
295
413
  ## Roadmap
296
414
 
@@ -299,12 +417,12 @@ SolidObserver is actively developed. Here's what's coming:
299
417
  | Version | Focus | Status |
300
418
  |---------|-------|--------|
301
419
  | v0.1.0 | Solid Queue monitoring, CLI tools | ✅ Released |
302
- | v0.1.1 | Real-time mode (no migrations needed) | ✅ Current |
303
- | v0.2.0 | Web UI dashboard (vanilla HTML/CSS) | 🔜 Planned |
304
- | v0.3.0 | Solid Cache monitoring | 🔜 Planned |
305
- | v0.4.0 | Solid Cable monitoring | 🔜 Planned |
306
- | v0.5.0 | Cross-component correlation, health scores | 🔜 Planned |
307
- | v0.6.0 | Alerting & notifications | 🔜 Planned |
420
+ | v0.1.1 | Real-time mode (no migrations needed) | ✅ Released |
421
+ | v0.3.0 | Web UI dashboard + stability hardening | Current |
422
+ | v0.4.0 | Solid Cache monitoring | 🔜 Planned |
423
+ | v0.5.0 | Solid Cable monitoring | 🔜 Planned |
424
+ | v0.6.0 | Cross-component correlation, health scores | 🔜 Planned |
425
+ | v0.7.0 | Alerting & notifications | 🔜 Planned |
308
426
  | v1.0.0 | Production stable release | 🎯 Goal |
309
427
 
310
428
  See [GitHub Milestones](https://github.com/bart-oz/solid_observer/milestones) for detailed plans.
@@ -331,6 +449,19 @@ bundle exec reek
331
449
 
332
450
  ## Troubleshooting
333
451
 
452
+ ### Docker, CI, and Offline Boot
453
+
454
+ SolidObserver is designed to boot without a live database connection. During
455
+ `rails assets:precompile`, CI runs without a database service, or Kubernetes init
456
+ containers, the engine logs a single info message and skips subscriber activation:
457
+
458
+ ```text
459
+ [SolidObserver] Database not reachable at boot. Skipping subscriber activation.
460
+ ```
461
+
462
+ No monkey-patching or environment-variable workarounds are needed. Once the application
463
+ boots with a live database, the engine activates normally on the next restart.
464
+
334
465
  ### "no such table: solid_queue_ready_executions"
335
466
 
336
467
  This error means Solid Queue isn't configured to use the correct database in your environment.
@@ -347,7 +478,9 @@ config.solid_queue.connects_to = { database: { writing: :queue } }
347
478
 
348
479
  ### Multi-database setup
349
480
 
350
- SolidObserver works with Rails multi-database configurations. Here's an example with PostgreSQL as your primary database:
481
+ > **See also:** [Multi-adapter setup](#multi-adapter-setup) in the Database Setup section for the full pattern (explicit `adapter:` override, `gem "sqlite3"` Bundler note, `migrations_paths` rationale).
482
+
483
+ SolidObserver works with Rails multi-database configurations. Quick-reference example with PostgreSQL as your primary database and SQLite for SolidObserver's storage:
351
484
 
352
485
  ```yaml
353
486
  development:
@@ -355,14 +488,10 @@ development:
355
488
  adapter: postgresql
356
489
  database: myapp_development
357
490
  # ... PostgreSQL settings
358
- queue:
359
- <<: *default
360
- adapter: sqlite3
361
- database: storage/development_queue.sqlite3
362
- migrations_paths: db/queue_migrate
363
491
  solid_observer_queue:
364
492
  adapter: sqlite3
365
493
  database: storage/development_solid_observer_queue.sqlite3
494
+ migrations_paths: db/solid_observer_migrate
366
495
  ```
367
496
 
368
497
  ## Contributing