Skip to content

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

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

purple4reina wants to merge 1 commit into
mainfrom
rey.abolofia/ffe-extension-base-url

Conversation

@purple4reina

@purple4reina purple4reina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Jira: SVLS-10161
Same change for Python and Node: DataDog/datadog-lambda-python#890, DataDog/datadog-lambda-js#867

What does this PR do?

In Datadog::Lambda.configure_apm, before Datadog.configure, 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, via Datadog::Utils.extension_running?).
  2. DD_API_KEY is unset, empty or whitespace.
  3. The customer has not set DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL (unset, empty or whitespace).

In every other case the wrapper changes nothing.

Motivation

dd-trace-rb's feature flag provider needs DD_API_KEY in the process environment. 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 it are already broken. dd-trace-rb reads only DD_API_KEY (no alias) and strips it, so whitespace counts as unset.
  • Extension present: without the extension, port 8126 refuses the connection. Leaving the variable unset keeps the tracer's clearer requires DD_API_KEY warning.
  • Base URL not set: an explicit customer value wins. dd-trace-rb strips this value too and treats whitespace as unset.

Additional Notes

Gotchas reviewers should know about:

  • Env var, not a Datadog.configure setting: c.feature_flags.agentless.base_url does not exist before datadog 2.44.0 and would raise NoMethodError in the configure block. Older gems ignore the env var.
  • Only configure_apm applies it. Like the other defaults there, customers who call Datadog.configure themselves without configure_apm get nothing.
  • Timing: dd-trace-rb reads the option lazily, when the provider activates (OpenFeature::SDK.configure { |c| c.set_provider(...) }), and caches it. If the customer creates the provider before calling configure_apm, the variable has no effect.
  • datadog gem versions: supported since 2.44.0. The layer installs datadog ~> 2.40 when it is built, so layer v3.31.0 and later bundle 2.44 or newer. An older datadog in the customer's bundle ignores the variable.
  • Extension older than v104: #1510 shipped after v103. With v103 or older, customers without DD_API_KEY get 404 instead of the DD_API_KEY warning. Flags fail either way; only the log message changes. This can be merged before v104.
  • Extension cannot resolve the key (wrong ARN, missing IAM permission): the route returns 403, and the provider logs it and does not retry.
  • Port is hard-coded to 8126. That's where the extension's trace agent listens in Lambda.
  • 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 in test/datadog/lambda.spec.rb call configure_apm with the extension present or absent, DD_API_KEY set, empty or whitespace, a secret ARN only, and a base URL the customer already set.

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

🤖 Generated with Claude Code

… is unset

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

@datadog-prod-us1-6 datadog-prod-us1-6 Bot 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.

Bits Code Review: PASS

More details

The extension fallback preserves existing routing for API-key users and explicit URL overrides. Runtime behavior remains unverified because required test dependencies were missing.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit ab635f1

@datadog-prod-us1-6

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

Copy link
Copy Markdown

Pipelines

✨ Unblock PR with BitsAI

❌ Errors

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

🚦 17 Pipeline jobs failed

DDCI - DataDog/datadog-lambda-rb | integration test (3.2, amd64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

DDCI - DataDog/datadog-lambda-rb | integration test (3.2, arm64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

DDCI - DataDog/datadog-lambda-rb | integration test (3.3, amd64) — 🔧 Needs a code fix, caused by this PR

View more details · View in DDCI

View all 17 failed jobs.

Useful? React with 👍 / 👎

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

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.

1 participant