feat: Make the C API's config types opaque handles #457
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 525 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #457"
general
weight: 0.35
fuzzybinary
refs: RUM-20127
This PR redefines the following config types in the C API:
dd_core_config_tdd_rum_config_tdd_logger_config_tdd_crash_reporting_config_tdd_profiling_config_tPreviously, these types had their struct layouts exposed at the API layer, and callers were expected to allocate their own values and pass them to
dd__config_init():As of this PR, these config structs are now opaque to the caller, and we employ a more traditional
dd__config_create()/dd__config_destroy()pattern:dd_core_createet al. create an internal copy of the provided config, so it's always safe for a caller to destroy config structs at any time after they're used.Creating a config struct via the C API now incurs one additional heap allocation.
This is a breaking change to the C API. Since the only known clients of the C API are internal Datadog projects, and since we warrant that breaking changes may be released in minor versions at v0, this change will ship as
0.10.0.## Benefits of this approach
c/andcpp/.DATADOG_MAX__LENlimits (truncating or rejecting long values). All strings passed to either API's config setters are copied, so no config struct can retain a dangling reference to an application-owned string.## Changes to API-layer tests
We have tests that exercise each API end-to-end, e.g.:
core_c_api_test.cppcore_cpp_api_test.cppThese tests tend to be carbon copies of each other, with only the symbol names changed. However, the C API tests have needed to maintain their own unique coverage for things like string truncation.
In addition to updating all usages of config structs in the C API, this PR has cleaned up any places where the C API no longer deviates from the C++ API, ensuring that each pair of test files is as close as possible to one another in structure. This includes a few miscellaneous fixes to correct other places where API tests have drifted.
There are some differences in test coverage that remain, all because the APIs behave differently:
_create()functions, which have no C++ equivalentNULLhandles andNULLarguments (e.g. C has to care aboutnullptrand""as distinct string args)userdataargs where C++ can just takestd::functiondd_core_config_internal_set_ca_certificatesneeds extra test cases due to accepting(data, size)NULLwhere the C++ API returns a valid no-op object## Additional behavior changes
Previously, passing
NULLtodd_core_config_set_application_storage_path()would be ignored. It now clears the configured path, consistent with passing an empty string.Diagnostic error messages logged due to invalid arguments at the API layer have been slightly tweaked to use API-neutral wording, since both the C and C++ APIs use the same validation path. e.g.: