Intrumentation for Next.js Server side apps - #242
Open
Arnab28122000 wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.