Return agent response length.#1170
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1170 +/- ##
==========================================
+ Coverage 71.42% 71.44% +0.02%
==========================================
Files 348 348
Lines 54522 54719 +197
==========================================
+ Hits 38942 39096 +154
- Misses 15580 15623 +43
🚀 New features to boost your workflow:
|
| #[no_mangle] | ||
| pub unsafe extern "C" fn ddog_trace_exporter_response_get_body( | ||
| response: *const ExporterResponse, | ||
| out_len: Option<&mut usize>, |
There was a problem hiding this comment.
Would it be simpler if we turned ExporterResponse to Repr(C) and access fields directly ?
There was a problem hiding this comment.
I thought about that but changing the ExporterResponse in any way will result in an ABI incompatibility, for example returning the headers or parsing headers info. Probably it won't matter too much because tracers always recompile the bindings with each new version but I think it's a good practice to return opaque pointers for types that are subject to change.
There was a problem hiding this comment.
Ok, on compatibility note you could add a new getter to retrieve len instead of modifying the existing signature. Although since dotnet is the only tracer using the bindings for now both are fine.
There was a problem hiding this comment.
Indeed at first I thought about just adding a new getter but since .Net was the only one using the API I decided to change it in order to reduce the performance overhead of crossing the managed side boundary two times for each agent response.
…rned into a null terminated string.
BenchmarksComparisonBenchmark execution time: 2025-08-06 09:58:38 Comparing candidate commit 4066a4a in PR branch Found 2 performance improvements and 0 performance regressions! Performance is the same for 51 metrics, 2 unstable metrics. scenario:credit_card/is_card_number/378282246310005
CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
Group 14
BaselineOmitted due to size. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
## Summary of changes - Bump version from 19.1.0 to 20.0.0. - Update GetResponseBody signature. ## Reason for change API Changes: - `ddog_trace_exporter_response_get_body` now returns the length which prevents managed code to compute the payload's length manually. Improvements: - Avoid formatting the agent response into a null terminated string before returning it to the managed code. This will boost the performance by avoiding an additional copy of the response ([#1170](DataDog/libdatadog#1170)). - Lower the severity of the info fetcher logs [#1168](DataDog/libdatadog#1168). ## Other details Libdd release [page](https://github.com/DataDog/libdatadog/releases/tag/v20.0.0)
What does this PR do?
The calling code will need to deserialize the response in order to get the sample rates for that it will need the length of the response which can be computed by iterating over the response looking for the NUL character. This results in extra computation in the calling code and this PR address this situation. Moreover the FFI layer was making an additional copy of the payload to turn it into a CString, this was also removed.
Motivation
Avoid performance penalties while deserializing the response.