Sentry
Ship structured logs to Sentry next to your errors and traces
Send logs to Sentry’s structured logs (Explore → Logs). Every meta field becomes a typed, searchable attribute, and logs link to traces through trace_id — no Sentry SDK required.
Setup
- Create (or open) a project in Sentry and copy its DSN from Settings → Projects → Client Keys (DSN).
- Set the environment variable:
SENTRY_DSN=https://your-public-key@o0.ingest.sentry.io/your-project-id
- Wire the transport:
import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'
import { createSentryTransport } from 'logixlysia/sentry'
const app = new Elysia()
.use(
logixlysia({
config: {
transports: [createSentryTransport()]
}
})
)
.get('/', () => 'ok')
.listen(3000)
- Trigger a request and open Explore → Logs in Sentry.
Environment Variables
| Variable | Required | Description |
|---|---|---|
SENTRY_DSN |
Yes | Project DSN (https://<public-key>@<host>/<project-id>) |
SENTRY_ENVIRONMENT |
No | Sets the sentry.environment attribute |
SENTRY_RELEASE |
No | Sets the sentry.release attribute |
Options
const sentry = createSentryTransport({
environment: 'production',
release: '1.4.2',
tags: { team: 'backend' }
})
| Option | Type | Default | Description |
|---|---|---|---|
dsn |
string |
SENTRY_DSN |
Project DSN |
environment |
string |
SENTRY_ENVIRONMENT |
sentry.environment attribute |
release |
string |
SENTRY_RELEASE |
sentry.release attribute |
tags |
Record<string, string> |
— | Extra attributes added to every log |
Plus the shared batching options: maxBatchSize, flushIntervalMs, timeout, retries — see the overview.
Payload
Logs post to the project’s envelope endpoint as Sentry log items:
- Body — the log message, or
GET /pathfor access logs. - Level —
DEBUG→debug,INFO→info,WARNING→warn,ERROR→error. - Attributes — meta fields flattened to typed attributes (
string,integer,double,boolean):request.method,status,durationMs,context.requestId, and anything you merge into the request context. - Trace ID — reused from
context.trace_idwhenlogixlysia/otelinjected one (linking logs to the trace), otherwise generated.
Filter in Sentry by any attribute, e.g. status:500 or context.requestId:0d5e….
Troubleshooting
401/403— the DSN was revoked or belongs to another project; copy a fresh one from Client Keys.invalid DSNat startup — the expected shape ishttps://<public-key>@<host>/<project-id>.- Logs don’t link to traces — make sure
trace_idreaches the request context vialogixlysia/otel.