Repository navigation
[SVLS-10161] feat: route feature flag config through the extension when no API key is set - #1522
purple4reina wants to merge 2 commits into
Conversation
…en no API key is set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
dd-trace-js reads DATADOG_API_KEY as an alias of DD_API_KEY, and Node uses this wrapper for AppSec. The extension does not read that variable, so routing those customers through it would break flags that work today. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the wrapper’s conditional feature-flag proxy configuration.
No open issues 🎉
What changed in this PR
Updates the Lambda runtime wrapper to route feature flag configuration requests through the extension’s existing proxy when no supported API key environment variable contains a non-whitespace value. This lets tracers use the API key resolved by the extension.
Changes:
- Checks all six API key environment variables supported by Java before setting the default.
- Defaults the feature flag base URL to
http://127.0.0.1:8126, preserving any non-empty customer override.
| File | Description |
|---|---|
scripts/datadog_wrapper |
Adds conditional feature flag proxy configuration for runtimes using the wrapper. |
Review effort: Balanced
| # extension, which adds the key it resolved (e.g. from DD_API_KEY_SECRET_ARN). | ||
| # The variables are every API key setting dd-trace-java reads, plus | ||
| # DATADOG_API_KEY, which dd-trace-js reads (Node uses this wrapper for AppSec). | ||
| if [[ "$DD_API_KEY$DATADOG_API_KEY$DD_API_KEY_FILE$DD_PROFILING_API_KEY$DD_PROFILING_API_KEY_FILE$DD_PROFILING_APIKEY$DD_PROFILING_APIKEY_FILE" =~ ^[[:space:]]*$ ]] |
There was a problem hiding this comment.
My only concern is this could potentially break customers who set their API key only in a Java system property or a Java/.NET config file. The wrapper can’t see those keys and will set the local base URL. The tracer then sends the request without its key, so the extension returns 403 if it doesn’t have a key of its own.
litianningdatadog
left a comment
There was a problem hiding this comment.
Left some comment. Let me know if I missed something or am over concerned.
Jira: SVLS-10161
Java and .NET version of DataDog/datadog-lambda-python#890 and DataDog/datadog-lambda-js#867 (Ruby: DataDog/datadog-lambda-rb#173).
Problem
The tracer's feature flag provider loads flag config from Datadog's CDN with the API key from its own config. Customers who keep the key in
DD_API_KEY_SECRET_ARN,DD_API_KEY_SSM_NAMEorDD_KMS_API_KEYgetPROVIDER_NOT_READYon every flag check.This PR
#1510 added a route on the trace agent (
127.0.0.1:8126) that forwards the config request with the key the extension resolved. The tracer uses it only whenDD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URLis set.datadog_wrappernow setsDD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL=http://127.0.0.1:8126only when both are true:DD_API_KEY,DATADOG_API_KEY,DD_API_KEY_FILE,DD_PROFILING_API_KEY,DD_PROFILING_API_KEY_FILE,DD_PROFILING_APIKEYandDD_PROFILING_APIKEY_FILEare unset, empty or whitespace-only. That is every API key env var dd-trace-java reads, and it includesDD_API_KEY, the only one dd-trace-dotnet reads.DATADOG_API_KEYis there because dd-trace-js reads it as an alias, and Node uses this wrapper for AppSec: the extension does not read it, so routing those customers through the extension would break flags that work today.The default is set in the block that sets
DD_TRACE_STATS_COMPUTATION_ENABLED, so it applies to every runtime that uses the wrapper.Why these conditions
Gotchas reviewers should know about
dd-openfeatureSDK (an application dependency, not part of the layer) reads it from v1.68.0. Older versions ignore it.DD-API-KEYordd_envto a custom base URL. The extension adds the key, and it addsdd_envfromDD_ENV(orenvinDD_TAGS). So in .NET, an environment changed in code at runtime does not change the flag config environment.-Ddd.api-key,-Ddd.api-key-file, for example inJAVA_TOOL_OPTIONS), a JavaDD_TRACE_CONFIGproperties file, or .NETdatadog.json/DD_TRACE_CONFIG_FILE. These customers go through the extension, which works because the route exists and the extension uses its own key. The wrapper does not parse these sources.403.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_configorDD_FEATURE_FLAGS_ENABLED=false: the base URL applies only to the agentless source, so it has no effect.Testing
The repo has no wrapper tests.
Test 1: env matrix
Steps
env -i, run the wrapper under bash 3.2 and bash 5 withAWS_EXECUTION_ENVset to Java 21, .NET 8 and Python 3.12. Passprintenv DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URLas the command.DD_API_KEY_SECRET_ARNonly, each of the key variables set, and a customer base URL with and withoutDD_API_KEY.Result
All 12 cases pass on every runtime. The wrapper on
mainfails the 4 no-key cases.Test 2: shellcheck
Steps
shellcheckon the old and new wrapper.Result
No new findings.
🤖 Generated with Claude Code