fix(observability): canonicalise child-logger entity id under entityNumber#178
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThis PR establishes a canonical ChangesEntity Number Logging Correlation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Pull request overview
Canonicalizes the per-request entity identifier across webhook handlers and the workflow executor under a single entityNumber field so operators can grep one field name to reconstruct a request end-to-end, resolving the field-name drift described in issue #175.
Changes:
- Widen
createChildLoggerto accept the four canonical fields plus arbitrary extra bindings, and route 4 webhook handlers (issues,pull-request,issue-comment,review-comment) through it, replacingissueNumber/prNumberwithentityNumber. Also addentityNumberonreview.ts/review-thread.tslog lines and a flatentityNumber(alongside nestedtarget) inworkflow-executor.ts. - Update
docs/operate/observability.mdlede and Common log fields table with theentityNumberrow. - Add tests in
test/utils/logger.test.tsfor the bindings contract.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/logger.ts | Widens createChildLogger signature with & Record<string, unknown> and expands the contract docstring. |
| src/webhook/events/issues.ts | Routes labeled-handler through createChildLogger and renames issueNumber → entityNumber. |
| src/webhook/events/pull-request.ts | Same migration for pull_request.labeled (prNumber → entityNumber). |
| src/webhook/events/issue-comment.ts | Migration plus comment noting PR comments share the canonical field. |
| src/webhook/events/review-comment.ts | Migration and rename for review-comment handler. |
| src/webhook/events/review.ts | Adds entityNumber to the per-request log line. |
| src/webhook/events/review-thread.ts | Adds entityNumber to the per-request log line. |
| src/daemon/workflow-executor.ts | Adds flat entityNumber from context.entityNumber next to nested target. |
| docs/operate/observability.md | Updates lede and Common log fields table with entityNumber row. |
| test/utils/logger.test.ts | New tests for canonical bindings and extras passthrough. |
…umber Webhook event handlers hand-rolled `logger.child` with drifting entity field names (issueNumber vs prNumber), bypassing the canonical createChildLogger helper, so an operator could not grep one field name to reconstruct a request end-to-end. - Widen createChildLogger to accept the 4 required canonical fields plus arbitrary extra bindings, so handlers route through the single source of truth while keeping per-handler context (event, label, senderLogin). - Migrate issues / pull-request / issue-comment / review-comment handlers to createChildLogger emitting canonical `entityNumber`. - Add entityNumber to review.ts and review-thread.ts per-request log lines (they previously emitted no entity id). - workflow-executor.ts: add flat entityNumber alongside the nested `target` envelope (target retained). - Docs: observability.md lede + new entityNumber row in Common log fields. - Tests: assert createChildLogger binds entityNumber and passes extras through, and that drifted issueNumber/prNumber names do not leak back. No compatibility mirror or installationId: nothing consumes the old field names (grep-clean), and installationId is tracked separately as #177. Closes #175 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Resolves #175. The canonical
createChildLoggerhelper (src/logger.ts) defines the{deliveryId, owner, repo, entityNumber}correlation contract and is already used byapp.ts,core/context.ts, anddaemon/job-executor.ts— but the webhook event handlers bypassed it, hand-rollinglogger.childwith a drifting entity field name (issueNumberin issues/issue-comment,prNumberin pull-request/review-comment). An operator who knows a PR/issue number could not grep one field name to reconstruct a request end-to-end.Changes
createChildLoggerto accept the 4 required canonical fields plus arbitrary extra bindings (& Record<string, unknown>), so handlers route through the single source of truth while keeping per-handler context (event,label,senderLogin). Existing 4-field callers are unaffected (verified typecheck).issues,pull-request,issue-comment,review-comment) tocreateChildLogger, emitting canonicalentityNumber.entityNumbertoreview.tsandreview-thread.tsper-request log lines (they previously emitted no entity id), so every webhook handler with a per-request line is greppable by entity.workflow-executor.ts: add a flatentityNumberalongside the nestedtargetenvelope (target retained).entityNumberrow in the Common log fields table (documents the surviving adjacent layers: job-payloadprNumber/issueNumberand scoped-rail snake_casepr_number/issue_number).test/utils/logger.test.tsassertscreateChildLogger().bindings()carriesentityNumber, passes extras through, and that the driftedissueNumber/prNumbernames do not leak back.Verification
bun run typecheck,eslint .(0 errors),prettier --check,check:docs-citations,check:no-em-dashes→ clean.bun test test/utils/logger.test.ts→ 16 pass (2 new). Webhook/workflow-executor tests pass per-file; the combined-run 4 fail/4 error are a pre-existing cross-file test-isolation issue (identical count on cleanmain, verified by stash).Scope decisions (judgement calls)
prNumber/issueNumbercompatibility mirror. Verified grep-clean — nothing consumes those field names (no docs, dashboards, or alerts). A mirror would be tech debt + a needless follow-up. This also makes the proposedisPRdiscriminator unnecessary.installationIddescoped → tracked as feat(observability): emit installationId on per-request child loggers for per-installation quota triage #177. It is a separate correlation enhancement and interacts with installation-guard ordering; not the field-name-drift bug.ws-messages.ts/job-queue.ts/job-dispatcher.ts) untouched — theprNumber/issueNumberthere are the job-payload contract, a different layer not cited by the issue.issues.ts,pull-request.ts) and one internal-error fallback (pull-request.tsrepos.getCommit failed, retainsprNumber) are not request-correlation lines; left as-is, can fold into feat(observability): emit installationId on per-request child loggers for per-installation quota triage #177 for full uniformity.Senior-review gate: 3 iterations, converged clean (CodeRabbit unavailable this run — org out of credits — so senior-review is the quality gate).
🤖 Generated with Claude Code
Summary by CodeRabbit