-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update Local Scope Documentation #5136
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29f4570
add local scope doc to Android Platform, adapt LocalScope doc for Jav…
lbloder 5f8f0d2
Update local scope documentation. Differentiate between withScope/pus…
lbloder 715fa08
Merge branch 'master' into feat/java-local-scope
lbloder 12e870a
CR remove local scope section from native, as it is not supported. Re…
lbloder e85f78b
Merge branch 'getsentry:master' into feat/java-local-scope
lbloder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
src/includes/enriching-events/scopes/scope-callback-param/java.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
```java {tabTitle: Java} | ||
import io.sentry.Sentry; | ||
import io.sentry.SentryLevel; | ||
|
||
// will be tagged with my-tag="my value" | ||
Sentry.captureException(new Exception("my error"), scope -> { | ||
scope.setTag("my-tag", "my value"); | ||
scope.setLevel(SentryLevel.WARNING); | ||
}); | ||
|
||
// will not be tagged with my-tag | ||
Sentry.captureException(new Exception("my error")); | ||
``` | ||
|
||
```kotlin {tabTitle: Kotlin} | ||
import io.sentry.Sentry | ||
import io.sentry.SentryLevel | ||
|
||
// will be tagged with my-tag="my value" | ||
Sentry.captureException(Exception("my error")) { scope -> | ||
scope.setTag("my-tag", "my value") | ||
scope.level = SentryLevel.WARNING | ||
} | ||
|
||
// will not be tagged with my-tag | ||
Sentry.captureException(Exception("my error")) | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
<PlatformSection notSupported={["android"]}> | ||
|
||
```java {tabTitle: Java} | ||
import io.sentry.Sentry; | ||
import io.sentry.SentryLevel; | ||
|
||
Sentry.withScope(scope -> { | ||
scope.setLevel(SentryLevel.FATAL); | ||
scope.setTransaction("main"); | ||
scope.setTag("my-tag", "my value"); | ||
scope.setLevel(SentryLevel.WARNING); | ||
|
||
// This message includes the dataset to the scope in this block: | ||
Sentry.captureMessage("Fatal message!"); | ||
// will be tagged with my-tag="my value" | ||
Sentry.captureException(new Exception("my error")); | ||
}); | ||
|
||
// will not be tagged with my-tag | ||
Sentry.captureException(new Exception("my error")); | ||
``` | ||
|
||
```kotlin {tabTitle: Kotlin} | ||
import io.sentry.Sentry | ||
import io.sentry.SentryLevel | ||
|
||
Sentry.withScope { scope -> | ||
scope.level = SentryLevel.FATAL | ||
scope.setTransaction("main") | ||
scope.setTag("my-tag", "my value") | ||
scope.level = SentryLevel.WARNING | ||
|
||
// This message includes the dataset to the scope in this block: | ||
Sentry.captureMessage("Fatal message!") | ||
// will be tagged with my-tag="my value" | ||
Sentry.captureException(Exception("my error")) | ||
} | ||
|
||
// will not be tagged with my-tag | ||
Sentry.captureException(Exception("my error")) | ||
``` | ||
|
||
<Alert level="info" title="Important"> | ||
|
||
In the Java SDK `with-scope` does **not** work reliably in `globalHubMode` as the `scope` gets pushed on the stack global to the hub. In `globalHubMode` use the callback parameter of the capture methods detailed below. | ||
|
||
</Alert> | ||
|
||
</PlatformSection> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Further down is an
<Alert>
explaining that exceptions inwithScope
will be ignored. If I'm not mistaken, the new local scope overloads don't behave the same way. I think they should. Can we please update the implementation to catch Exceptions aswithScope
does?https://github.com/getsentry/sentry-docs/pull/5136/files#diff-1b74f2288f1f938f1b7595fe4986f66d21eb90be88c3670334e42ca2520746d1R117-R122
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.
Well, we do have a bit of a discrepancy between the SDKs that use the callback parameter in this case: cocoa and dart don't capture exceptions that are thrown within the callback, while dotnet and java do because they invoke the callback within the try/catch of the respective
capture
methodsWDYT the correct behavior should be?
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'll try to clarify
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've created this getsentry/sentry-java#2123 to keep track of it. It's not blocking this PR just noticed this here and didn't wanna drop it.