Hosted Application Logging: 5 Node.js Postgres SaaS API Rollback Decisions
TL;DR: Choose a hosted searchable log store with a small, vendor-neutral Node.js contract when manual review is acceptable. For a media SaaS, the deciding constraint is rollback safety: API requests, background publication workers, and scheduled jobs must leave enough shared evidence to explain which release changed an asset and whether the rollback completed. Keep heartbeat monitoring separate,…
1. Define the rollback question before choosing the store. Failing a media release impacts multiple processes, including the API, Postgres, a worker, and a scheduled job. To formulate a clear incident review question, capture the essential details: which release affected which asset, under which trace, and what was the result? The key event data should include occurred_at, service, event, release_id, asset_id, trace_id, and outcome.
Focus on identifiers, not article content, access tokens, or customer email addresses. Note that the recommended logging solution has no deletion, export, or subscription features, and its retention settings cannot be customized. Data minimization is crucial, especially with European data residency and erasure requirements. Adopt a stable event contract early, ensuring the logging backend can change without altering the API, worker, or cron calls.
2. Should a Postgres SaaS use hosted application logging for API workers? A trace ID helps link records only if every component includes it. However, it doesn't guarantee that a scheduled task ran, nor does a list of matching log lines constitute a distributed trace or span tree. While this logging option can retain trace_id and span_id in log lines, the correlation stops there.
For silent cron failures, a separate heartbeat monitor like Healthchecks is necessary. Sentry might be a better fit if reconstructing known publication failures is crucial. Remember, a searchable store can reconstruct known failures but cannot report events that never occurred.
3. Keep the smallest implementation boring. A plain TypeScript application boundary can suffice. Emit one JSON line locally and call the hosted search route without adding undeclared filters. Use caller-provided timestamps and IDs to avoid creating fictional sequences during retries. Define an IncidentEvent interface with occurred_at, service, event, release_id, asset_id, trace_id, and outcome.
Create a LogSink interface with a write method and implement it using JsonLineSink to write JSON lines to stdout. The recordRelease function writes incident events to the sink, and the searchHostedLogs function retrieves logs from the hosted service.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.