-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
Hubs/Scopes Merge 27 - Discussions #3352
Conversation
…pes-merge-2-add-scopes
…ainScopes to rootScopes
|
@@ -99,7 +99,7 @@ allprojects { | |||
dependsOn("cleanTest") | |||
} | |||
withType<JavaCompile> { | |||
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing")) | |||
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing", "-Xlint:-try")) |
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 allows us to write:
try(ISentryLifecycleToken ignored = scopes.makeCurrent()) {
...
}
and rely on AutoClosable
to clean up scopes.
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.
👍 why do you have to disable this warning? Does it complain every time you're not using the API with a try block?
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.
It complains about not using the variable (called ignored
here) inside the try {}
block.
@@ -663,6 +663,7 @@ public void setUnknown(@Nullable Map<String, Object> unknown) { | |||
@Override | |||
@SuppressWarnings("JavaUtilDate") | |||
public int compareTo(@NotNull Breadcrumb o) { | |||
// TODO also use nano time if equal |
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.
To fix breadcrumb ordering across multiple collections when combining scopes - so we can maintain insertion order as well as possible. If this isn't good enough we might need some atomic counter we increment for each breadcrumb.
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.
Implemented in #3355
@@ -237,6 +237,7 @@ public void setTag(@NotNull String key, @NotNull String value) { | |||
|
|||
@Override | |||
public void removeTag(@NotNull String key) { | |||
// TODO should this go to all scopes? |
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.
Deleting certain things from scope can be tricky with new API since deletions might go to the wrong scope. Maybe we should just delete from all scopes. On the other hand a user might just want to shadow something temporarily so maybe deleting everywhere isn't wanted.
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.
When calling removeX on current scope where scope has been forked since adding e.g. the tag in a parent scope, the remove only removes it from the current scope, not from the parent.
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.
Good point, yeah that's tricky!
From a user perspective, I expect it to behave in-sync with setting a value, so I wouldn't remove the value from all scopes.
I'm wondering if we could treat remove<xy>()
like a set<xy>(null)
instead.
When retrieving scope values we then would need to change the behavior as well. From ~
return current.value ?: scope.value ?: global.value
To something like this ~
return if (current.isSet) {
current.value // can still be null
} else if (scope.isSet) {
scope.value
} else {
global.value
}
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.
Yeah I agree on not removing from all and making it behave the same way set
does.
Not so sure about setting null
and returning that because how do you ever unset this?
As a workaround for users actually wanting to clear certain values from all scopes, we could offer a ScopeType.ALL
where we send set
, remove
etc. to all scopes, when they run Sentry.configureScope(ScopeType.ALL) { scope -> ... }
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.
If users want to shadow something in the sense of temporarily unsetting, we'd have to use Optional
for all values I guess.
GLOBAL, | ||
|
||
// TODO do we need a combined as well so configureScope | ||
COMBINED; |
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 would allow users to use .configureScope()
and be able to access the combined view of all scopes relevant, so they can read the same way SentryClient
would.
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 use case would be relevant for reading data from the scope right?
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.
Yeah, cross platform SDKs (via InternalSentrySdk
) are the primary use case atm. I'm about to play around with this but I'm gonna need help testing cross platform SDKs after the change.
@@ -428,6 +429,7 @@ public void addBreadcrumb(final @NotNull Breadcrumb breadcrumb, final @Nullable | |||
} | |||
|
|||
private IScope getSpecificScope(final @Nullable ScopeType scopeType) { | |||
// TODO extract and reuse |
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.
move to CombinedScopeView
as well?
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.
Implemented in #3361
Performance metrics 🚀
|
getDefaultWriteScope().removeContexts(key); | ||
} | ||
|
||
private @NotNull IScope getDefaultWriteScope() { | ||
// TODO use Scopes.getSpecificScope? |
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.
Implemented in #3361
@@ -363,6 +363,7 @@ public void endSession() { | |||
} | |||
|
|||
private IScope getCombinedScopeView() { | |||
// TODO create in ctor? |
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.
Implemented in #3361
All discussions have been addressed in follow up PRs. |
#skip-changelog
📜 Description
There's a lot of open questions, we should discuss.
💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps