Commit 639bdc4
authored
chore(config): preserve provenance in typed configuration (#2279)
## Human Summary
This PR prepares us to properly close #1965. However we need to migrate the affected components to typed configuration to pick up the fix. #1965 will close when affected components migrate. It is a bit much to do in a single PR so I want to land the mechanism first.
In this PR we preserve a binary interpretation of the `source` field in the remote Agent config stream. When that stream declares the `source` as `default` or `schema`, we record `Provenance::Default`, otherwise `Provenance::Explicit`. For algorithms such as overriding `site` with `dd_url`, this information is required because the Agent stream populates the fields with their default values and we need to know which one should take precedence.
**Important**: without such guidance in my prompt, the coding agent decided that Agent defaults should **not** override explicit local settings (i.e. in the config file or environment variables that ADP reads during startup). This is a behavioral change and, to be honest, I am not sure what the right behavior is. This seems fine? But also, I could see us making the argument that the config stream is definitive even to the extent of overriding local values. In practice this should have little or no effect since we do not expect operators to configure ADP directly beyond the minimum configuration required to connect to the Agent.
**Reviewer's Guide**
- `lib/saluki-config/src/dynamic/event.rs` introduces types to carry provenance in the Agent updates.
- `lib/agent-data-plane-config/src/provenance.rs` introduces types to carry provenance in typed config.
- `bin/agent-data-plane/src/internal/remote_agent.rs` is where we preserve the information in the config stream.
- `lib/agent-data-plane-config-system/src/translators/datadog_translator.rs` is where we preserve the information for those fields where we need it in typed config.
Most of the code churn is in tests creating config stream events for themselves, which now have to add the provenance metadata.
## AI Summary
The Core Agent configuration stream publishes a complete reified configuration, including values materialized from schema defaults, and source metadata for each key. Once that configuration is deserialized into a value-only model, an explicitly supplied value equal to the schema default is indistinguishable from a defaulted value. That distinction is required for source-aware translation and is the key to resolving #1965.
This PR carries the two-state provenance (`Default`/`Explicit`) from the stream through the typed configuration system and exposes it to `SalukiConfiguration` consumers with `ConfigValue<T>`. Translators and consumers can now determine whether a setting was supplied without hardcoding or comparing schema-default values. Provenance is preserved across local bootstrap values, snapshots, partial updates, resets, and live changes while retaining the existing serialized configuration shape.
As a side effect, default-sourced Agent values no longer shadow explicit local file or environment values in the typed path; explicit Agent values still override them. This is useful for local and test configuration, but is secondary to making source-aware configuration decisions possible. The legacy `GenericConfiguration` compatibility view remains value-only, and affected components still need to migrate before #1965 is fully resolved.
### Follow-up
The components that need typed-config plumbing for the #1965 endpoint fix are below. This PR also carries provenance for the forwarder retry-queue settings; the retry-related rows are needed to consume that additional fix, but are not required for the `site`/`dd_url` endpoint fix itself.
```
┌────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Component │ Why it must migrate │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DatadogMetricsConfiguration / │ It currently deserializes `site` and `dd_url` from the raw map and decides which endpoint wins │
│ dd_metrics_encode │ in `configured_primary_endpoint` and `any_series_endpoint_matches`. It must use │
│ │ `Endpoints.dd_url.is_explicit()` and the typed site value rather than treating the default URL │
│ │ as absent. This also covers the MRF and autoscaling-failover metrics encoder instances. │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DatadogForwarderConfiguration / │ Its `EndpointConfiguration` currently independently deserializes `site` and `dd_url`. If only. │
│ dd_out (and `mrf_dd_out`) │ the metrics encoder migrates, the encoder and forwarder can disagree about the primary │
│ │ endpoint. │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ForwarderConfiguration │ This is the common adapter used by both forwarders. It needs to overlay the typed endpoint and │
│ │ retry values onto the remaining raw/deserialized forwarder settings. │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ EndpointConfiguration │ This is where primary endpoint resolution currently happens. It needs to represent a defaulted │
│ │ `dd_url` as “not an override” and an explicit `dd_url`—even `https://app.datadoghq.com`—as an │
│ │ override. │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ RetryConfiguration │ `queue_max_size_bytes()` currently uses `Option` presence. It needs to prefer │
│ │ `retry_queue_payloads_max_size` only when that value is explicit, then fall back to │
│ │ `retry_queue_max_size` only when that value is explicit. │
├────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ClusterAgentForwarderConfiguration / │ Its destination URL is explicitly supplied programmatically, so it does not need global │
│ cluster_agent_out │ `site`/`dd_url`. However, it uses the shared `ForwarderConfiguration` and calls │
│ │ `queue_max_size_bytes()`, so it must receive the provenance-aware retry settings. │
└────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘
```
These are shared configuration adapters as well as components. The topology constructors in `bin/agent-data-plane/src/cli/run.rs` must pass the typed shared endpoint configuration through for the primary, MRF, and autoscaling-failover paths. The MRF and Cluster Agent endpoint overrides remain explicit programmatic overrides.
## Change Type
- [x] Non-functional (chore, refactoring, docs)
## How did you test this PR?
- `cargo check --workspace --tests`
- `cargo test -p agent-data-plane-config -p agent-data-plane-config-system -p saluki-config -p agent-data-plane`
- `git diff --check`
#### Human Note
Not tested at the integration level yet because we need to migrate to typed config. But I recommend that we test at least one example of this behavior in the integration suite when we migrate to this mechanism.
## References
- Progresses #1965
- Related to #2169
Co-authored-by: matt.briggs <matt.briggs@datadoghq.com>1 parent 71a9d5c commit 639bdc4
23 files changed
Lines changed: 1558 additions & 634 deletions
File tree
- .claude/skills/config-system
- bin/agent-data-plane/src
- components
- dogstatsd_post_aggregate_filter
- dogstatsd_prefix_filter
- tag_filterlist
- internal
- lib
- agent-data-plane-config-system/src
- translators
- agent-data-plane-config/src
- saluki-components/src
- common/datadog
- destinations/dsd_debug_log
- forwarders/datadog
- transforms/mrf_gateway
- saluki-config/src
- dynamic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
| |||
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
144 | | - | |
| 149 | + | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
329 | 332 | | |
330 | 333 | | |
331 | 334 | | |
| |||
560 | 563 | | |
561 | 564 | | |
562 | 565 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
| 566 | + | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| |||
Lines changed: 18 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
348 | 351 | | |
349 | 352 | | |
350 | 353 | | |
| |||
499 | 502 | | |
500 | 503 | | |
501 | 504 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
| 597 | + | |
601 | 598 | | |
602 | 599 | | |
603 | 600 | | |
| |||
616 | 613 | | |
617 | 614 | | |
618 | 615 | | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
623 | 620 | | |
624 | 621 | | |
625 | 622 | | |
| |||
Lines changed: 24 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
349 | 352 | | |
350 | 353 | | |
351 | 354 | | |
| |||
915 | 918 | | |
916 | 919 | | |
917 | 920 | | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
| 921 | + | |
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
927 | | - | |
928 | | - | |
929 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
930 | 930 | | |
931 | 931 | | |
932 | | - | |
| 932 | + | |
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
| |||
952 | 952 | | |
953 | 953 | | |
954 | 954 | | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
| 955 | + | |
959 | 956 | | |
960 | 957 | | |
961 | 958 | | |
962 | 959 | | |
963 | 960 | | |
964 | | - | |
965 | | - | |
966 | | - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
967 | 964 | | |
968 | 965 | | |
969 | | - | |
| 966 | + | |
970 | 967 | | |
971 | 968 | | |
972 | 969 | | |
| |||
978 | 975 | | |
979 | 976 | | |
980 | 977 | | |
981 | | - | |
982 | | - | |
983 | | - | |
984 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
985 | 982 | | |
986 | 983 | | |
987 | 984 | | |
| |||
1004 | 1001 | | |
1005 | 1002 | | |
1006 | 1003 | | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
| 1004 | + | |
1011 | 1005 | | |
1012 | 1006 | | |
1013 | 1007 | | |
1014 | 1008 | | |
1015 | 1009 | | |
1016 | | - | |
1017 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1018 | 1013 | | |
1019 | | - | |
1020 | | - | |
| 1014 | + | |
| 1015 | + | |
1021 | 1016 | | |
1022 | 1017 | | |
1023 | 1018 | | |
| |||
0 commit comments