fix: disable remote configuration by default in Lambda#797
Merged
zarirhamza merged 2 commits intomainfrom Apr 15, 2026
Merged
Conversation
Remote configuration relies on /dev/shm for shared memory, which is unavailable in AWS Lambda. Set DD_REMOTE_CONFIGURATION_ENABLED=false before ddtrace loads (following the same pattern used for DD_TRACE_STATS_COMPUTATION_ENABLED and DD_INSTRUMENTATION_TELEMETRY_ENABLED) so the tracer knows RC is disabled from the start. This is a defense-in-depth companion to the primary fix in dd-trace-py (DataDog/dd-trace-py#17550) which skips the shared memory allocation entirely when in_aws_lambda() is detected. Integration test snapshots will need regenerating since ddtrace startup behavior changes slightly when RC is disabled from the start vs disabled later by the ASM Lambda guard. Resolves: #785
This was referenced Apr 15, 2026
purple4reina
approved these changes
Apr 15, 2026
gh-worker-dd-mergequeue-cf854d bot
pushed a commit
to DataDog/dd-trace-py
that referenced
this pull request
Apr 15, 2026
## Summary Fixes the `Unable to create shared memory. Features relying on remote configuration will not work as expected.` warning that appears on every Lambda cold start since ddtrace v4.5.0. Closes DataDog/datadog-lambda-python#785 ## Root Cause The [single RC subscriber refactor](74c3ab43b0) (`v4.5.0`) moved `PublisherSubscriberConnector` creation into `RemoteConfigClient.__init__`, making it eagerly constructed when the module-level `remoteconfig_poller` singleton is instantiated at import time. Before that refactor, connectors were created lazily per-product registration and were never created in Lambda because remote config is disabled there. AWS Lambda does not provide `/dev/shm`, so the `multiprocessing.Array` allocation always fails with `FileNotFoundError`, logging the warning even though: - `DD_REMOTE_CONFIGURATION_ENABLED=false` is set - The ASM settings already disable remote config for Lambda (`asm.py:284`) Both guards run **after** the singleton is already created — too late to prevent the allocation attempt. ## Changes - **`ddtrace/internal/remoteconfig/_connectors.py`**: Check `in_aws_lambda()` in `PublisherSubscriberConnector.__init__` before attempting shared memory allocation. When in Lambda, skip directly to `_DummySharedArray` without logging a warning (this is expected behavior, not an error). - **`tests/internal/remoteconfig/test_remoteconfig_connector.py`**: Add test verifying the connector uses `_DummySharedArray` when `AWS_LAMBDA_FUNCTION_NAME` is set. ## Safety Using `_DummySharedArray` in Lambda is safe because: - `.value` is the only attribute accessed on the shared array — `_DummySharedArray` satisfies the full duck-typing contract - `connector.read()` returns `[]` when `.value` is `b""`, which is handled gracefully by the subscriber dispatch chain (`_dispatch_to_products` calls `periodic()` on callbacks then returns early) - The RC poller never starts in Lambda (`enable()` returns `False`), so no data is ever written to the connector - All RC callbacks (ASM, DI, APM Tracing, Tracer Flare, Feature Flags) handle empty/no-op RC data gracefully - This is the same `_DummySharedArray` already used as the `FileNotFoundError` fallback — we just reach it earlier and without the warning ## Companion PR Defense-in-depth change in datadog-lambda-python: [DataDog/datadog-lambda-python#797](DataDog/datadog-lambda-python#797) (sets `DD_REMOTE_CONFIGURATION_ENABLED=false` before ddtrace loads) ## Test Plan - [ ] Existing `test_remoteconfig_connector.py` tests pass (non-Lambda paths unchanged) - [ ] New `test_connector_uses_dummy_shared_array_in_aws_lambda` test passes - [ ] Verify no `Unable to create shared memory` warning in Lambda cold start logs Co-authored-by: zarir.hamza <zarir.hamza@datadoghq.com>
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.
Summary
Disables remote configuration by default before ddtrace loads, preventing the
Unable to create shared memorywarning on Lambda cold starts.Closes #785
Context
Remote configuration in ddtrace relies on
/dev/shmfor shared memory viamultiprocessing.Array. AWS Lambda does not provide/dev/shm, so the allocation fails withFileNotFoundErrorand logs a warning on every cold start — even whenDD_REMOTE_CONFIGURATION_ENABLED=falseis explicitly set — because the shared memory allocation happens at import time before the config flag is checked.This started occurring with ddtrace v4.5.0 due to the single RC subscriber refactor which changed
PublisherSubscriberConnectorcreation from lazy (per-product registration) to eager (at module import time).Changes
datadog_lambda/config.py: SetDD_REMOTE_CONFIGURATION_ENABLED=falsein the environment before ddtrace is imported, following the same pattern already used forDD_TRACE_STATS_COMPUTATION_ENABLEDandDD_INSTRUMENTATION_TELEMETRY_ENABLED. Respects explicit user overrides — only sets the default if the env var is not already present.Primary Fix
The primary fix is in dd-trace-py: DataDog/dd-trace-py#17550 — adds an
in_aws_lambda()check inPublisherSubscriberConnector.__init__to skip the shared memory allocation entirely when running in Lambda.This PR is a defense-in-depth companion that:
ddconfig._remote_config_enabledisFalsefrom the start (the env var defaults toTruewhen unset, and the ASM Lambda guard only overrides it later during initialization)enable()dIntegration Test Snapshots
This change alters ddtrace startup behavior (RC is now
Falsefrom config init rather thanTrue-then-Falseafter the ASM guard). Integration test snapshots need regenerating viaUPDATE_SNAPSHOTS=true.Test Plan