Skip to content

Intrumentation for Next.js Server side apps - #242

Open
Arnab28122000 wants to merge 2 commits into
mainfrom
docs/nextjs-scout-default
Open

Intrumentation for Next.js Server side apps#242
Arnab28122000 wants to merge 2 commits into
mainfrom
docs/nextjs-scout-default

Conversation

@Arnab28122000

Copy link
Copy Markdown

No description provided.

Arnab28122000 and others added 2 commits August 27, 2026 13:52
Every existing JS guide points the SDK at a collector on :4318 and puts the
OAuth2 in the collector's oauth2client extension. On a serverless host there
is nowhere to run that collector, so the app process has to hold the
credential and export OTLP itself. Nothing documented that.

New guide covers the parts that break silently when it is done by hand:

- headers passed as an async function, so a short-lived bearer refreshes per
  export instead of being frozen at exporter construction
- flush() from after(), because a frozen invocation never fires a batch timer
- provider handles on globalThis, since Next compiles instrumentation.ts into
  a different bundle from the route handlers
- delta temporality, because cold starts reset cumulative counters to zero
- NEXT_PHASE guard, so the SDK does not start during the prerender pass
- serverExternalPackages, without which the require-time patches attach to
  nothing and there is simply no telemetry

Makes it the default Next.js entry (sidebar_position 12) and relabels the
existing collector-based guide "Next.js (Collector)" at 12.7. That page keeps
its URL and title, and gains a callout pointing at the new default. Generic
"Next.js" cross-references now resolve to the new page; the two that are
specific to the collector guide's content or anchors are left alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RehmdjteyHHHnTReB5jQab
- Proxy route now ships with the guard module: per-instance rate limit,
  content-length check before and after the read, OTLP content-type
  allowlist, unconfigured short-circuit, swallowed upstream errors, 405 on
  GET. Drops the cfg! non-null assertion.
- Verify step no longer prints a bearer prefix; loads variables from
  .env.local instead of the command line.
- Adds the build-time secret check (no NEXT_PUBLIC_ in telemetry code, no
  secret literal in .next/static) and a note that the token is never logged.
- Corrects after() stability to Next.js 15.1.
- Removes an unused export from the pipeline module.
- Index row says route handlers, not server actions.

Every TypeScript snippet in the guide typechecks under strict against the
package versions in the compatibility matrix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RehmdjteyHHHnTReB5jQab
@Arnab28122000
Arnab28122000 requested a review from irfn August 27, 2026 08:47
@Arnab28122000 Arnab28122000 assigned irfn and unassigned irfn Aug 27, 2026
@Arnab28122000
Arnab28122000 requested review from nilakanta and removed request for irfn August 27, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants