-
Notifications
You must be signed in to change notification settings - Fork 421
Metrics not flushing #43
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
Comments
Hi @dotorg-richard - Thank you for reporting this. That doesn't seem right, and more like a bug - It's as if the metric set isn't being cleaned up. I'll try reproducing this on my end, and update here. |
It's a bug indeed - I'll create a test, and publish a patched version today. |
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]> #43
* [Sync Master] 0.7.0 release (#22) * docs: add pypi badge * fix: add missing single_metric example; test var name * chore: pypi monthly download badge * chore: fix github badge typo * feat: add docs to CI * fix: CI attempt 2 * fix: CI attempt 3 * fix: CI attempt 3 * fix: CI attempt 4 * chore: clean up CI workflows * Decorator factory Feat: Create your own middleware (#17) * feat(utils): add decorator factory * improv: use partial to reduce complexity * improv: add error handling * chore: type hint * docs: include pypi downloads badge * feat: opt in to trace each middleware that runs * improv: add initial util tests * improv: test explicit and implicit trace_execution * improv: test decorator with params * chore: linting * docs: include utilities * improv: correct tests, dec_factory only for func * improv: make util name more explicit * improv: doc trace_execution, fix casting * docs: add limitations, improve syntax * docs: use new docs syntax * fix: remove middleware decorator from libs * feat: build docs in CI * chore: linting * fix: CI python-version type * chore: remove docs CI * chore: kick CI * chore: include build badge master branch * chore: refactor naming * fix: rearrange tracing tests * improv(tracer): toggle default auto patching * feat(tracer): retrieve registered class instance * fix(Makefile): make cov target more explicit * improv(Register): support multiple classes reg. * improv(Register): inject class methods correctly * docs: add how to reutilize Tracer * improv(tracer): test auto patch method * improv: address nicolas feedback * improv: update example to reflect middleware feat * fix: metric dimension in root blob * chore: version bump Co-authored-by: heitorlessa <[email protected]> Co-authored-by: heitorlessa <[email protected]> * feat: add algolia search for docs and api ref (#39) (#40) Signed-off-by: heitorlessa <[email protected]> * fix: revert makefile build-docs-api Signed-off-by: heitorlessa <[email protected]> * fix: metric_set reuse #43 Signed-off-by: heitorlessa <[email protected]> * fix: clear metrics Signed-off-by: heitorlessa <[email protected]> * fix: update serialize_metrics helper function to use MetricManager instead of Metrics * fix: clear metrics after lambda invocation #43 Signed-off-by: heitorlessa <[email protected]> * improv: document metrics tests, remove redundants Signed-off-by: heitorlessa <[email protected]> #43 * chore: linting Signed-off-by: heitorlessa <[email protected]> * docs: add section to flush metrics manually Signed-off-by: heitorlessa <[email protected]> * docs: include EMF Json object Signed-off-by: heitorlessa <[email protected]> * chore: bump version 0.9.4 Signed-off-by: heitorlessa <[email protected]> Co-authored-by: Tom McCarthy <[email protected]>
Done - 0.9.4 is now live. Let me know if that works for you @dotorg-richard |
Thanks Heitor for being so responsive, I'm deep into a big refactor right now will get you feedback when I can afford the context switch :) |
Tested it on v0.9.5 and the fix works, the behavior is as expected. Thanks again!! |
* [Sync Master] 0.7.0 release (#22) * docs: add pypi badge * fix: add missing single_metric example; test var name * chore: pypi monthly download badge * chore: fix github badge typo * feat: add docs to CI * fix: CI attempt 2 * fix: CI attempt 3 * fix: CI attempt 3 * fix: CI attempt 4 * chore: clean up CI workflows * Decorator factory Feat: Create your own middleware (#17) * feat(utils): add decorator factory * improv: use partial to reduce complexity * improv: add error handling * chore: type hint * docs: include pypi downloads badge * feat: opt in to trace each middleware that runs * improv: add initial util tests * improv: test explicit and implicit trace_execution * improv: test decorator with params * chore: linting * docs: include utilities * improv: correct tests, dec_factory only for func * improv: make util name more explicit * improv: doc trace_execution, fix casting * docs: add limitations, improve syntax * docs: use new docs syntax * fix: remove middleware decorator from libs * feat: build docs in CI * chore: linting * fix: CI python-version type * chore: remove docs CI * chore: kick CI * chore: include build badge master branch * chore: refactor naming * fix: rearrange tracing tests * improv(tracer): toggle default auto patching * feat(tracer): retrieve registered class instance * fix(Makefile): make cov target more explicit * improv(Register): support multiple classes reg. * improv(Register): inject class methods correctly * docs: add how to reutilize Tracer * improv(tracer): test auto patch method * improv: address nicolas feedback * improv: update example to reflect middleware feat * fix: metric dimension in root blob * chore: version bump Co-authored-by: heitorlessa <[email protected]> Co-authored-by: heitorlessa <[email protected]> * feat: add algolia search for docs and api ref (#39) (#40) Signed-off-by: heitorlessa <[email protected]> * fix: revert makefile build-docs-api Signed-off-by: heitorlessa <[email protected]> * fix: metric_set reuse #43 Signed-off-by: heitorlessa <[email protected]> * fix: clear metrics Signed-off-by: heitorlessa <[email protected]> * fix: update serialize_metrics helper function to use MetricManager instead of Metrics * fix: clear metrics after lambda invocation #43 Signed-off-by: heitorlessa <[email protected]> * improv: document metrics tests, remove redundants Signed-off-by: heitorlessa <[email protected]> #43 * chore: linting Signed-off-by: heitorlessa <[email protected]> * docs: add section to flush metrics manually Signed-off-by: heitorlessa <[email protected]> * docs: include EMF Json object Signed-off-by: heitorlessa <[email protected]> * chore: bump version 0.9.4 Signed-off-by: heitorlessa <[email protected]> Co-authored-by: Tom McCarthy <[email protected]>
Using Python 3.8 and aws-lambda-powertools==0.9.1
It could be that I'm not using metrics as their design intended however I would like to make use of them in the following pattern so metrics can be consumed by classes shared across my project which are imported into my lambdas as needed (so my lambdas handlers have few lines of code) e.g.
Adding metrics to MyClass might look something like this (using randint for demo purposes obviously):
Following this pattern the desired metrics are created correctly but on subsequent executions metrics are not flushed so subsequent executions will output both a 'Success' AND a 'Failure' metric from a single execution, so the print output in logs looks like this:
Metrics are supposed to be flushed by the log_metrics decorator on each handler execution no? Would love to get your thoughts on this if it's a bug or if I'm not using them as intended.
The text was updated successfully, but these errors were encountered: