Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coroutines exception handler #1886

Closed
wants to merge 4 commits into from
Closed

Conversation

marandaneto
Copy link
Contributor

馃摐 Description

馃挕 Motivation and Context

Closes #1524

馃挌 How did you test it?

馃摑 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

馃敭 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2022

Fails
馃毇 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- Coroutines exception handler ([#1886](https://github.com/getsentry/sentry-java/pull/1886))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 馃毇 dangerJS against cebbf5b

@bruno-garcia
Copy link
Member

Would be good to add an example here: https://docs.sentry.io/platforms/java/enriching-events/scopes/#kotlin-coroutines

public class SentryCoroutineExceptionHandler(private val hub: IHub = HubAdapter.getInstance()) : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler {
public constructor() : this(HubAdapter.getInstance())

override fun handleException(context: CoroutineContext, exception: Throwable) {
Copy link
Member

@romtsn romtsn Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should check if (context is SentryContext) and use the hub instance from there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HubAdapter always forwards to Sentry static class, it'd not make any difference.

* Sentry exception handler element for [CoroutineExceptionHandler].
*/
@ApiStatus.Experimental
public class SentryCoroutineExceptionHandler(private val hub: IHub = HubAdapter.getInstance()) : AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it open for inheritance? If I have my custom exception handler I'd want to have mine on top of Sentry's, or we advise delegating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea, other integrations had to make it open because of that.

@marandaneto
Copy link
Contributor Author

Outdated, a new PR would make more sense.

@marandaneto marandaneto closed this Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SentryCoroutineExceptionHandler锘�
3 participants