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

Enable WithScope and WithScopeAsync #2300

Closed
mattjohnsonpint opened this issue Apr 14, 2023 · 0 comments · Fixed by #2303
Closed

Enable WithScope and WithScopeAsync #2300

mattjohnsonpint opened this issue Apr 14, 2023 · 0 comments · Fixed by #2303
Assignees
Labels
Feature New feature or request

Comments

@mattjohnsonpint
Copy link
Contributor

Problem Statement

In #675, we added overloads to Capture methods to take an Action<Scope> parameter. This was good, and should remain. This is the preferred method to capture using one-off scope-based configuration.

At the same time, we decided to obsolete SentrySdk.WithScope. IMHO, this wasn't necessary, and should be undone.

Justification:

  • WithScope is still useful when many things are going to be done within a single new scope, such as adding breadcrumbs, starting a transaction, performing work that may need to capture multiple events, etc.
  • Comments on the original issue indicated some friction with the obsoletion. See Add overload to the public API to take Action<Scope> #675 (comment)
  • WithScope would be easier than PushScope + ConfigureScope for Improve guidance for .NET Worker Services #2274
  • ISentryScopeManager.WithScope wasn't obsoleted, so hub.WithScope still works. Generally, anything that works on an IHub instance should also be available statically on SentrtySdk.

Solution Brainstorm

Remove Obsolete attribute from SentrySdk.WithScope. Add some comments to suggest using Capture overloads in the original use case of only needing to configure scope for a single event.

Also, we should expand this to include WithScopeAsync. Overloads should also exist for returning values (ie: T WithScope<T> and Task<T> WithScopeAsync<T>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant