Repository navigation
refactor(nitro): dedupe the request-id gate and tail-sampling emit in the v3 plugin - #795
Merged
Merged
Conversation
… the v3 plugin The cf-ray request-id gate ran twice in plugin.ts and the tail-sampling emit sequence ran verbatim in both the response and error hooks. Extract resolveRequestId() and emitWithTailSampling() so each rule has one owner; behavior is unchanged and the pinned integration tests still pass.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Contributor
|
Thank you for following the naming conventions! 🙏 |
@evlog/cli
evlog
@evlog/nuxthub
@evlog/signals
@evlog/telemetry
commit: |
This branch was successfully deployed
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.
Summary
Two sequences in
packages/evlog/src/nitro-v3/plugin.tswere duplicated with a shared single owner available in the same file:cf-rayrequest-id gate and therequestId: override || ctx.requestId || crypto.randomUUID()expression ran in both the enabled and the globally-disabledrequesthooks. Extracted asresolveRequestId(event, ctx)._evlogStartTimeduration,TailSamplingContext,evlog:emit:keephook, plugin-runnerkeep,log.emit) ran verbatim in theresponseanderrorhooks. Extracted asemitWithTailSampling(hooks, log, event, status, ctx), mirroring the existing v2 owneremitTailSamplinginpackages/evlog/src/nitro/plugin.tsand matchingcallDrainHook's parameter shape (hence the existingmax-paramsdisable pattern).Both call sites are token-identical copies of the extracted bodies, so behavior is preserved. The nitro-v3 integration suite is the matching test: it pins the
evlog:emit:keeptail-sampling path (test/nitro-v3/nitro-v3.test.ts) and thecf-rayrequest-id (requestIdassertions in the same file).Diff shape
The two emit sequences deleted verbatim (response hook shown; the error hook copy is identical):
Net: 41 insertions, 51 deletions in one file. Found by the repo-health sweep at revision
54dcc504; confirmed by the workflow's verifier and reproduced in the sandbox.Checks
pnpm --filter evlog exec vitest run test/nitro-v3/: 5 files, 29 tests passed with the edit.pnpm run lint,pnpm run typecheck,pnpm run test: all exit 0 with the edit.AGENTS.md).ELI5
Two pieces of request-logging logic existed in two copies each inside the same file. This puts each piece in one function that both places now call, with no change in behavior. The automated tests that watch those exact log paths still pass.