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 5 commits into
Conversation
|
405e95f to
dc8aeb9
Compare
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results✅ No issues found! 📦
|
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
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 *`).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## lloeki/ffi-for-trace-exporter #2029 +/- ##
=================================================================
- Coverage 72.73% 72.72% -0.02%
=================================================================
Files 459 459
Lines 76096 76065 -31
=================================================================
- Hits 55352 55316 -36
- Misses 20744 20749 +5
🚀 New features to boost your workflow:
|
9d7998b to
5e2089f
Compare
b3784be to
34f795a
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).