feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1293
Draft
zarirhamza wants to merge 1 commit into
Draft
feat(config): add DD_SERVERLESS_APM_ONLY traces-only mode#1293zarirhamza 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.
Implemented on the datadog-agent-config Config<LambdaConfig> model:
- LambdaConfig / LambdaConfigSource gain a serverless_apm_only field, merged
from both env (DD_SERVERLESS_APM_ONLY) and YAML. Defaults to false.
- get_config() applies a post-merge override that forces
serverless_logs_enabled, enhanced_metrics, lambda_proc_enhanced_metrics and
the core OTLP metrics/logs toggles off, overriding any individually set
values so the guarantee holds regardless of other configuration.
Enforced defensively at the egress points as well:
- 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.
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
Implementation (on the Config model)
LambdaConfig/LambdaConfigSourcegain aserverless_apm_onlyfield, merged from both env (DD_SERVERLESS_APM_ONLY) and YAML viamerge_fields!. Defaults tofalse.get_config()applies a post-merge override (apply_serverless_apm_only) that forcesserverless_logs_enabled,enhanced_metrics,lambda_proc_enhanced_metrics(on.ext) and the coreotlp_config_metrics_enabled/otlp_config_logs_enabledtoggles off — overriding any individually set values so the guarantee holds regardless of other configuration.Enforcement (defense in depth)
config/mod.rs::apply_serverless_apm_only) — forces the logs/metrics/OTLP toggles off after the shared env/yaml merge.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— passes, including two new tests:serverless_apm_only_defaults_off— flag defaults off; other toggles unchanged.serverless_apm_only_forces_metrics_and_logs_off— flag overrides explicitly-enabled metrics/logs/OTLP toggles.Live validation on AWS Lambda
Built the layer (arm64) and deployed two fully-distinct 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:
serverless-apm-full)serverless-apm-standalone)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 leavingDD_SERVERLESS_APM_ONLYunset.Notes for reviewers