Skip to content
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

AWS lambda function API key verification stabilization #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kenchan0130
Copy link

@kenchan0130 kenchan0130 commented Jul 25, 2022

What does this PR do?

Support retry requesting API key verification

Motivation

In a lambda function, API requests for API Key validation sometimes fail.
API call failure is an expected event.
Therefore, I tried to stabilize the function by retrying.

CloudWatch Logs
@timestamp @message
2022-07-20 19:24:41.722 END RequestId: bd4a1909-4454-4b60-8612-bfb75a9bc758
2022-07-20 19:24:41.722 REPORT RequestId: bd4a1909-4454-4b60-8612-bfb75a9bc758 Duration: 1347.70 ms Billed Duration: 1348 ms Memory Size: 1024 MB Max Memory Used: 123 MB Init Duration: 2047.79 ms
2022-07-20 19:24:41.720 [INFO] 2022-07-20T19:24:41.720Z bd4a1909-4454-4b60-8612-bfb75a9bc758 [dd.trace_id=2154822661225323426 dd.span_id=1818091998981912450] 202 POST https://api.datadoghq.com/api/v1/distribution_points (585.6555ms)
2022-07-20 19:24:40.373 START RequestId: bd4a1909-4454-4b60-8612-bfb75a9bc758 Version: $LATEST
2022-07-20 19:24:40.373 [INFO] 2022-07-20T19:24:38.843Z Found credentials in environment variables.
2022-07-20 19:24:40.373 [INFO] 2022-07-20T19:24:40.372Z [dd.trace_id=0 dd.span_id=0] patched 1/1 modules (logging)
2022-07-20 19:15:49.128 END RequestId: b71f6377-f7e2-493f-afbe-e6afc4b3a7d6
2022-07-20 19:15:49.128 REPORT RequestId: b71f6377-f7e2-493f-afbe-e6afc4b3a7d6 Duration: 1314.66 ms Billed Duration: 1315 ms Memory Size: 1024 MB Max Memory Used: 123 MB Init Duration: 2168.51 ms
2022-07-20 19:15:49.127 [INFO] 2022-07-20T19:15:49.126Z b71f6377-f7e2-493f-afbe-e6afc4b3a7d6 [dd.trace_id=3212527782324643694 dd.span_id=6417391527933788086] 202 POST https://api.datadoghq.com/api/v1/distribution_points (586.3867ms)
2022-07-20 19:15:47.812 START RequestId: b71f6377-f7e2-493f-afbe-e6afc4b3a7d6 Version: $LATEST
2022-07-20 19:15:47.812 [INFO] 2022-07-20T19:15:46.190Z Found credentials in environment variables.
2022-07-20 19:15:47.812 [INFO] 2022-07-20T19:15:47.811Z [dd.trace_id=0 dd.span_id=0] patched 1/1 modules (logging)
2022-07-20 19:14:44.500 [ERROR] Exception: The API key is not valid. Traceback (most recent call last):   File "/var/lang/lib/python3.7/imp.py", line 234, in load_module     return load_source(name, filename, file)   File "/var/lang/lib/python3.7/imp.py", line 171, in load_source     module = _load(spec)   File "", line 696, in _load   File "", line 677, in _load_unlocked   File "", line 728, in exec_module   File "", line 219, in _call_with_frames_removed   File "/opt/python/lambda_function.py", line 67, in     raise Exception("The API key is not valid.")
2022-07-20 19:14:43.154 [INFO] 2022-07-20T19:14:43.153Z Found credentials in environment variables.
2022-07-20 19:14:42.578 END RequestId: b71f6377-f7e2-493f-afbe-e6afc4b3a7d6
2022-07-20 19:14:42.578 REPORT RequestId: b71f6377-f7e2-493f-afbe-e6afc4b3a7d6 Duration: 2602.91 ms Billed Duration: 2603 ms Memory Size: 1024 MB Max Memory Used: 47 MB

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)
  • This PR passes the unit tests
  • This PR passes the installation tests (ask a Datadog member to run the tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant