# Monitor a Node.js app with Lampwick

> Send requests, queries, errors and pino logs from a Node.js app to Lampwick with the OpenTelemetry auto-instrumentations. No code changes.

Node.js apps send to Lampwick through OpenTelemetry. The auto-instrumentations patch `http`, Express, `pg` and more when Node starts, so your code stays as it is. We tested it with Express 5, `pg` and pino on Node.js 26.

## What you get

- **Requests**, grouped by route, such as `GET /orders/:id`.
- **Queries**, linked to the request they ran in.
- **Issues** from unhandled errors, with the stack trace, counted once per request.
- **Logs** from pino, winston or bunyan, linked to their request.

## Set it up

```bash
npm install @opentelemetry/api @opentelemetry/auto-instrumentations-node
```

Set these in the app's environment:

```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=https://app.lampwick.dev
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS=x-lampwick-token=YOUR_PROJECT_TOKEN
export OTEL_SERVICE_NAME=my-app
export OTEL_METRICS_EXPORTER=none
export OTEL_LOGS_EXPORTER=otlp
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
```

`YOUR_PROJECT_TOKEN` is the project's ingest token, from the **Connect your app** card on its **Settings** page. `NODE_OPTIONS` loads the instrumentation before your app's code. Start the app as usual; requests show up within about 5 seconds.

## What it doesn't do

- **`console.log` isn't sent.** Only pino, winston and bunyan are captured.
- **Errors you catch yourself** become issues only when you record them on the span: `trace.getActiveSpan()?.recordException(err)`.
- **Bundled code**: source maps aren't applied, so stack traces name the files Node runs.

## Let your agent do it

```text
Add OpenTelemetry to this Node.js app so it reports to Lampwick: follow https://lampwick.dev/docs/node.md exactly (zero-code setup, environment variables, no code changes besides a pino logger if the app has no logger). Read the ingest token from the environment, never commit it.
```

## Next step

The [Node.js docs](/docs/node/) have the app we tested, what showed up and the troubleshooting table. How spans map to Lampwick: [OpenTelemetry](/docs/opentelemetry/#what-shows-up-where).
