Skip to content

fix(next): thread redact through createInstrumentation().register()#442

Open
lichterspiel wants to merge 1 commit into
HugoRCD:mainfrom
lichterspiel:fix/next-instrumentation-redact
Open

fix(next): thread redact through createInstrumentation().register()#442
lichterspiel wants to merge 1 commit into
HugoRCD:mainfrom
lichterspiel:fix/next-instrumentation-redact

Conversation

@lichterspiel

@lichterspiel lichterspiel commented Jul 23, 2026

Copy link
Copy Markdown

🔗 Linked issue

Resolves #441

📚 Description

register() in next/instrumentation-create.ts re-initialises the global logger without threading options.redact and then calls lockLogger() — so with the documented Next.js setup (createEvlog({ redact }) + the instrumentation module loading at boot), redaction configured at import is silently wiped once register() runs, and errors reach drains unredacted.

Next-only: the handler path threads redact since #409, and both nitro plugins pass it — this was the last init path missing it.

Changes:

  • redact added to InstrumentationOptions (same boolean | RedactConfig shape as NextEvlogOptions; raw pass-through like the handler path — the logger resolves it internally).
  • Threaded in register()'s initLogger call.
  • Regression test on the existing initLogger spy (fails on main).
  • Changeset (patch).

vitest run test/next/instrumentation.test.ts → 24/24; pnpm --filter evlog run build clean.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Added support for configuring automatic PII redaction in Next.js instrumentation via a new redact option (boolean or custom config).
  • Bug Fixes

    • Fixed an issue where the configured redact settings were not honored during instrumentation registration, resulting in redaction being silently ignored.
  • Tests

    • Added a regression test to confirm custom redaction paths are correctly applied when instrumentation is registered.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@lichterspiel is attempting to deploy a commit to the HRCD Projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the bug Something isn't working label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Next instrumentation now accepts redact in InstrumentationOptions and forwards it during register() logger initialization. A regression test verifies propagation, and a Changesets entry records the patch release.

Changes

Next instrumentation redaction

Layer / File(s) Summary
Redaction option contract
packages/evlog/src/next/instrumentation-create.ts
Adds the optional redact option using boolean | RedactConfig and documents its behavior.
Register redaction forwarding
packages/evlog/src/next/instrumentation-create.ts, packages/evlog/test/next/instrumentation.test.ts, .changeset/fix-next-instrumentation-redact.md
Passes options.redact to initLogger, tests the forwarded configuration, and records a fix(next) patch release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • HugoRCD/evlog#409: Wires redaction into another Next.js logger initialization path.
  • HugoRCD/evlog#380: Modifies Next.js instrumentation option handling and registration behavior.

Suggested reviewers: hugorcd

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes address #441 by threading redact through register(), adding the option type, and covering it with a regression test.
Out of Scope Changes check ✅ Passed The changeset, type update, and test are all directly tied to the documented Next.js redact fix.
Title check ✅ Passed The title follows conventional commits and clearly summarizes the main change to Next.js instrumentation redaction.
Description check ✅ Passed The description includes the linked issue, problem statement, change summary, tests, build result, and checklist items.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lichterspiel
lichterspiel force-pushed the fix/next-instrumentation-redact branch 4 times, most recently from 2da5f87 to 154b0f5 Compare July 23, 2026 12:11
register() re-initialised the global logger without threading options.redact
and then locked it, clobbering the redact config createEvlog applied at
import — silently disabling redaction for the documented Next.js
instrumentation setup. Next-only: the handler path (HugoRCD#409) and both nitro
plugins already thread it.

Adds the redact option to InstrumentationOptions (matching the handler
path's raw pass-through; the logger resolves it internally) and a
regression test on the initLogger spy.
@lichterspiel
lichterspiel force-pushed the fix/next-instrumentation-redact branch from 154b0f5 to 274ae35 Compare July 23, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(next): instrumentation register() drops redact and locks the logger, silently disabling createEvlog({ redact })

1 participant