feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1292
Closed
zarirhamza wants to merge 1 commit into
Closed
feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1292zarirhamza wants to merge 1 commit into
zarirhamza wants to merge 1 commit into
Conversation
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.
|
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
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.
false— existing behavior is completely preserved.DD_SERVERLESS_APM_ONLY) and YAML.Behavior
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):config/mod.rs) — forcesserverless_logs_enabled,enhanced_metrics,lambda_proc_enhanced_metrics,otlp_config_metrics_enabled, andotlp_config_logs_enabledtofalse, overriding any individually set toggles.main.rs::start_metrics_flushers) — returns no flushers, so anything drained from the DogStatsD aggregator (custom / enhanced / process) is discarded rather than sent.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:
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/leavingDD_SERVERLESS_APM_ONLYunset.Notes for reviewers