instrumentation-setuplisted
Install: claude install-skill voidcorp-core/void-harness
# instrumentation-setup
Use when setting up observability in a fresh Next.js app, OR when adding a new instrumentation tool (Sentry → +OTel, +Datadog, etc.). The pattern: ONE `instrumentation.ts` at the project root, conditionally initializes per runtime.
Composes with `harness:observability` (the doctrine: pino, structured logs, Sentry user scope). This skill is the Next-specific wiring.
## File location
```
apps/<app>/
├── instrumentation.ts # the bootstrap
├── instrumentation-node.ts # Node-runtime-specific
├── instrumentation-edge.ts # Edge-runtime-specific (optional)
└── src/
```
Next 16 auto-loads `instrumentation.ts` at server startup (both runtimes). `instrumentation-{node,edge}.ts` are convention-driven splits.
## Canonical bootstrap
```ts
// apps/web/instrumentation.ts
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./instrumentation-node');
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('./instrumentation-edge');
}
}
```
The dynamic imports keep edge bundles slim (Sentry's Node SDK doesn't ship to Edge runtime).
## Node runtime setup
```ts
// apps/web/instrumentation-node.ts
import * as Sentry from '@sentry/nextjs';
import { trace } from '@opentelemetry/api';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-