fix(core): Fix withStreamedSpan typing error add missing exports#20124
fix(core): Fix withStreamedSpan typing error add missing exports#20124Lms24 wants to merge 3 commits intolms/feat-span-firstfrom
withStreamedSpan typing error add missing exports#20124Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Core
Deps
Other
Bug Fixes 🐛Core
Other
Internal Changes 🔧Core
Deps
Other
🤖 This preview updates automatically when you update the PR. |
withStreamedSpan typing error and export from SDKswithStreamedSpan typing error add missing exports
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 44ea531. Configure here.
| callback: ClientOptions['beforeSendSpan'], | ||
| ): callback is BeforeSendStramedSpanCallback { | ||
| return !!callback && '_streamed' in callback && !!callback._streamed; | ||
| callback: (ClientOptions['beforeSendSpan'] & { _streamed?: true }) | unknown, |
There was a problem hiding this comment.
l: is this not equivalent to callback: unknown? 🤔
mydea
left a comment
There was a problem hiding this comment.
left a tiny note but looks good to me!
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
d561aa5 to
53f5d9c
Compare

This PR makes some changes to the span streaming
beforeSendSpanimplementation:Previously
beforeSendSpanwas typed via discriminated union. While I initially thought this would work, it would break type checking for user-provided staticbeforeSendSpancallbacks because TS couldn't infer if the callback received aSpanJSONor aStreamedSpanJSON. So it defaulted tounknown. Now, we "pretend" that everybeforeSendSpancallback receives and returns aSpanJSON. Since we instruct users for span streaming to use thewithStreamedSpanhelper anyway, they will get correct typing within the wrapper function (i.e. a callback receiving and returningStreamedSpanJSON.Other changes:
withStreamedSpanhelper from every SDKwarntologthat the browserspanStreamingIntegrationautomatically setstraceLifecycle: 'stream'. This is expected behaviour and we'll instruct users to only setspanStreamingIntegrationto avoid a double-opt-in situation.