Repository navigation
feat: route feature flag config through the extension when DD_API_KEY is unset - #293
Closed
purple4reina wants to merge 1 commit into
Closed
purple4reina wants to merge 1 commit into
purple4reina wants to merge 1 commit into
Conversation
… 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 in a package init, 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
The routing guards preserve existing API-key and custom-URL configurations, and the specialist confirmed the intended initialization behavior against dd-trace-go v2.11.0. End-to-end routing through the extension was not exercised.
🤖 Bits Code Review · Commit 57d07fb
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.
dd-trace-go PR
DataDog/dd-trace-go#5904 (same change in
contrib/aws/datadog-lambda-go)What does this PR do?
Jira: SVLS-10161
Same change for Python (DataDog/datadog-lambda-python#890), Node (DataDog/datadog-lambda-js#867) and Ruby (DataDog/datadog-lambda-rb#173).
A package
init()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_KEYis unset or empty.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL.In every other case it changes nothing.
Motivation
dd-trace-go's feature flag provider needs
DD_API_KEY. Customers who keep the key inDD_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 provider uses that route only when this variable is set.Why these conditions
DD_API_KEYunset: the library cannot tell which extension version is installed. An extension without the #1510 route returns404, and the tracer does not fall back to the CDN. With this condition, nothing that works today can break:DD_API_KEYusers keep going straight to the CDN, and customers without it are already broken. dd-trace-go reads onlyDD_API_KEY(itsDD-API-KEYalias is not a valid Lambda env var name) and does not trim it, so neither do we.Why a package
init()NewDatadogProviderreads the cachedinternal/configinstance (config.Get()). A typicalmain()creates the provider beforelambda.Start(ddlambda.WrapFunction(...)), so setting the variable inWrapFunction(wheresetupAppSecsets its env vars) would be too late.init()runs beforemain(). No dd-trace-go package readsinternal/configduring its own init (the OTel bridge loads it lazily), andtracer.Startre-reads the environment throughconfig.CreateNew().Gotchas reviewers should know about
DD_API_KEYget404instead ofDD_API_KEY is required. Flags fail either way; only the log message changes. This can be merged before v104.dd-trace-go.v1 v1.74.6(which builds ondd-trace-go/v2 v2.2.3). The base URL needsdd-trace-go/v2v2.11.0 or later, which a customer using the v2openfeatureprovider gets through their owngo.mod. With an older v2, the variable is ignored.init()runs in any binary that imports this package, whether or not it wraps a handler. It does nothing unless/opt/extensions/datadog-agentexists.varorinit()of a package that Go initializes before this one would still miss 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
TestSetFeatureFlagsBaseURLcovers the extension present or absent,DD_API_KEYset or unset, a secret ARN only, and a base URL the customer already set.Types of changes
Checklist
🤖 Generated with Claude Code