-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): Send Baggage in Envelope Header #5104
Conversation
size-limit report 📦
|
708a608
to
40da8e7
Compare
const session = scope && scope.getSession && scope.getSession(); | ||
const session = scope && scope.getSession(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't have anything to do with baggage but it's a no longer necessary check I stumbled across. See this conversation for context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, why not use scope?.getSession()
notation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question!
It's because we try to optimize our codebase around targeting es6
. Optional Chaining is a newer JS feature, ES2020 - "ES11"
as per: https://gist.github.com/rajaramtt/7df3702a04c644b0b62c9a64f48f3dbf#64-optional-chaining. This means that it'll have to be down-compiled to es6
compatible code when we generate the final assets to distribute on npm and the CDN (this is for max browser + node version support).
Something like so:
if (hey?.me) {
console.log('me');
}
ends up getting down-compiled to:
if (hey !== null && hey !== void 0 && hey.me) {
console.log('me');
}
which is way more bytes, which is bad for bundle size.
We made a decision as a result to not use any optional chaining in code that might be used in browser environments. See some examples on bundle wins we made here: https://github.com/getsentry/sentry-javascript/pulls?q=is%3Apr+optional+chaining+is%3Aclosed+milestone%3A%22Tree+shaking+%2F+Bundle+Size%22
40da8e7
to
cf5fe65
Compare
#5066 has been merged, I think we can rebase this accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
WIP, currently a very simple and unsustainable solution that doesn't take immutability or additional data into account
In Relay we allow for arbitrary headers for forwards compatibility reasons, so I think we should be fine to send these: https://github.com/getsentry/relay/blob/7e63150f486fa6cd35db599aef6287040601f8e7/relay-server/src/envelope.rs#L705 |
0e2fe8c
to
8bcf2a6
Compare
Thanks for the review, I'll address the feedback first thing tomorrow morning. |
Ahh right, that makes sense. Then I think for now we're good. I was Just thinking that we might have to revisit this when we're adding the header to outgoing requests (due to the potential CORS problems we talked about). If we decide hide the baggage header in outgoing requests behind an experimental flag for v7, we should discuss if we want to continue sending baggage data in the envelope header when the flag is not set. Don't know what this entails in terms of consistency with traces/transactions. But this is a discussion for another time. Anyway, I implemented the suggestions and I think this should be good to get merged in. Do you wanna take another look @AbhiPrasad ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was Just thinking that we might have to revisit this when we're adding the header to outgoing requests (due to the potential CORS problems we talked about).
Yes, let’s bring this up as a TSC topic actually.
Everything else looks good for me to ship
This patch Introduces the first step of getting Dynamic Sampling working with the JS SDKs. It adds a very simple approach of attaching baggage to the envelope header of a transaction's event envelope. It does not take immutability of baggage in multiple transactions per trace scenarios into account. This is something we have to address when we're going to add the baggage header to outgoing requests. However, the simple approach should be enough to send baggage information to relay to get DS working on individual transactions.
This PR introduces the first step of getting Dynamic Sampling working with the JS SDKs. It contains a very simple approach of attaching baggage to the envelope header of a transaction's event envelope. It does not take immutability of baggage in multiple transactions per trace scenarios into account. This is something we have to address when we're going to add the baggage header to outgoing requests. However, the simple approach should be enough to send baggage information to relay to get DS working on individual transactions.
Open question which I'm happy to address in this PR or in follow-ups:
ref: https://getsentry.atlassian.net/browse/WEB-919