Repository navigation
feat(ai): correlate ai-gateway calls with functionPath/traceId - #181
Conversation
The generated `ctx.ai` facade now threads the dispatch's `functionPath` and `traceId` into `createAi`, which folds them into the active AI Gateway's native `metadata` (and `resolveAiGateway`'s `cf-aig-metadata` header) so gateway log entries tie back to the Lunora trace. Additive and opt-in: metadata is attached only when a gateway is configured (explicit or env-derived) and never overrides a caller's own gateway metadata; unset gateways are unchanged. The emitter reads the trace under the same anchor guard the tracer uses so a deferred subscription re-run does not borrow a concurrent dispatch's trace. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
✅ Deploy Preview for lunorash ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for following the naming conventions! 🙏 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (5)
WalkthroughAI Gateway metadata types and encoding are extended for correlation fields. Gateway resolution merges metadata into active gateway options, while generated AI calls pass function paths and trace IDs into ChangesAI Gateway correlation metadata
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Generated ctx.ai
participant createAi
participant resolveGatewayOption
participant AI Gateway
Generated ctx.ai->>Generated ctx.ai: Derive functionPath and traceId
Generated ctx.ai->>createAi: Pass metadata
createAi->>resolveGatewayOption: Resolve gateway with metadata
resolveGatewayOption->>AI Gateway: Forward gateway metadata
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
Thank you for confirming the Contributor License Agreement! 🙏 |
Merging this PR will not alter performance
Comparing Footnotes
|
Sync the cloud observability + security-hardening branch with alpha (OTLP resource attributes #182, notify observability #183, do perf #184, workerd custom-spans test #180, ai-gateway correlation #181, and release bumps). Clean auto-merge — no conflicts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
Codegen picks up alpha's ai-gateway trace correlation (#181): the emitted ShardDO now threads functionPath + traceId into createAi. Matches the merged runtime; tsc validated against this output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Auto-threads
functionPath+traceIdinto the AI-Gateway call so gateway logs correlate to the Lunora trace (the #165 follow-up).buildCtx; the emit fragment threads them under the same anchor-guard the tracer uses (a deferred subscription re-run can't borrow another dispatch's trace).gateway.metadatafor Workers-AI/binding calls and thecf-aig-metadataheader for BYO providers. Additive/opt-in — attached only when a gateway resolves, never overrides a caller's own metadata.resolveGatewayOptionfolds it into both the AI-SDK model path and rawai.run().ai 119 / codegen 863 tests pass. (Follow-up commit clears pre-existing
prefer-expect-assertionsdebt in ai test files that the affected-lint surfaces.)🤖 Generated with Claude Code
Summary by CodeRabbit