You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds span metadata to the `TransactionMetadata` type and the default value given to the `metadata` property in the `Transaction` constructor. I chose to add a property to `TransactionMetadata` rather than create a new `SpanMetadata` type/property which would live on the `Span` class because by doing the former, we don't have to worry about looping over the spans and deleting the metadata before the transaction is sent - everything in `transaction.metadata` (which becomes `event.sdkProcessingMetadata`) is already cleared when the envelope is created[1].
In order to not have to assert on its existence every time it's used, I made `spanMetadata` a required property of `TransactionMetadata`. In order to satisfy that required-ness, a few other things had to happen:
- It had to be initialized in the `Transaction` constructor. (Note that there should never be incoming span metadata because the only span at that point is the transaction itself, and its metadata can and does already live in the main `metadata` object. This means there's no need to do `span: metadata.span || {}` when initializing it. )
- The metadata passed to the constructor in the transaction context needed to become a partial (which it effectively already was, since until now all properties have been optional).
- The metadata passed to `setMetadata` similarly had to become a partial.
[1] https://github.com/getsentry/sentry-javascript/blob/8a06b16d605ca3a1fa6c9af2a701f332e39799ed/packages/core/src/envelope.ts#L86
0 commit comments