Skip to content

feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1292

Closed
zarirhamza wants to merge 1 commit into
mainfrom
zarir.hamza/serverless-apm-only
Closed

feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1292
zarirhamza wants to merge 1 commit into
mainfrom
zarir.hamza/serverless-apm-only

Conversation

@zarirhamza

Copy link
Copy Markdown
Contributor

Summary

Adds a single master switch — DD_SERVERLESS_APM_ONLY — that puts the extension in APM-only ("traces only") mode. When enabled, every billable metrics and logs egress path is suppressed so the customer incurs no infrastructure-monitoring or log-ingestion charges, while traces and APM trace stats are unaffected.

This closes the gap that made a true "traces only" configuration impossible before: there was no toggle to disable custom DogStatsD metrics, so even with logs and enhanced metrics turned off, custom metrics could still egress. A single, defensive flag now guarantees the behavior.

  • Default is false — existing behavior is completely preserved.
  • Readable from both environment (DD_SERVERLESS_APM_ONLY) and YAML.

Behavior

Signal APM-only mode
Traces / APM trace stats sent (unchanged)
Enhanced metrics suppressed
Process (proc) enhanced metrics suppressed
Custom DogStatsD metrics suppressed
OTLP metrics suppressed
Logs (incl. OTLP logs) suppressed

Enforcement (defense in depth)

The flag is enforced at multiple layers so the guarantee holds regardless of other configuration (e.g. even if a user also sets DD_ENHANCED_METRICS=true):

  1. Config (config/mod.rs) — forces serverless_logs_enabled, enhanced_metrics, lambda_proc_enhanced_metrics, otlp_config_metrics_enabled, and otlp_config_logs_enabled to false, overriding any individually set toggles.
  2. Metrics wiring (main.rs::start_metrics_flushers) — returns no flushers, so anything drained from the DogStatsD aggregator (custom / enhanced / process) is discarded rather than sent.
  3. Logs flusher (logs/flusher.rs::flush) — short-circuits to an empty request set, guaranteeing no log egress even if something is queued or redriven.

Testing

  • cargo fmt --all -- --check — passes.
  • cargo clippy --workspace --all-targets --features default — passes (no new warnings).
  • cargo test (config + logs modules) — 55 passed, including two new tests:
    • test_serverless_apm_only_defaults_off — flag defaults off; other toggles unchanged.
    • test_serverless_apm_only_forces_metrics_and_logs_off — flag overrides explicitly-enabled metrics/logs toggles.

Live validation on AWS Lambda

Built the layer (arm64) and deployed two otherwise-identical Node.js 22 functions (Datadog Node layer + this extension), one with the flag off and one on, then invoked each and queried the Datadog API:

Signal flag OFF flag ON (APM-only)
Spans / traces present present
Logs present 0
Custom metric present absent (never ingested)

The extension's Lambda Telemetry API subscription also drops from [Platform, Extension, Function] to [Platform] when the flag is on, confirming logs are cut off at the source.

Risk / rollback

Low. Behavior is gated entirely behind a new flag that defaults to false; when unset the code paths are unchanged. Rollback is setting/leaving DD_SERVERLESS_APM_ONLY unset.

Notes for reviewers

  • The FIPS-feature clippy variant could not be run locally (macOS is missing the aws-lc FIPS crypto dylib); it exercises the same feature-agnostic config/logs code and runs on the Ubuntu CI runners.

Introduce a single master switch, DD_SERVERLESS_APM_ONLY, that puts the
extension in APM-only ("traces only") mode. When enabled, every billable
metrics and logs egress path is suppressed so the customer incurs no
infrastructure-monitoring or log-ingestion charges, while traces and APM
trace stats are unaffected.

The flag is enforced defensively at multiple layers so the guarantee holds
regardless of other configuration:
- config: forces serverless_logs_enabled, enhanced_metrics,
  lambda_proc_enhanced_metrics, and OTLP metrics/logs off, overriding any
  individually set toggles.
- main: start_metrics_flushers returns no flushers, so custom DogStatsD /
  enhanced / process metrics drained from the aggregator are discarded.
- logs flusher: flush() short-circuits to guarantee no log egress even if
  something is queued.

Readable from both env (DD_SERVERLESS_APM_ONLY) and YAML. Defaults to false,
preserving existing behavior. Adds unit tests covering the default-off case
and the forced-override case.
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jul 2, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 3 Pipeline jobs failed

DataDog/datadog-lambda-extension | integration-suite: [lmi]   View in Datadog   GitLab

DataDog/datadog-lambda-extension | integration-suite: [on-demand]   View in Datadog   GitLab

DataDog/datadog-lambda-extension | integration-suite: [snapstart]   View in Datadog   GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a35de23 | Docs | Datadog PR Page | Give us feedback!

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