fix: skip unnecessary API key retrieval when Datadog extension is present#680
Merged
purple4reina merged 1 commit intoOct 21, 2025
Merged
Conversation
Move getAPIKey call to avoid unnecessary Secrets Manager calls when Datadog Lambda Extension is present, preventing Signature expired errors in provisioned concurrency environments.
11 tasks
Contributor
|
Looks good, tests are running here: #684 |
Contributor
|
Tests are all passing on the other PR. Thanks for opening this, everything looks great. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR refactors the API key retrieval logic in
MetricsListener.onStartInvocation()to skip thegetAPIKey()call when the Datadog Lambda Extension is running. The API key is now only fetched when the extension is not present, avoiding unnecessary Secrets Manager API calls.Motivation
This change addresses an issue where Lambda functions using provisioned concurrency with the Datadog Lambda Extension experience "Signature expired" errors in logs when using Secrets Manager for API key storage.
Root Cause:
DD_API_KEY_SECRET_ARNis configured and the Datadog Lambda Extension is running, the code was still callinggetAPIKey()during initializationgetAPIKey()wasn't being awaited, the Lambda instance could pause during the 3-minute period between initialization and when requests start arriving (a characteristic of provisioned concurrency)InvalidSignatureException: Signature expirederrors being loggedEnvironment where this occurs:
DD_API_KEY_SECRET_ARN(Secrets Manager)Testing Guidelines
Additional Notes
This change also highlights a broader architectural concern: async operations like
getAPIKey()should generally be awaited to prevent Lambda instances from pausing unexpectedly. While this specific fix addresses the immediate issue by avoiding unnecessary API calls when the extension is running, the underlying concern about unawaited async operations remains.Types of Changes
Check all that apply