Skip to content

fix: disable remote configuration by default in Lambda#795

Closed
zarirhamza wants to merge 3 commits intomainfrom
zarir.hamza/fix-lambda-shared-memory-warning
Closed

fix: disable remote configuration by default in Lambda#795
zarirhamza wants to merge 3 commits intomainfrom
zarir.hamza/fix-lambda-shared-memory-warning

Conversation

@zarirhamza
Copy link
Copy Markdown
Contributor

Summary

Disables remote configuration by default before ddtrace loads, preventing the Unable to create shared memory warning on Lambda cold starts.

Resolves #785

Context

Remote configuration in ddtrace relies on /dev/shm for shared memory via multiprocessing.Array. AWS Lambda does not provide /dev/shm, so the allocation fails with FileNotFoundError and logs a warning on every cold start — even when DD_REMOTE_CONFIGURATION_ENABLED=false is 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 PublisherSubscriberConnector creation from lazy (per-product registration) to eager (at module import time).

Changes

  • datadog_lambda/config.py: Set DD_REMOTE_CONFIGURATION_ENABLED=false in the environment before ddtrace is imported, following the same pattern already used for DD_TRACE_STATS_COMPUTATION_ENABLED and DD_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 in PublisherSubscriberConnector.__init__ to skip the shared memory allocation entirely when running in Lambda.

This PR is a defense-in-depth companion that:

  1. Ensures ddconfig._remote_config_enabled is False from the start (preventing features like Dynamic Instrumentation from force-enabling RC in Lambda)
  2. Prevents the RC poller from ever being enable()d, even if the dd-trace-py fix is not yet deployed
  3. Follows established conventions in this module for disabling features incompatible with Lambda

Test Plan

  • Existing unit tests pass
  • Verify DD_REMOTE_CONFIGURATION_ENABLED defaults to "false" when not explicitly set
  • Verify explicit DD_REMOTE_CONFIGURATION_ENABLED=true overrides the default
  • No Unable to create shared memory warning in Lambda cold start logs

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
which skips the shared memory allocation entirely when in_aws_lambda()
is detected.

Resolves: #785
@zarirhamza zarirhamza closed this Apr 15, 2026
@zarirhamza zarirhamza deleted the zarir.hamza/fix-lambda-shared-memory-warning branch April 15, 2026 16:00
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.

Lambda Unable to create shared memory warnings

1 participant