feat: Align tracer FFI error and response types with common conventions#2029
feat: Align tracer FFI error and response types with common conventions#2029lloeki wants to merge 8 commits into
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 10ceab4 | Docs | Datadog PR Page | Give us feedback! |
405e95f to
dc8aeb9
Compare
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
dc8aeb9 to
b3784be
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2029 +/- ##
==========================================
- Coverage 72.85% 72.82% -0.04%
==========================================
Files 459 459
Lines 76134 76105 -29
==========================================
- Hits 55469 55423 -46
- Misses 20665 20682 +17
🚀 New features to boost your workflow:
|
9d7998b to
5e2089f
Compare
b3784be to
34f795a
Compare
|
There are some CI failures but I'm opening this for review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1425e682b1
ℹ️ 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".
| gen_error!(ErrorCode::Panic) | ||
| ) | ||
| ) -> MaybeError { | ||
| let chunks = Vec::with_capacity(capacity); |
There was a problem hiding this comment.
Restore panic guarding around capacity allocations
When a C caller passes an oversized capacity value (for example usize::MAX from a bad FFI input), Vec::with_capacity panics; because this extern "C" entry point no longer wraps the body in catch_panic, the process aborts instead of returning a ddog_MaybeError. The previous implementation caught this and returned an error, and ddog_tracer_trace_chunks_begin_chunk now has the same unguarded allocation path.
Useful? React with 👍 / 👎.
5e2089f to
b9ea727
Compare
1425e68 to
3bd0ef7
Compare
8ed5a05 to
e6df3ba
Compare
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
Switch tracer span and chunk construction functions from `Option<Box<ExporterError>>` to `MaybeError` (`Option<ddog_Error>`). These functions only produce error messages (the error code is never used by callers), so the simpler `ddog_Error` type is sufficient. This lets C consumers use the existing `read_ddogerr_string_and_drop` and `get_error_details_and_drop` helpers instead of custom error handling. `send_trace_chunks` retains `ExporterError` because callers need the error code for HTTP response classification.
Replace the separate `*const u8` return + `out_len` out-parameter with a single `ByteSlice` return value. This bundles pointer and length into one FFI-safe struct, matching the existing slice conventions in libdd-common-ffi and avoiding the awkward split between return value and out-parameter.
Wrap the `fields` parameter in `Option` so the function can check for null and return an error instead of undefined behavior. cbindgen produces the same C signature (`const ddog_TracerSpanFields *`).
e6df3ba to
49384c0
Compare
What does this PR do?
Two improvements to the tracer FFI surface in
libdd-data-pipeline-ffi:Use
ddog_MaybeErrorfor tracer construction functions. Switchddog_tracer_span_new,set_meta,set_metric,trace_chunks_new,begin_chunk, andpush_spanfromOption<Box<ExporterError>>toMaybeError(Option<ddog_Error>). These functions only produce errormessages — the error code is never used by callers — so the simpler
ddog_Errortype is sufficient.send_trace_chunksretainsExporterErrorbecause callers need the error code for HTTP responseclassification.
Return
ByteSlicefromddog_trace_exporter_response_get_body.Replace the separate
*const u8return +out_lenout-parameter witha single
ByteSlicereturn value, matching the existing sliceconventions in
libdd-common-ffi.Motivation
FUP to #1952. C consumers (dd-trace-rb) can now use the existing
read_ddogerr_string_and_drop/get_error_details_and_drophelpersfrom
datadog_ruby_common.hinstead of custom error handling for tracerconstruction functions. The
ByteSlicereturn avoids an awkward splitbetween return value and out-parameter for the response body.
Additional Notes
AI was used to accelerate implementation; all code was reviewed and understood.
How to test the change?
All 40 tests pass (13 tracer + 3 response + 24 trace_exporter).