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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Local Scope Documentation #5136

Merged
merged 5 commits into from
Jun 27, 2022

Conversation

lbloder
Copy link
Collaborator

@lbloder lbloder commented Jun 10, 2022

Adapt Documentation for LocalScopes (getsentry/sentry-java#2084)

  • Include new LocalScope Mechanism for Android
  • Adapt Java Doc to show both the new and old Version of creating a LocalScope
  • Adapt Java/Kotlin Code example to better match the description
  • Split up Documentation about with-scope and callback parameter approaches

…a to include the new callback. align old code example and leave as alternative
@vercel
Copy link

vercel bot commented Jun 10, 2022

@lbloder is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@lbloder
Copy link
Collaborator Author

lbloder commented Jun 10, 2022

In order to keep the "old" version of creating a local Scope in the JavaSDK in the docs and not mess with the existing docs too much, I added 2 new Tabs to the code example. Not 100% sure if that is the way to go. What do you guys think?

All in all I'm not really satisfied with the current state of that part of the doc, because we have different ways of creating a local scope depending on the SDK.
Either we enclose the call to the captureMethods in with-scope/push-scope, which is used in the following SDKs

  • Go
  • Java (old way)
  • JavaScript
  • PHP
  • Python
  • Ruby
  • Rust

Or we add it as a function parameter to the captureMethods like in the following SDKs

  • Apple (ObjC and Swift)
  • Dart
  • .Net
  • Java
  • Unreal

The docs match the first approach, but are not 100% correct for the second one. Should we split them up and create two different doc sections based on the approach the SDK uses?

@vercel
Copy link

vercel bot commented Jun 10, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sentry-docs ✅ Ready (Inspect) Visit Preview Jun 10, 2022 at 2:07PM (UTC)


<PlatformSection notSupported={["android"]}>

The JavaSDK provides two alternative ways of configuring a local scope.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The JavaSDK provides two alternative ways of configuring a local scope.
The Java SDK provides two alternative ways of configuring a local scope.

@@ -93,7 +93,7 @@ You can also apply this configuration when unsetting a user at logout:
To learn what useful information can be associated with scopes see
[the context documentation](../context/).

<PlatformSection notSupported={["android"]}>
<PlatformSection>
Copy link
Member

Choose a reason for hiding this comment

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

This now shows the default "Local Scope" section for Android which mentions withScope a lot. Since withScope does not play nice with globalHubMode I'd say it would be better if we could add a custom text around it as well to not mention withScope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not exactly, it shows the same doc (like all SDKs), but only the code example for the callback (like dotnet). Java on the other hand has code examples for both the old and the new version.

However, as mentioned above, we do have a discrepancy in the SDKs anyways. Some use an enclosure like the original java withScope and some use a callback-based approach on the capture methods directly.

In my opinion we should have 2 Sections for LocalScope something like

  • Local Scope
  • Local Scope Callback

and show them for the relevant SDKs.

Because the current doc doesn't really make sense for all the Callback based SDKs. For Java we could show both sections in the meantime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For Java we could also show an alert that the withScope variant doesn't play well with globalHubMode

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, I'd move the current docs into a subheading and have a sibling subheading for the capture overload with callback param.

maybe like this:

## Local Scopes
### Using `withScope`
### Using Scope Callback Parameter

Warning sounds good as well.

@@ -93,7 +93,7 @@ You can also apply this configuration when unsetting a user at logout:
To learn what useful information can be associated with scopes see
[the context documentation](../context/).

<PlatformSection notSupported={["android"]}>
<PlatformSection>

## Local Scopes

Copy link
Member

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 in withScope 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 as withScope does?

https://github.com/getsentry/sentry-docs/pull/5136/files#diff-1b74f2288f1f938f1b7595fe4986f66d21eb90be88c3670334e42ca2520746d1R117-R122

Copy link
Collaborator Author

@lbloder lbloder Jun 16, 2022

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 methods

WDYT the correct behavior should be?

Copy link
Member

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

Copy link
Member

@adinauer adinauer Jun 22, 2022

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.

…hScope and scope callback parameter of capture methods
@lbloder lbloder marked this pull request as ready for review June 16, 2022 09:35
@lbloder lbloder changed the title Document new LocalScope Feature Update Local Scope Documentation Jun 16, 2022
@lbloder lbloder requested a review from adinauer June 21, 2022 06:11
called `with-scope`, `push-scope` or implemented as a function parameter on the capture methods, depending on the SDK. It's very helpful if
you only want to send data for one specific event.

<PlatformSection supported={["go", "java", "javascript", "native", "php", "python", "ruby", "rust"]}>
Copy link
Member

Choose a reason for hiding this comment

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

How did we arrive at this list of supported platforms? Is it all that have a file in src/includes/enriching-events/scopes/with-scope?

Copy link
Member

Choose a reason for hiding this comment

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

Native just has _This is not supported by the Native SDK._ shouldn't that simply be removed from the list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, went through the platforms in the with-scope folder.

Removing native sounds good to me. Will have a look if that has any implications.

Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

Thank you for doing this!

@adinauer adinauer merged commit 0a196e8 into getsentry:master Jun 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants