feat(tracing): Allow storing span metadata #5464
Merged
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.
This adds span metadata to the
TransactionMetadata
type and the default value given to themetadata
property in theTransaction
constructor. I chose to add a property toTransactionMetadata
rather than create a newSpanMetadata
type/property which would live on theSpan
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 intransaction.metadata
(which becomesevent.sdkProcessingMetadata
) is already cleared when the envelope is created.In order to not have to assert on its existence every time it's used, I made
spanMetadata
a required property ofTransactionMetadata
. In order to satisfy that required-ness, a few other things had to happen: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 mainmetadata
object. This means there's no need to dospan: metadata.span || {}
when initializing it. )setMetadata
similarly had to become a partial.