← Back to Pull requests

feat: Make the C API's config types opaque handles #457

Closed
unknown closed this pull request without merging on Nov 19, 2026 18:11 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 20:18 UTC
Author

refs: RUM-20127

This PR redefines the following config types in the C API:

  • dd_core_config_t

  • dd_rum_config_t

  • dd_logger_config_t

  • dd_crash_reporting_config_t

  • dd_profiling_config_t
  • Previously, 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():

    dd_core_config_t config;
    dd_core_config_init(&config, "client-id", "service", "env");
    dd_core_config_set_version(&config, "1.0.0");
    dd_core_create(&config, DD_TRACKING_CONSENT_PENDING);
    

    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_config_t* config = dd_core_config_create("client-id", "service", "env");
    dd_core_config_set_version(config, "1.0.0");
    dd_core_create(config, DD_TRACKING_CONSENT_PENDING);
    dd_core_config_destroy(config);
    

    dd_core_create et 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

  • FFI code that depends on these C APIs is much more stable: it's no longer directly coupled to the struct layout.
  • There is now significantly less duplicated code at the API layer: we don't need to maintain parallel C structs for every C++ config struct; each C struct just wraps the corresponding C++ struct.
  • Similarly, argument validation at the API layer can be handled largely in a single code path, rather than being duplicated across c/ and cpp/.
  • Both APIs now have identical semantics for how string values are handled: the C API no longer imposes its own DATADOG_MAX__LEN limits (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.
  • Because the C and C++ APIs now behave more uniformly, the API-layer tests have also been streamlined a bit (detailed below).
  • ## Changes to API-layer tests

    We have tests that exercise each API end-to-end, e.g.:

  • core_c_api_test.cpp

  • core_cpp_api_test.cpp
  • These 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:

  • C API tests _create() functions, which have no C++ equivalent

  • C API tests have to separately validate NULL handles and NULL arguments (e.g. C has to care about nullptr and "" as distinct string args)

  • C API accepts separate callback-function-pointer and userdata args where C++ can just take std::function

  • dd_core_config_internal_set_ca_certificates needs extra test cases due to accepting (data, size)

  • C API returns NULL where the C++ API returns a valid no-op object
  • ## Additional behavior changes

    Previously, passing NULL to dd_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.:

    -application must supply a non-empty 'service' value in CoreConfig
    +application must supply a non-empty 'service' value in the core config
    

    Diff: 525 lines (+393 / -132) across 6 files Reviewer: fuzzybinary Review duration: 1313m
    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
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.0% (HIGH) · Higher = larger blast radius
    71.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28% · Safe to merge
    28%