Observability recap
- Unified events via
ActiveSupport::Notifications:search_engine.search,search_engine.multi_search,search_engine.schema.*,indexer.*, and compile‑time summaries (joins/grouping/selection/facets/highlight/synonyms/geo/vector/hit limits). - Redaction policy ensures no secrets or raw filter literals are logged. Use
params_previewandfilter_hash. - Optional subscribers:
- LoggingSubscriber (
config.logging.mode = :compact|:json) - OpenTelemetry adapter (
config.opentelemetry.enabled = true)
- LoggingSubscriber (
DX helpers
to_params_json— redacted JSON, stable keysto_curl— one‑liner with redacted API keydry_run!— compile only; returns{ url:, body:, url_opts: }explain— extended overview (grouping, joins, presets/curation, conflicts, predicted events)
Testing offline
- Automatic offline mode:
SearchEngine.clientreturnsSearchEngine::Test::OfflineClientin test mode (Rails test orRACK_ENV=test) - Stub client:
SearchEngine::Test::StubClientfor programmable responses - Queue responses per verb and assert on captured calls (URL, redaction flags, redacted body)
- Event assertions with RSpec or Minitest helpers
- Use
SearchEngine.clientto access the configured client instance
Putting it together
Troubleshooting
- Missing events: enable subscriber/logging or OTel and wrap calls
- Redaction gaps: use
params_preview, never log raw bodies - DX helpers performing I/O: re‑check call site; helpers are pure