Skip to content

Enable WithScope and WithScopeAsync #2300

Closed

Description

@mattjohnsonpint

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

Metadata

Metadata

Labels

Feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions