Skip to content

feat: add C language binding#286

Open
adeshkumar1 wants to merge 4 commits intomainfrom
adeshkumar1/c-binding-on-main
Open

feat: add C language binding#286
adeshkumar1 wants to merge 4 commits intomainfrom
adeshkumar1/c-binding-on-main

Conversation

@adeshkumar1
Copy link

@adeshkumar1 adeshkumar1 commented Mar 3, 2026

Description

Add C language binding (ddog_trace_*) wrapping the C++ tracing library for integration from C-based projects.
Follows Datadog's ddog_ naming convention from libdatadog. Gated behind BUILD_C_BINDING=OFF.

Motivation

Enable C-based projects to use dd-trace-cpp without a C++ dependency at the call site.

Building and Testing

cmake -B build -DBUILD_C_BINDING=ON -DDD_TRACE_BUILD_TESTING=ON
cmake --build build -j
./build/binding/c/test_c_binding

@pr-commenter
Copy link

pr-commenter bot commented Mar 3, 2026

Benchmarks

Benchmark execution time: 2026-03-12 20:33:34

Comparing candidate commit 1f83a79 in PR branch adeshkumar1/c-binding-on-main with baseline commit f8c3913 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.70%. Comparing base (f8c3913) to head (1f83a79).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #286      +/-   ##
==========================================
- Coverage   87.76%   87.70%   -0.07%     
==========================================
  Files          84       84              
  Lines        5658     5668      +10     
==========================================
+ Hits         4966     4971       +5     
- Misses        692      697       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@datadog-official
Copy link

datadog-official bot commented Mar 3, 2026

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 87.70% (-0.07%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1f83a79 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@adeshkumar1
Copy link
Author

All format changes/decisions are done wit the clang-format script

Copy link
Collaborator

@xlamorlette-datadog xlamorlette-datadog left a comment

Choose a reason for hiding this comment

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

Great work!
(Please address very latest comments, and we're good to go!)


// Options for creating a span. Unset fields default to NULL.
typedef struct {
const char* name;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The order of the fields matters for ABI stability. So, what should be the order of these fields:

  • Same order as in SpanConfig?
  • Logical order? (But what is it? The one in SpanConfig does not fit since, in this C API, name is the only one mandatory and so should come first.)
  • Alphabetical order? (When in doubt, this is what I would do. But if we ever add a field, it will no more be sorted.)

DD_ERROR_ALLOCATION_FAILURE = 3
} dd_error_code;

// Error details populated on failure. The caller must allocate this struct
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: The comment about the caller and the callee (”The caller must allocate this struct […] Pass NULL to ignore errors.”) should not be here. I think the comment for dd_tracer_new() is sufficient.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants