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

DeprecationWarning: sentry_sdk.configure_scope is deprecated #94

Closed
williamjamir opened this issue Aug 8, 2024 · 3 comments
Closed

Comments

@williamjamir
Copy link

Hi,

Looks like the sentry_sdk is deprecating the configure_scope used here: https://github.com/snok/asgi-correlation-id/blob/main/asgi_correlation_id/extensions/sentry.py#L27

https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring

Should this lib use the get_current_scope , or should it be a transaction thing, and should we use get_isolation_scope?
I'm seeing the following logs:

/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/asgi_correlation_id/extensions/sentry.py:27: in set_transaction_id
    with configure_scope() as scope:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

callback = None

    def configure_scope(  # noqa: F811
        callback=None,  # type: Optional[Callable[[Scope], None]]
    ):
        # type: (...) -> Optional[ContextManager[Scope]]
        """
        Reconfigures the scope.
    
        :param callback: If provided, call the callback with the current scope.
    
        :returns: If no callback is provided, returns a context manager that returns the scope.
        """
>       warnings.warn(
            "sentry_sdk.configure_scope is deprecated and will be removed in the next major version. "
            "Please consult our migration guide to learn how to migrate to the new API: "
            "https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring",
            DeprecationWarning,
            stacklevel=2,
        )
E       DeprecationWarning: sentry_sdk.configure_scope is deprecated and will be removed in the next major version. Please consult our migration guide to learn how to migrate to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring
@sondrelg
Copy link
Member

sondrelg commented Aug 8, 2024

This description of an isolation scope seems to suggest that we should possibly use that

The isolation scope follows a single basic unit of your program, such as a single request-response cycle or one task in a task queue, and holds data pertaining to it. In most cases, the lifecycle of an isolation scope maps to the lifecycle of a transaction.

Would you be interested in creating a PR for fixing this? I guess we should do some form of version checking of the package to determine which API to use, to keep backwards compatibility.

@JonasKs
Copy link
Member

JonasKs commented Aug 8, 2024

Please also see snok/django-guid#129

@sondrelg
Copy link
Member

sondrelg commented Sep 2, 2024

v4.3.3 should be out any second 🙂 Thanks for the report and PR!

@sondrelg sondrelg closed this as completed Sep 2, 2024
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

No branches or pull requests

3 participants