-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: Add support for async instrumentation functions #61
Conversation
@trallnag should this be merged? |
Async support would be great |
Is this still relevant? From what I understand the new middleware implementation is async. I did not implement this, so I can't say for sure. In addition I know almost nothing about async Python. |
We use this branch at work, so it would be awesome to have it on master :) Edit: I'll try to read through the changes to make sure |
Codecov Report
@@ Coverage Diff @@
## master #61 +/- ##
==========================================
+ Coverage 93.60% 93.75% +0.14%
==========================================
Files 5 5
Lines 297 304 +7
==========================================
+ Hits 278 285 +7
Misses 19 19
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I managed to rebase your enhancement into the new middleware. I don't have any tests yet. Can you add examples on how you use I will go ahead and merge it into |
Hi, we use this feature actively. The use-case is exactly as with the non-async case: sync_metric = Info("sync_metric", "Documentation")
async_metric = Info("async_metric", "Documentation")
def sync_function(_: InstInfo) -> None:
value = sync_metric_getter()
sync_metric.info({"type": value})
async def async_function(_: InstInfo) -> None:
value = await async_metric_getter()
async_metric.info({"type": value})
instrumentator = Instrumentator()
instrumentator.add(sync_function)
instrumentator.add(async_function) This just adds the option of using |
@Skeen, thanks for the example. Adapted it into a unit test |
You're awesome, thank you for the work that you do! |
@AndreasPB, I'll release it already this weekend |
No description provided.