Repository navigation
feat: route feature flag config through the extension when no API key is set - #867
Open
purple4reina wants to merge 1 commit into
Open
purple4reina wants to merge 1 commit into
purple4reina wants to merge 1 commit into
Conversation
… is set When the extension is present and DD_API_KEY, DATADOG_API_KEY and DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL are all unset, set the base URL to http://127.0.0.1:8126 before dd-trace initializes, so customers who use DD_API_KEY_SECRET_ARN (or SSM/KMS) get feature flags through the extension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
More details
Existing API-key and nonblank custom-endpoint configurations retain their routing. The extension default is applied before tracer initialization only when the extension is present and those values are absent.
🤖 Bits Code Review · Commit 96326b0
This was referenced Nov 17, 2026
This branch has not been deployed
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.
Jira: SVLS-10161
Same change for Python: DataDog/datadog-lambda-python#890
What does this PR do?
In
handler.mjs, beforeinitTracer(), setsDD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL=http://127.0.0.1:8126only when all of these are true:/opt/extensions/datadog-agentexists).DD_API_KEYandDATADOG_API_KEYare both unset, empty or whitespace.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL.In every other case the wrapper changes nothing.
Motivation
dd-trace's feature flag provider needs an API key in the tracer's environment. Customers who keep the key in
DD_API_KEY_SECRET_ARN,DD_API_KEY_SSM_NAMEorDD_KMS_API_KEYgetPROVIDER_NOT_READYon every flag check (IR-63040). DataDog/datadog-lambda-extension#1510 adds a route on the extension's trace agent that fetches flag config with the key the extension resolved. The tracer uses that route only when this variable is set.Why these conditions
404, and the tracer does not fall back to the CDN. With this condition, nothing that works today can break. Customers with a key keep going straight to the CDN, and customers without one are already broken.DATADOG_API_KEYtoo: unlike dd-trace-py, dd-trace-js readsDATADOG_API_KEYas an alias ofDD_API_KEY, so those customers get flags from the CDN today. Whitespace counts as unset because dd-trace trims the key.DD_API_KEY is requirederror.The logic is in
src/utils/feature-flags.tsso it can be unit-tested.handler.mjscalls it next to the other dd-trace defaults.Gotchas reviewers should know about
404instead ofDD_API_KEY is required. Flags fail either way; only the log message changes. This can be merged before v104.handler.mjs, it does nothing for customers who calldatadog()themselves, or who preload dd-trace withNODE_OPTIONS=--require dd-trace/init.^5.136.0 || ^6.24.0. An older dd-trace bundled in the function (whichinitTracerprefers) ignores the variable.403, and the provider logs it and does not retry.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_configorDD_FEATURE_FLAGS_ENABLED=false: the base URL applies only to the agentless source, so the variable has no effect.Testing Guidelines
Unit tests in
src/utils/feature-flags.spec.tscover the extension present or absent, each API key variable set, empty or whitespace, a secret ARN only, and a base URL the customer already set.Types of Changes
Check all that apply
🤖 Generated with Claude Code