Skip to content

feat: route feature flag config through the extension when DD_API_KEY is unset - #890

Open
purple4reina wants to merge 4 commits into
mainfrom
rey.abolofia/ffe-extension-base-url
Open

purple4reina wants to merge 4 commits into
mainfrom
rey.abolofia/ffe-extension-base-url

Conversation

@purple4reina

@purple4reina purple4reina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Jira: SVLS-10161

What does this PR do?

Before ddtrace loads, sets DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL=http://127.0.0.1:8126 only when all of these are true:

  1. The extension is present (/opt/extensions/datadog-agent exists).
  2. DD_API_KEY is unset or empty.
  3. The customer has not set DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL (unset or empty).

In every other case the wrapper changes nothing.

Motivation

dd-trace-py's feature flag provider reads only DD_API_KEY. Customers who keep the key in DD_API_KEY_SECRET_ARN, DD_API_KEY_SSM_NAME or DD_KMS_API_KEY get PROVIDER_NOT_READY on 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

  • DD_API_KEY unset: the wrapper cannot tell which extension version is installed. An extension without the #1510 route returns 404, and the tracer does not fall back to the CDN. With this condition, nothing that works today can break: DD_API_KEY users keep going straight to the CDN, and customers without DD_API_KEY are already broken today.
  • Extension present: without the extension, port 8126 refuses the connection. Leaving the variable unset keeps the tracer's clearer DD_API_KEY is required error.
  • Base URL not set: an explicit customer value wins.

Gotchas reviewers should know about

  • Extension older than v104: #1510 merged after v103, so it ships in v104. With v103 or older, customers without DD_API_KEY get 404 instead of DD_API_KEY is required. Flags fail either way, but the log message changes and is less obvious. This can be merged before v104; it only helps after customers upgrade the extension.
  • ddtrace older than 4.14.0 (including the 3.x line for Python 3.8/3.9) does not know this variable and ignores it. No effect.
  • ddtrace imported before datadog_lambda: if the customer's handler loads ddtrace's feature flag module before datadog_lambda, ddtrace has already read its config, so the variable has no effect. This is the same as the other defaults in config.py.
  • Extension cannot resolve the key (wrong ARN, missing IAM permission): the route returns 403, and the provider logs it and does not retry. Before, the failure was the missing DD_API_KEY. Now it shows up as a 403 in the tracer and an error in the extension logs.
  • Port is hard-coded to 8126. The extension's trace agent always listens on 8126 in Lambda (DD_APM_RECEIVER_PORT applies only to its test-mode binary), so DD_TRACE_AGENT_URL and DD_TRACE_AGENT_PORT are not used.
  • Extension could not build its no-redirect HTTP client: the extension leaves the route out (404), the same as an old extension.
  • DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_config or DD_FEATURE_FLAGS_ENABLED=false: the base URL applies only to the agentless source, so the variable has no effect.

Testing Guidelines

Unit tests run datadog_lambda.config with each combination of extension present or absent, DD_API_KEY set, empty or unset, and a preset base URL.

config now imports datadog_lambda.extension, so the test that checks importing config does not import ddtrace now also evicts the cached datadog_lambda submodules. Before, it did not re-run extension.py and would miss a ddtrace import there.

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)

🤖 Generated with Claude Code

… is unset

When the extension is present and DD_API_KEY and
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL are both unset,
set the base URL to http://127.0.0.1:8126 before ddtrace loads, 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>
@purple4reina
purple4reina requested review from a team as code owners November 17, 2026 00:53
@purple4reina
purple4reina requested a review from lym953 November 17, 2026 00:53

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The configuration guards preserve existing API-key and custom-URL paths while enabling extension routing when both settings are empty or unset. Extension and tracer compatibility was not exercised end to end.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit b26e43d

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 20 Pipeline jobs failed

DDCI - DataDog/datadog-lambda-python | unit-test (python310-amd64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

DDCI - DataDog/datadog-lambda-python | unit-test (python310-arm64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

DDCI - DataDog/datadog-lambda-python | unit-test (python311-amd64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

View all 20 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dd8ad51 | Docs | View more details | Give us feedback!

Evict all datadog_lambda submodules, not only config, so modules that
config imports (e.g. datadog_lambda.extension) also run under the
ddtrace blocker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@clifordshelton clifordshelton left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good 👍. Thanks Rey! Left just two non-blocking nits.

Comment thread datadog_lambda/config.py Resolved
Comment thread tests/test_config.py Resolved
purple4reina and others added 2 commits November 17, 2026 23:08
Co-authored-by: clifordshelton <cliford.shelton@datadoghq.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants