End the Analytics Engine span when a write rejects - #201
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📝 WalkthroughWalkthroughAnalytics Engine instrumentation now wraps writes in Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Merged
This was referenced Aug 3, 2026
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.
instrumentAEFninpackages/otel-cf-workers/src/instrumentation/analytics-engine.tscalledspan.end()only on the success path, with no try/catch/finally around the wrapped call. So whenwriteDataPointrejects, the span is never ended and never exported: the operation disappears from the trace entirely and the failure leaves no trace at all, which is the opposite of what you want from a failed write. Every sibling instrumentation in the package already guards this, for exampledo-storage.tsrecords the exception, setsERROR, and ends the span in afinally.This applies that same shape here, so a rejected write now ends its span with an
exceptionevent andERRORstatus and still rethrows the original error unchanged.The instrumented behavior had no test coverage at all before this, only the attribute helper did, so I added two cases against an
InMemorySpanExporter: one for the success path and one for the rejection. The rejection test fails on current main withexpected [] to have a length of 1, which is the missing span. Ranpnpm run checkfrom the root, all green. Patch changeset for@pydantic/otel-cf-workersincluded.quick disclosure: Claude Code helped me put this together and I read the final diff myself. Freshman still learning my way around the Workers runtime, so corrections welcome :)