Observability

Logs, request ids, traces and errors, and what never gets logged.

Logs

The api and the Next servers log json lines through @ritorno/logger (one readable line in dev). console.* calls are routed through the same logger.

Before a line is written, every field passes the redaction:

  • keys that look like a secret (password, token, authorization, cookie, api key, session, dsn) are replaced with [redacted]
  • keys that look like guest data (phone, mobile, whatsapp, email, name, firstName, fullName, ...) are replaced with [redacted]
  • email addresses and phone numbers (international +216 20 123 456 or 00216..., and Tunisian local 20 123 456, 20.123.456, 20123456) inside any string, including error messages and stacks, are masked
  • a database query error is logged as its class and Postgres code only ({ name: "DrizzleQueryError", code: "23505" }), since its message and params hold the row being written

Log the guest id and the hotel id, never the guest. If a new field carries personal data under another key name, add it to PII_KEY in packages/logger/src/redact.ts and a case to its test.

Request ids

The api gives every request an id, the inbound x-request-id when it is short and plain, a new uuid otherwise. Every log line written while the request runs carries it as requestId, and the response returns it in the x-request-id header. A guest or hotel reporting a problem can send that header value to find the whole request.

Traces and logs: OpenObserve

Set these in .env (all optional, empty means off):

KeyWhat it is
OPENOBSERVE_URLbase url of your OpenObserve
OPENOBSERVE_ORGorganization, default unless you changed it
OPENOBSERVE_USER, OPENOBSERVE_PASSWORDthe ingest user

Log lines carry trace_id and span_id, so a log line links to its trace and back.

Errors: GlitchTip

KeyWhat it is
GLITCHTIP_DSNdsn of the api project, from the GlitchTip project settings
NEXT_PUBLIC_GLITCHTIP_DSNdsn of the browser project

GlitchTip speaks the sentry protocol, so the sentry sdk is used as is. Errors are tagged with DEPLOY_ENV, so staging and previews stay apart from production. See The Keep for where both run.

On the public site (apps/web/instrumentation-client.ts) the browser sdk is about 150 KB gzipped, so it is imported only when NEXT_PUBLIC_GLITCHTIP_DSN is set and only once the page is idle. Errors thrown before that are not reported.

The api and the worker both init sentry with a beforeSend (apps/api/src/sentry.ts) that drops the params: part of query errors, masks phone and email shaped text, redacts extra and breadcrumb data and drops request bodies, headers and cookies.

Failed jobs

A job that throws is logged as job failed with its name and id, and sent to GlitchTip as job <name> failed tagged job and jobId, never with its payload or the raw error. pg-boss then retries it under the job's retry policy. To see what went wrong, look the job up by id in the pgboss schema.

On this page