Skip to content

fix(api_gateway): fixed custom metrics issue when using debug mode #1827

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

Merged

Conversation

pawosty
Copy link
Contributor

@pawosty pawosty commented Jan 10, 2023

Issue number: #1805

Summary

Changes

Newlines are now emitted at the end of api_gateway debug JSON events. This resolves an issue where the debug events would be combined with CloudWatch EMF metrics, resulting in the metrics being ignored.

User experience

Before, if debug mode was enabled in the api_gateway router, custom EMF metrics would be appended to the end of the debug JSON in the same line in standard out. This would result in the custom metrics being ignored by the CloudWatch agent. With this change, the two JSON objects are separated by newlines and CloudWatch recognizes the metrics data and uploads it.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change? This is not a breaking change.

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Newlines are now emitted at the end of api_gateway debug JSON events.
This resolves an issue where the debug events would be combined with
CloudWatch EMF metrics, resulting in the metrics being ignored.
@pawosty pawosty requested a review from a team as a code owner January 10, 2023 19:30
@pawosty pawosty requested review from leandrodamascena and removed request for a team January 10, 2023 19:30
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 10, 2023

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 10, 2023
@github-actions github-actions bot added the bug Something isn't working label Jan 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2023

Codecov Report

Base: 97.58% // Head: 97.59% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (f2298c3) compared to base (20ca7ed).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1827   +/-   ##
========================================
  Coverage    97.58%   97.59%           
========================================
  Files          141      141           
  Lines         6425     6434    +9     
  Branches       442      444    +2     
========================================
+ Hits          6270     6279    +9     
  Misses         123      123           
  Partials        32       32           
Impacted Files Coverage Δ
aws_lambda_powertools/event_handler/api_gateway.py 100.00% <100.00%> (ø)
...ws_lambda_powertools/utilities/idempotency/base.py 100.00% <100.00%> (ø)
...bda_powertools/utilities/idempotency/exceptions.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@leandrodamascena leandrodamascena changed the title fix: api_gateway debug events now end with newlines fix(api_gateway): fixed custom metrics issue when using debug mode Jan 11, 2023
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pawosty! Great job catching and fixing this issue. Now I was able to simulate the problem with the current code this PR solves the problem.

Approved.

@leandrodamascena leandrodamascena merged commit 693fb63 into aws-powertools:develop Jan 11, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 11, 2023

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@pawosty pawosty deleted the fix/api-gateway-debug-newline branch January 11, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Custom CloudWatch metrics not always appearing for split route(s)
4 participants