The current context managers for starting transactions and marking spans are great. However, there have been a few cases where having decorators for transactions and spans would make code simpler to understand. For example celery tasks could be written like
@celery.task
@sentry_sdk.transaction(transaction="celery.update.user" op="job")
def update_user(user_id):
# Do things
Has less visual noise than the decorator does, and when adding/removing instrumentation the entire function doesn't change. The same idea applies to spans:
@sentry_sdk.span(description="github.fetch_users", op="github.api")
def fetch_github_users(...):
# do the api request and data transformations.
The names of the decorators in this issue are likely rubbish, but I think supporting decorators will help make adding instrumentation simpler for end users as it generates less noisy differences and reduces the amount of indentation in their code.
The current context managers for starting transactions and marking spans are great. However, there have been a few cases where having decorators for transactions and spans would make code simpler to understand. For example celery tasks could be written like
Has less visual noise than the decorator does, and when adding/removing instrumentation the entire function doesn't change. The same idea applies to spans:
The names of the decorators in this issue are likely rubbish, but I think supporting decorators will help make adding instrumentation simpler for end users as it generates less noisy differences and reduces the amount of indentation in their code.