feat(eve): record the caller and accept authored instrumentation events - #507
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 0405b7c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thank you for following the naming conventions! 🙏 |
commit: |
📝 WalkthroughWalkthroughEve events now include authenticated caller identifiers. Eve instrumentation accepts custom event handlers and merges authored runtime context with evlog turn and session context, with authored keys taking precedence. ChangesEve instrumentation updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant HookSession
participant buildCaller
participant buildLineage
participant defineEvlogInstrumentation
participant UserEventHandler
participant evlogRuntimeContext
HookSession->>buildCaller: authenticated principal
buildCaller->>buildLineage: principal identifiers
buildLineage-->>HookSession: eve.caller on turn and session events
defineEvlogInstrumentation->>UserEventHandler: invoke step.started handler
UserEventHandler-->>defineEvlogInstrumentation: authored context
defineEvlogInstrumentation->>evlogRuntimeContext: tracked step input
evlogRuntimeContext-->>defineEvlogInstrumentation: evlog context or undefined
defineEvlogInstrumentation-->>UserEventHandler: merged runtime context
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/docs/content/5.use-cases/5.eve.md`:
- Line 229: Update the PostHog sentence in the instrumentation guidance to say
that PostHog links spans to the initiating user, correcting the grammar while
keeping the prose factual and plain.
In `@packages/evlog/README.md`:
- Line 599: Update packages/evlog/README.md lines 599-599 to state that
authenticated turns carry eve.caller and unauthenticated turns omit it. Update
apps/docs/content/5.use-cases/5.eve.md lines 234-238 so the example omits
caller.id or returns undefined when principalId is absent.
- Line 597: Update the documentation sentence describing the events merge
behavior near defineEvlogInstrumentation() to limit the claim specifically to
events['step.started']; clarify that authored and evlog runtime context are
merged only in the wrapped step.started handler, while other custom event
handlers pass through unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 66d90459-a924-4a65-b34c-55a829034847
📒 Files selected for processing (2)
apps/docs/content/5.use-cases/5.eve.mdpackages/evlog/README.md
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/evlog/src/eve/index.ts (1)
1516-1529: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftPreserve the
eventsAPI or publish a breaking release.
defineEvlogInstrumentation()still acceptsEvlogEveInstrumentationOptions, but the interface does not exposeeventsand the implementation installs only the built-instep.startedhandler. Existing callers cannot pass custom event callbacks through this public API.
packages/evlog/src/eve/index.ts#L1516: retain callback composition or add migration docs..changeset/eve-instrumentation-events-and-caller.md#L2: change the release type fromminortomajorif this removal is intentional.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/evlog/src/eve/index.ts` around lines 1516 - 1529, Update defineEvlogInstrumentation in packages/evlog/src/eve/index.ts to preserve the public events API: expose and forward caller-provided event callbacks while retaining the built-in step.started handler through callback composition. If removing custom events is intentional instead, update .changeset/eve-instrumentation-events-and-caller.md at line 2 to classify the release as major; otherwise no changes are required there.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/evlog/src/eve/index.ts`:
- Around line 1516-1529: Update defineEvlogInstrumentation in
packages/evlog/src/eve/index.ts to preserve the public events API: expose and
forward caller-provided event callbacks while retaining the built-in
step.started handler through callback composition. If removing custom events is
intentional instead, update .changeset/eve-instrumentation-events-and-caller.md
at line 2 to classify the release as major; otherwise no changes are required
there.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3459c412-18bd-4d39-a606-65055d54bf8e
⛔ Files ignored due to path filters (1)
packages/evlog/test/toolkit/__snapshots__/api-surface.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (5)
.changeset/eve-instrumentation-events-and-caller.mdapps/docs/content/5.use-cases/5.eve.mdpackages/evlog/README.mdpackages/evlog/src/eve/index.tspackages/evlog/test/eve.test.ts
An agent has exactly one
agent/instrumentation.ts, and other integrations want the samestep.startedslot — PostHog's links spans to the initiating user.defineEvlogInstrumentationowned that slot outright, so adopting one meant dropping the other.It now accepts
events, merged with the runtime context it contributes. evlog'sevlog.request_id/evlog.session_idare applied first, so authored keys win on a collision:Turn and session events also carry
eve.callernow:principalId,principalType,authenticator, taken from the principal eve resolved at dispatch. On a multi-user channel that is the dimension you group cost, volume and refusals by, and it was previously unreachable — the enrich hook is HTTP-shaped and exposes no path to the eve session.subjectandattributesare excluded on purpose, since a channel may put a name or an email in them.Docs
/use-cases/evegainseve.callerin the wide-event field table and a "Combine with another integration" section under the correlation guide. The package README notes both. No skill coversevlog/eve, so none needed updating.Testing
packages/evlog/test/eve.test.ts— 66 passing. Seven new cases: the merge, an authored key winning a collision, an authored context surviving outside a tracked turn, neither side contributing, the caller on the event, the caller's field set being exactly the three identifiers, and its absence without an authenticated principal.pnpm api:snapshotis unchanged.Summary by CodeRabbit