Right now, we have a lot of APIs tailored to our SpanJSON type, which reflects the child span protocol in transactions. When span streaming becomes the default, we should adjust our public API to reflect the StreamedSpan type.
This is a breaking change, as some fields have been renamed or removed/added newly in the respective types.
I propose we make these changes:
beforeSendSpan callback will emit a StreamedSpanJSON
- To ensure a compatibiltiy path with the transaction fallback, we can export a
withTransactionSpan helper, users that users wrap their callback in. This is exactly how the callback today is made compatible with span streaming but flipped once span streaming becomes the default.
spanToJson will emit a StreamedSpanJSON(this is mostly internally used but it's publicly exported)
- This ensures the default experience for anyone using
spanToJSON matches the type of beforeSendSpan to only confront users with one PoJo span type. Internally, it should also help us write span-streaming-native code.
- For us, we'll need a
spanToLegacyJSON (naming TBD) which we can expose in transaction code paths (event processors, beforeSendTransaction, etc). Maybe we can avoid exporting this from packages other than core, since it will go away once we remove transcations in v12. Ideally, we work with the new spanToJSON in as many places as possible but this remains TBD.
TBD for v12: We could rename StreamedSpanJSON to SpanJSON for a more concise and intuitive name, since at this point, transactions and legacy child spans will be gone.
Right now, we have a lot of APIs tailored to our
SpanJSONtype, which reflects the child span protocol in transactions. When span streaming becomes the default, we should adjust our public API to reflect theStreamedSpantype.This is a breaking change, as some fields have been renamed or removed/added newly in the respective types.
I propose we make these changes:
beforeSendSpancallback will emit aStreamedSpanJSONwithTransactionSpanhelper, users that users wrap their callback in. This is exactly how the callback today is made compatible with span streaming but flipped once span streaming becomes the default.spanToJsonwill emit aStreamedSpanJSON(this is mostly internally used but it's publicly exported)spanToJSONmatches the type ofbeforeSendSpanto only confront users with one PoJo span type. Internally, it should also help us write span-streaming-native code.spanToLegacyJSON(naming TBD) which we can expose in transaction code paths (event processors, beforeSendTransaction, etc). Maybe we can avoid exporting this from packages other than core, since it will go away once we remove transcations in v12. Ideally, we work with the newspanToJSONin as many places as possible but this remains TBD.TBD for v12: We could rename
StreamedSpanJSONtoSpanJSONfor a more concise and intuitive name, since at this point, transactions and legacy child spans will be gone.