mozilla-services / mozilla-services/markus
consider adding on_return and on_error transform functions to timer_decorator
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 70
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
I often want to decorate functions with timer_decorator, but want to provide different tags depending on the returned result or error.
What if we added on_return and on_error transform functions with defaults:
def on_return(tags, value, ret):
return tags, value, ret
def on_error(tags, value, exc):
return tags, value, exc
These would get called here after the function has completed:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the timer_decorator completion logic in src/markus/main.py around line 515, as linked in the issue. Review how returned values and errors are currently handled, then determine how the proposed on_return and on_error callbacks should receive and return tags, value, and result or exception. Done means both optional transforms have the stated defaults and are invoked after completion or failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100