refactor(span)!: use VecMap for meta, metrics and meta_struct for v04 spans#2043
refactor(span)!: use VecMap for meta, metrics and meta_struct for v04 spans#2043yannham wants to merge 9 commits into
meta, metrics and meta_struct for v04 spans#2043Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: d3b289b | Docs | Datadog PR Page | Give us feedback! |
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. |
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
meta, metrics and meta_struct
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## yannham/span-vec-fields #2043 +/- ##
===========================================================
- Coverage 72.92% 72.89% -0.04%
===========================================================
Files 460 460
Lines 76396 76471 +75
===========================================================
+ Hits 55711 55740 +29
- Misses 20685 20731 +46
🚀 New features to boost your workflow:
|
1c727ec to
a9e644d
Compare
| size += k.as_ref().len() + v.as_ref().len(); | ||
| } | ||
| for k in self.metrics.keys() { | ||
| for (k, _) in &self.metrics { |
There was a problem hiding this comment.
TODO: this is wrong, because keys can be duplicated.
Solution 1: don't dedup. The size will be over-estimated.
Solution 2: deduplicate here. Costly (2 times with serialization).
Solution 3; deduplicate upfront (and eg keep a dirty flag in the vecmap to avoid double dedup).
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
|
681d36f to
95d3d03
Compare
meta, metrics and meta_structmeta, metrics and meta_struct
meta, metrics and meta_structmeta, metrics and meta_struct for v04 spans
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95d3d03685
ℹ️ 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".
| let bytes_str_key = convert_char_slice_to_bytes_string(key); | ||
| map.insert(bytes_str_key, value); |
There was a problem hiding this comment.
Preserve overwrite semantics for repeated FFI tags
When callers set the same meta/metric/meta_struct key more than once through the FFI, this now appends another entry instead of replacing the old one. The FFI getters hide this by returning the last value and key listing dedups, but the v04 serializer used by ddog_serialize_traces_to_bytes still writes span.meta.len() and iterates every entry in libdd-trace-utils/src/msgpack_encoder/v04/span.rs, so updates to an existing key are emitted as duplicate msgpack map keys and also inflate buffering size until flush. Please update existing entries here (or dedup before the manual encoders) to keep the previous HashMap semantics.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Indeed, the msgpack encoding doesn't go through Serialize and needs to handle deduplication as well.
74358f8 to
7e38b23
Compare
7c95b47 to
1336e90
Compare
The trace_buffer benchmark was still using HashMap for Span meta, metrics, and meta_struct fields after the VecMap migration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The decoder functions were returning Vec<(K, V)> which callers immediately converted to VecMap via .into(). Return VecMap directly to avoid the unnecessary intermediate type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1336e90 to
2d45a7f
Compare
2d45a7f to
8f43f82
Compare
Depends on #2022.
What does this PR do?
This PR continues the native span performance work required to land native spans in dd-trace-js. Follow-up of #2022. Actually use
VecMapin theSpandata structure.Motivation
Performance improvement following dd-trace-js native span experiments. See #2022.
How to test the change?
Run tests.