-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: Custom CloudWatch metrics not always appearing for split route(s) #1805
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
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @pawosty! Thank you for opening this issue and letting us know about a possible issue. I inspected the code and tried to simulate this problem here and I couldn't. I don't know if I'm missing something specific you're doing, but I tried to create an example similar to what you did and I got the expected behavior: all metrics were sent to CloudWatch. I created a project using sam cli and pushed it to a github repository (https://github.com/leandrodamascena/custom-metrics-example). You can look at the code I made to try to reproduce the problem and see if there is something different in your environment that I should adjust here to reproduce the problem. Below are screenshots of the tests I performed. Thank you. |
Thanks for looking into this! I have noticed that I have lambda context data appearing twice, once as a log item as you do, and then a second time clobbered with the metrics data, so I think there might be a dependency interfering. I'll try to get to the bottom of this and confirm. |
|
Thanks for reply. Let me know if I can help in any way to detect if this is indeed a bug in Powertools. If so, we are fully interested in fixing it. |
Ok, I believe I found the issue. The extra JSON appearing in the logs was because I had "debug" enabled on the APIGatewayResolver object, causing this line to be executed:
This gets combined with the metrics output and then ignored by CloudWatch metrics. A member on our team was able to confirm setting debug mode to FALSE results in metrics appearing as expected. I'm not sure why this specific print behaves this way, maybe because a newline is being omitted? Regardless I think it's an unexpected interaction. |
|
This is now released under 2.6.0 version! |
Expected Behaviour
When uploading a custom metric using the
aws_lambda_powertools.metrics
package, the metrics should appear in CloudWatch Metrics.Current Behaviour
Metrics appear intermittently and appear to be tied to whether a lambda was cold started (and also had a cold start metric uploaded).
Code snippet
Possible Solution
When examining the cloudwatch logs, the unsuccessful metrics appear in the same log line as the tracer log, for example:
When successful metrics appear (such as when they are uploaded as part of a cold start), they appear in their own log line in CloudWatch and are presumably parsed.
Steps to Reproduce
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.6
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: