Skip to content

chore(config): migrate TraceSamplerConfiguration to typed config#1984

Merged
webern merged 2 commits into
m/pr5-cutoverfrom
m/trace-sampler
Jul 5, 2026
Merged

chore(config): migrate TraceSamplerConfiguration to typed config#1984
webern merged 2 commits into
m/pr5-cutoverfrom
m/trace-sampler

Conversation

@webern

@webern webern commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

AI Summary

Build TraceSamplerConfiguration from the resolved traces configuration instead of the raw configuration map. Move trace sampler defaults into the typed configuration layers and remove the sampler-specific source parsing from the shared APM helper.

Change Type

  • Non-functional (chore, refactoring, docs)

How did you test this PR?

  • make build-schema-overlay && make fmt
  • make check-all
  • make test
  • make check-docs

References

@webern webern requested a review from a team as a code owner July 4, 2026 13:53
Copilot AI review requested due to automatic review settings July 4, 2026 13:53
@dd-octo-sts dd-octo-sts Bot added area/components Sources, transforms, and destinations. transform/trace-sampler Trace Sampler synchronous transform. labels Jul 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the trace sampler transform to build TraceSamplerConfiguration from the resolved typed traces domain config (via ConfigurationSystem) instead of reading sampler-specific fields directly from the raw GenericConfiguration map. It also relocates sampler-related defaults into the typed configuration model/system and removes sampler parsing/defaulting from the shared APM helper.

Changes:

  • Refactor TraceSamplerConfiguration to be derived from agent_data_plane_config::domains::traces::Domain and plumb it through bin/agent-data-plane topology creation.
  • Remove probabilistic/rare-sampler-related fields and defaults from lib/saluki-components APM config helper.
  • Add shared default helpers + model defaults for traces domain/rare sampler and update Saluki-only seeding to always populate required values; extend tests accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/saluki-components/src/transforms/trace_sampler/mod.rs Switches sampler config source to resolved typed traces config; updates builder wiring; adds a mapping test.
lib/saluki-components/src/common/datadog/apm.rs Removes sampler-specific config parsing/defaults from the shared APM helper.
lib/agent-data-plane-config/src/domains/traces.rs Introduces shared defaults and explicit Default impls for traces domain + rare sampler.
lib/agent-data-plane-config-system/src/saluki_only.rs Makes certain Saluki-only APM knobs required-with-defaults and always seeds them into the traces domain; updates tests/docs.
bin/agent-data-plane/src/cli/run.rs Passes ConfigurationSystem into baseline traces pipeline setup and builds trace sampler config from resolved traces domain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed7b23936c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs
@pr-commenter

pr-commenter Bot commented Jul 4, 2026

Copy link
Copy Markdown

Binary Size Analysis (Agent Data Plane)

Baseline: 7b98c6f · Comparison: b6ea818 · diff
Analysis Configuration: stripped binaries · Pass/Fail Threshold: +5%
Sizes: 41.63 MiB (baseline) vs 42.36 MiB (comparison)
Size Change: +743.16 KiB (+1.74%)

✅ Binary size difference within threshold

Changes by Module
Module File Size Symbols
figment -302.59 KiB 428
serde_json +227.06 KiB 511
core +182.19 KiB 9357
datadog_agent_config::generated::datadog_configuration +111.21 KiB 46
agent_data_plane_config_system::saluki_env_overlay::PathRecorder +69.04 KiB 25
serde_core +65.06 KiB 944
saluki_components::common::datadog +64.28 KiB 572
alloc +57.21 KiB 1469
[sections] +48.36 KiB 8
tokio +33.35 KiB 3078
prost +32.43 KiB 263
serde -30.43 KiB 85
saluki_common::task::instrument +25.78 KiB 55
resource_accounting::groups::Tracked -25.75 KiB 6
agent_data_plane_config_system::system::translate +19.95 KiB 1
agent_data_plane_config_system::translators::datadog_translator +19.76 KiB 19
tracing -19.09 KiB 117
otlp_protos::otlp_include::opentelemetry -18.65 KiB 146
serde_with -16.51 KiB 46
piecemeal +14.98 KiB 43
Detailed Symbol Changes
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +4.0%  +628Ki  +3.6%  +426Ki    [34162 Others]
  [NEW] +55.8Ki  [NEW] +55.6Ki    saluki_components::common::datadog::io::run_endpoint_io_loop::_{{closure}}::h3ef2a484186f0bb8
  [NEW] +53.1Ki  [NEW] +53.0Ki    agent_data_plane::cli::run::handle_run_command::_{{closure}}::he5819430e26508ec
  [NEW] +52.9Ki  [NEW] +52.5Ki    _<datadog_agent_config::generated::datadog_configuration::_::<impl serde_core::de::Deserialize for datadog_agent_config::generated::datadog_configuration::DatadogConfiguration>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::h59abc0a47db21533
  [NEW] +40.1Ki  [NEW] +39.9Ki    _<saluki_components::forwarders::otlp::OtlpForwarder as saluki_core::components::forwarders::Forwarder>::run::_{{closure}}::h3d7ef516f362b9a8
  [NEW] +36.7Ki  [NEW] +36.4Ki    _<saluki_components::common::datadog::obfuscation::_::<impl serde_core::de::Deserialize for saluki_components::common::datadog::obfuscation::ObfuscationConfig>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::h5dc7893c0984844c
  [NEW] +33.2Ki  [NEW] +33.0Ki    _<saluki_components::transforms::aggregate::Aggregate as saluki_core::components::transforms::Transform>::run::_{{closure}}::h6809d072204e0804
  [NEW] +32.0Ki  [NEW] +31.9Ki    saluki_components::sources::dogstatsd::drive_stream::_{{closure}}::h16acca5cc1c6ba60
  [NEW] +31.8Ki  [NEW] +31.7Ki    agent_data_plane::internal::env::workload::RemoteAgentWorkloadProvider::from_configuration::_{{closure}}::h65e15c9238557bac
  [NEW] +31.7Ki  [NEW] +31.5Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::translate_metrics::hd269a5b16c8f1266
  [NEW] +30.0Ki  [NEW] +29.8Ki    agent_data_plane::cli::dogstatsd::handle_dogstatsd_command::_{{closure}}::hd22ba2289c2b0af8
  [NEW] +26.7Ki  [NEW] +26.4Ki    _<saluki_components::sources::dogstatsd::_::<impl serde_core::de::Deserialize for saluki_components::sources::dogstatsd::DogStatsDConfiguration>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::hba6844531adf2ec6
  [DEL] -25.6Ki  [DEL] -25.4Ki    saluki_components::sources::dogstatsd::drive_stream::_{{closure}}::h3fe2520e3abdfc38
  [DEL] -26.6Ki  [DEL] -26.4Ki    _<saluki_components::sources::dogstatsd::DogStatsDConfiguration as saluki_core::components::sources::builder::SourceBuilder>::build::_{{closure}}::h2c2a33d551977c6d
  [DEL] -27.2Ki  [DEL] -26.9Ki    _<saluki_components::sources::dogstatsd::_::<impl serde_core::de::Deserialize for saluki_components::sources::dogstatsd::DogStatsDConfiguration>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map::hfc578ba92a99992a
  [DEL] -28.6Ki  [DEL] -28.5Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::translate_metrics::h1e8351a6f731e9df
  [DEL] -28.6Ki  [DEL] -28.5Ki    agent_data_plane::cli::dogstatsd::handle_dogstatsd_command::_{{closure}}::h84db3f7ad161eab2
  [DEL] -32.6Ki  [DEL] -32.4Ki    _<saluki_components::transforms::aggregate::Aggregate as saluki_core::components::transforms::Transform>::run::_{{closure}}::h72e4b09fd816d94f
  [DEL] -38.7Ki  [DEL] -38.5Ki    _<saluki_components::forwarders::otlp::OtlpForwarder as saluki_core::components::forwarders::Forwarder>::run::_{{closure}}::h3cd6ee67f0471508
  [DEL] -44.7Ki  [DEL] -44.6Ki    agent_data_plane::cli::run::handle_run_command::_{{closure}}::h83501a7881036c5f
  [DEL] -56.8Ki  [DEL] -56.6Ki    saluki_components::common::datadog::io::run_endpoint_io_loop::_{{closure}}::h54fbb73bb30184e6
  +1.7%  +743Ki  +1.6%  +540Ki    TOTAL

@pr-commenter

pr-commenter Bot commented Jul 4, 2026

Copy link
Copy Markdown

Regression Detector (Agent Data Plane)

Run ID: f2f1de7e-7f28-4e8c-be01-96f1bb184080
Baseline: 7b98c6f1 · Comparison: b6ea8182 · diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment (3)

Experiments configured erratic: true are tagged (ignored) and skipped when determining which experiments regressed or improved. Experiments which are detected as erratic at runtime are tagged (erratic) to flag that the run's sample dispersion was high, but their regression / improvement signal still counts.

experiment goal Δ mean % links
quality_gates_rss_idle memory ⚪ +2.93 metrics profiles logs
quality_gates_rss_dsd_low memory ⚪ +1.91 metrics profiles logs
quality_gates_rss_dsd_medium memory ⚪ +1.64 metrics profiles logs
Bounds Checks: ✅ Passed (3)
experiment check replicates observed links
quality_gates_rss_dsd_low memory_usage 10/10 ✅ 43.8 MiB ≤ 50 MiB metrics profiles logs
quality_gates_rss_dsd_medium memory_usage 10/10 ✅ 65.6 MiB ≤ 75 MiB metrics profiles logs
quality_gates_rss_idle memory_usage 10/10 ✅ 29.9 MiB ≤ 40 MiB metrics profiles logs
Explanation

A change is flagged as a regression when |Δ mean %| > 5.00% in the regressing direction for its optimization goal AND SMP marks the experiment as a regression (is_regression: true). Improvements use the matching criteria for the improving direction. Experiments configured erratic: true (tagged (ignored)) are skipped outright; experiments detected as erratic at runtime (tagged (erratic)) still count, since that flag describes sample dispersion rather than directional certainty. The Δ mean % cell is colored accordingly: 🟢 = improvement, 🔴 = regression, ⚪ = neutral. Reduction in CPU or memory is an improvement; reduction in ingress throughput is a regression.

@webern webern force-pushed the m/trace-sampler branch from ed7b239 to df4d8c7 Compare July 4, 2026 14:30
Copilot AI review requested due to automatic review settings July 5, 2026 08:21
@webern webern force-pushed the m/trace-sampler branch from df4d8c7 to b73691f Compare July 5, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs
@datadog-datadog-prod-us1

This comment has been minimized.

@webern webern left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code operating on behalf of webern. I found two blocking behavioral regressions in the cutover: the probabilistic sampler's absent-value default changes, and two previously supported APM environment variables no longer reach the sampler. The latest rebase's generated environment overlay does not resolve the latter because it derives flat names from config paths rather than the schema's actual environment-variable names. Details inline.

Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs Outdated
Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs
@webern webern force-pushed the m/pr5-cutover branch 2 times, most recently from c0cedef to 53f9087 Compare July 5, 2026 12:42
@webern webern force-pushed the m/trace-sampler branch from b73691f to 32f2dba Compare July 5, 2026 12:48
Copilot AI review requested due to automatic review settings July 5, 2026 12:54
@webern webern force-pushed the m/trace-sampler branch from 32f2dba to 07d5219 Compare July 5, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread lib/saluki-components/src/transforms/trace_sampler/mod.rs
Comment thread lib/agent-data-plane-config/src/domains/traces.rs
Build the trace sampler from the resolved traces domain and move its Saluki-only defaults into the configuration layers.

@webern webern left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code operating on behalf of webern.

