Would be helpful to have function decorators for transactions and spans
See original GitHub issueThe 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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Primer on Python Decorators
In this tutorial on decorators, we'll look at what they are and how to create and use them. Decorators provide a simple syntax...
Read more >Custom instrumentation for Elixir | AppSignal documentation
Decorators decorator module, it's possible add custom instrumentation to your Elixir applications without changing the functions' contents. Transaction events.
Read more >Instrument a custom method to get deep visibility into your ...
In Java, Datadog APM allows you to instrument your code to generate custom spans—either by using method decorators, or by instrumenting specific code...
Read more >Instrumenting custom code | APM Python Agent Reference [6.x]
Creating Additional Spans in a Transactionedit ... elasticapm.capture_span can be used either as a decorator or as a context manager.
Read more >OpenTelemetry NodeJS | Lightstep Blog
Apply this walkthrough to your application, and you are good to go. ... Once you have a tracer, you can use it to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have been using those decorators in production on a Python 3.8 FastAPI app for a few months now and they seem to get the job done.
I would be willing to push the PR to the finish line (linting, unit tests) but would prefer to get feedback first. @untitaker any thoughts?
Yup, has been brought up a couple times. I feel like we may only want this for spans for now.
For transactions I feel like the decorator could push a scope and set an error boundary at the same time as well
On Mon, Jul 13, 2020, 21:52 Mark Story notifications@github.com wrote: