Skip to content

Conversation

@lobsterkatie
Copy link
Member

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.

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.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.36 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 59.92 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.93 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 52.79 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.69 KB (0%)
@sentry/browser - Webpack (minified) 64.13 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.71 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.02 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.81 KB (+0.04% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.06 KB (+0.03% 🔺)

@lobsterkatie lobsterkatie merged commit 3f94dc1 into master Jul 26, 2022
@lobsterkatie lobsterkatie deleted the kmclb-add-span-metadata branch July 26, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants