void-instrumentation-setup

Configure instrumentation.ts in Next.js 16 with Sentry, OpenTelemetry, and pino across Node and Edge runtimes.

Updated May 29, 2026
One-click install
npx skills add https://github.com/voidcorp-core/void-harness --skill void-instrumentation-setup-voidcorp-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: void-instrumentation-setup
Source: https://github.com/voidcorp-core/void-harness/tree/main/packages/cli/core-assets/packs/pack-nextjs/skills/void-instrumentation-setup
Command: npx skills add https://github.com/voidcorp-core/void-harness --skill void-instrumentation-setup-voidcorp-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @sentry/nextjs, @opentelemetry/api, @opentelemetry/sdk-node, @opentelemetry/auto-instrumentations-node, @opentelemetry/exporter-trace-otlp-http.

What problem does it solve? Setting up observability in a Next.js app is error-prone: Sentry gets re-initialized per request, OpenTelemetry silently fails on the Edge runtime, and PII leaks into error events. This Skill provides the canonical wiring pattern for bootstrapping observability exactly once, split correctly across runtimes. ## Core Features & Use Cases - Runtime-split bootstrap: A single instrumentation.ts that conditionally loads instrumentation-node.ts or instrumentation-edge.ts via dynamic imports, keeping Edge bundles slim. - Sentry + OpenTelemetry + pino composition: Sentry init with environment-based sample rates and PII hashing in beforeSend, optional OTel NodeSDK with OTLP exporter, and pino logging via a shared core package. - Client-side coverage: A 'use client' SentryProvider for browser errors, since server instrumentation does not cover the client. - Use Case: When adding Datadog or OTel tracing to an existing Next.js 16 app that already has Sentry, use this Skill to extend instrumentation-node.ts without breaking the Edge runtime or duplicating initialization. ## Quick Start Set up Sentry and OpenTelemetry instrumentation for my Next.js 16 app with separate Node and Edge runtime configuration.

Frequently Asked Questions about void-instrumentation-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Sentry in a Next.js 16 app?

Create an instrumentation.ts file at the project root that dynamically imports instrumentation-node.ts or instrumentation-edge.ts based on NEXT_RUNTIME. Initialize Sentry in each runtime file with environment-based tracesSampleRate, and add a separate 'use client' SentryProvider for browser errors.

How to add OpenTelemetry tracing to Next.js instrumentation?

Initialize the OpenTelemetry NodeSDK inside instrumentation-node.ts only, using getNodeAutoInstrumentations and an OTLPTraceExporter pointed at your OTEL_EXPORTER_OTLP_ENDPOINT. Do not add OTel to the Edge runtime, since it cannot load Node native bindings and fails silently.

Does instrumentation.ts cover client-side errors in Next.js?

No, server instrumentation.ts does not cover the browser. Add a separate client-side SentryProvider component with 'use client' that calls Sentry.init once using the NEXT_PUBLIC_SENTRY_DSN environment variable, then wire it into app/layout.tsx.

Why does OpenTelemetry fail on the Next.js Edge runtime?

The Edge runtime cannot load Node native modules, write to the filesystem, or use Node Buffer outside polyfills, so OTel auto-instrumentation silently fails. Keep Edge instrumentation minimal with only Sentry init and captureMessage or addBreadcrumb calls.

How do I prevent PII from leaking into Sentry events?

Use the beforeSend hook in Sentry.init to hash or strip user.id, email, and other identifiers before events are sent. Never log raw PII, and validate that user IDs appear hashed when inspecting events in the Sentry dashboard.