Created
February 21, 2022 18:46
-
-
Save vmarkovtsev/afb9e33f33546f6ecca6eda4240825d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sentry_span(func): | |
if asyncio.iscoroutinefunction(func): | |
@async_wraps(func) | |
async def wrapped_async_sentry_span(*args, **kwargs): | |
__tracebackhide__ = True | |
with sentry_sdk.Hub(sentry_sdk.Hub.current): | |
with sentry_sdk.start_span(op=func.__qualname__): | |
return await func(*args, **kwargs) | |
return wrapped_async_sentry_span | |
@functools.wraps(func) | |
def wrapped_sync_sentry_span(*args, **kwargs): | |
__tracebackhide__ = True | |
with sentry_sdk.start_span(op=func.__qualname__): | |
return func(*args, **kwargs) | |
return wrapped_sync_sentry_span |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment