Hubs/Scopes Merge 22 - Combine global, isolation and current scope#3346
Hubs/Scopes Merge 22 - Combine global, isolation and current scope#3346
Conversation
…pes-merge-2-add-scopes
…ainScopes to rootScopes
|
|
|
||
| @Override | ||
| public @NotNull Contexts getContexts() { | ||
| return new CombinedContextsView( |
There was a problem hiding this comment.
CombinedContextsView isn't totally necessary to have but it avoids constantly creating copies of Contexts.
There was a problem hiding this comment.
We should use CombinedContextsView as ScopeType.COMBINED for cross platform SDKs should get all values and calls setDevice and setOperatingSystem so handing back a copy that isn't mutable (or rather loses updates) isn't ideal. See #3375
|
|
||
| @Override | ||
| public @NotNull IScope clone() { | ||
| // TODO just return a new CombinedScopeView with forked scope? |
There was a problem hiding this comment.
We're now returning a new CombinedScopeView with forked isolation and current scope. See #3375
Performance metrics 🚀
|
| } | ||
|
|
||
| @Override | ||
| public @Nullable Device getDevice() { |
There was a problem hiding this comment.
I think we need some propagation or copy-on-write mechanism for all Scope related fields.
E.g.
val user = Sentry.getUser() // returns global scope user, as it's unset
Sentry.setUser(user) // now default scope is set to the user
user.email = "[email protected]" // both global and default scope is written toThere was a problem hiding this comment.
Hmm this should only happen if someone calls .setUser on global scope so an actual User instance is returned from CombinedScopeView and then pass that into .setUser that goes to current or isolation scope.
Can we ignore this edge case for now and address it, when it actually happens for a customer?
One solution would be to have something like CombinedContextsView for user and other fields.
There was a problem hiding this comment.
Here's an example that should avoid the problem:
lbloder
left a comment
There was a problem hiding this comment.
The two comments within Scopes.getGlobalScope() could be removed:
sentry-java/sentry/src/main/java/io/sentry/Scopes.java
Lines 584 to 588 in a474402
LGTM otherwise
#skip-changelog
📜 Description
When creating envelopes/events/transactions/... we now have to use all three scopes (global, isolation and current).
TODO: Breadcrumbs currently do not maintain insertion order across scopes. This will be adressed in a future PR.
💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps