-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
fix: event SDK info should depend on the configured options #1853
Conversation
a9245fb
to
c53b221
Compare
Codecov Report
@@ Coverage Diff @@
## master #1853 +/- ##
==========================================
+ Coverage 92.13% 92.21% +0.07%
==========================================
Files 200 200
Lines 9450 9464 +14
==========================================
+ Hits 8707 8727 +20
+ Misses 743 737 -6
Continue to review full report at Codecov.
|
} | ||
|
||
event.sdk = @{ | ||
@"name" : self.options.sdkInfo.name, |
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.
The value from SentryMeta is added to envelope headers so Relay can also know what SDK is sending the data to its backend. This can help us troubleshoot issues where one SDK is sending bad data.
Ideally we find a way to change that value and affect all corners of the SDK, instead of reporting a different value here and on the envelope header, for example.
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.
Ideally we find a way to change that value and affect all corners of the SDK, instead of reporting a different value here and on the envelope header, for example.
I completely agree and I've had another look and updated all code paths from the actual SDK code (at least I think I've done all of them). The remaining call paths are either from test code or public APIs that I can't touch without breaking changes.
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.
Would be nice to add/update tests to verify the configured SDK override is actually propagated to events and envelopes, but I really don't know which test would be a good candidate to update. Maybe someone from the maintainers could have a look and make the change, or at least point me to the appropriate test case.
e5b13e7
to
aeaa554
Compare
You discovered a flaw in our SDK that is not easy to fix 😁. sentry-cocoa/Sources/Sentry/SentryEnvelope.m Lines 18 to 44 in 4ec83c3
The initializers of We can't get rid of the initializers using Option A Option B What do you think @vaind, @bruno-garcia, and @brustolin? |
Thanks for the wrapup - yes, that's what I've gathered when working on this PR.
The necessary initializers are already there and, after the changes in this PR, in use for all events & envelopes created by the SDK (to the best of my knowledge). There're a lot of test-cases that manually initialize the Envelope/Header and don't use the So yes, a breaking change (Option A) is necessary if we want to make sure users don't manually create envelopes without providing the SDK info. Other than that, for normal use-cases where users just report events/trasactions/etc, this PR should cover the necessary code paths without being a breaking change. So my suggestion would be to go now with this non-breaking change of using the right APIs internally. Can you maybe suggest/add a test case that would check that the configured options SDK info is correctly passed to captured events, transactions, user feedback & their envelopes? I think that's all that would be needed to land this change. |
Most users shouldn't have to use There is no good test case yet to ensure that the right SDKInfo is passed to captured events, and transactions because this information was previously static. Every envelope got the info from SentryMeta. Ensuring that we only call the new constructors with the right SDKInfo is the best test I can think of. Then we can add a few tests for |
I'd be happy if you could take over the test cases because I'm not an objective-c/swift developer. |
Sure, how urgently do you need this, @vaind? |
@bruno-garcia can answer that. Also, just from the functional perspective, it would be OK to review & merge the code changes in this PR and add tests, which require a bit more work, in a follow-up one, if you don't have time in the near future. Of course, that's technical-debt accumulation. |
I'm not too worried about the tests, just a few should be fine, but this could be a refactoring touching multiple places in the code. I just need a couple of hours to get this done, I think. |
I was just saying that the existing code in the PR already does all that's needed (as tested manually in sentry-unity) to the best of my knowledge. And there are no breaking changes |
That's true. Let's merge this and I create an issue to properly fix this. |
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.
LGTM 🚀
📜 Description
So this is yet another follow up to setting SDK info through options (related to #1793 and #1816). I've incorrectly assumed the option is actually being used... turns out it's not and other parts of the code still use
SentryMeta.sdkName/version
directly. This PR is the minimum fix (with some minor performance-related refactoring of thesetSdk(event)
on the go).There are other places where SentryMeta is used and IMO shouldn't, most importantly a couple of times inSentryEnvelopeHeader
- I could have a look at that one too if needed, but this PR seems to already get the right info to sentry.io💡 Motivation and Context
So the events actually show up in the UI with the right SDK.
💚 How did you test it?
Manually. Is there a test case I should update?
📝 Checklist
🔮 Next steps