Re-reviewed at the current head (b6ea8182) after the rebase onto the reworked config
system. The rebase resolves one of my two earlier blockers; the other still stands.

Resolved: APM environment variables now reach the sampler

My previous review flagged that DD_APM_ENABLE_RARE_SAMPLER and
DD_APM_ERROR_TRACKING_STANDALONE_ENABLED no longer reached these fields, because the
generated environment overlay derived flat key names from the config path
(apm_config_enable_rare_sampler) rather than the schema's actual env-var names
(apm_enable_rare_sampler).

The rebased overlay generator now derives the flat forms from the schema's env bindings, so
the generated table carries the correct names:

flats: &["apm_enable_rare_sampler"],           path: ["apm_config", "enable_rare_sampler"]
flats: &["apm_error_tracking_standalone_enabled"], path: ["apm_config", "error_tracking_standalone", "enabled"]
flats: &["apm_target_tps"],                    path: ["apm_config", "target_traces_per_second"]
flats: &["apm_error_tps"],                     path: ["apm_config", "errors_per_second"]

apply_env_overlay relocates these into the nested slots the typed deserializer reads, and
there is now test coverage for the relocation. This one is fixed — no further action needed.

Still blocking: probabilistic sampler rate now defaults to 0.0 instead of 1.0

The APM sampling rate is read without normalization, while its OTLP sibling is normalized:

sampling_rate: config.probabilistic_sampler.sampling_percentage / 100.0,
otlp_sampling_rate: normalize_sampling_rate(config.otlp.probabilistic_sampler_sampling_percentage / 100.0),

normalize_sampling_rate clamps a rate of <= 0.0 or >= 1.0 back to 1.0. The old
ApmConfig defaulted probabilistic_sampler.sampling_percentage to 100, so the
un-normalized sampling_rate happened to land on 1.0. The typed model instead takes the
Datadog schema default, which is 0, so sampling_rate now defaults to 0.0 and is used
verbatim.

That value is not confined to the probabilistic path. apply_sampling_metadata writes it onto
every kept non-OTLP trace:

trace.otlp_sampling_rate = Some(if is_otlp { self.otlp_sampling_rate } else { self.sampling_rate });

and the traces encoder emits it verbatim as the _dd.otlp_sr chunk tag. So on a default
deployment (probabilistic sampler disabled, no explicit percentage), every kept non-OTLP trace
now reports _dd.otlp_sr:0.00 where it previously reported 1.00. And if the probabilistic
sampler is enabled without an explicit percentage, sampling_rate of 0.0 drops all traces
rather than keeping them.

The fix that matches the OTLP path (and the encoder's own fallback, which clamps <= 0.0 /
>= 1.0 to 1.0) is to normalize this rate too:

sampling_rate: normalize_sampling_rate(config.probabilistic_sampler.sampling_percentage / 100.0),

That maps the 0.0 default back to 1.0 and preserves the prior behavior. Worth a confirming
test that an unset percentage yields a 1.0 sampling rate.

Copilot AI review requested due to automatic review settings July 5, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@webern

webern commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Human writing: I believe the pressing issues and blockers have been mitigated, so I'm merging this into the aggregation branch.

@webern webern merged commit 166c295 into m/pr5-cutover Jul 5, 2026
42 of 52 checks passed
@webern webern deleted the m/trace-sampler branch July 5, 2026 14:11
webern added a commit that referenced this pull request Jul 8, 2026
## AI Summary

Build `TraceSamplerConfiguration` from the resolved traces configuration
instead of the raw configuration map. Move trace sampler defaults into
the typed configuration layers and remove the sampler-specific source
parsing from the shared APM helper.

## Change Type
- [x] Non-functional (chore, refactoring, docs)

## How did you test this PR?

- `make build-schema-overlay && make fmt`
- `make check-all`
- `make test`
- `make check-docs`

## References

- Progresses #1788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/components Sources, transforms, and destinations. transform/trace-sampler Trace Sampler synchronous transform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants