feat(trace-utils)!: add from_string to span text#2011
Conversation
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. |
| /// Note: Borrow<str> is not required by the derived traits, but allows to access HashMap elements | ||
| /// from a static str and check if the string is empty. | ||
| pub trait SpanText: Debug + Eq + Hash + Borrow<str> + Serialize + Default { | ||
| pub trait SpanText: Debug + Eq + Hash + Borrow<str> + Serialize + Default + From<String> { |
There was a problem hiding this comment.
What does this trait bound add? I can't see that it's necessary.
There was a problem hiding this comment.
It allows to store new strings in the span e.g. an normalized/obfuscated version of a value. Otherwise SpanText instance can only be created from static str.
There was a problem hiding this comment.
If that's the case, then maybe there should be code in the PR that needs it, since everything compiles fine without that trait bound.
There was a problem hiding this comment.
It's needed by @Eldolfin work on the trace filters. It seemed cleaner to do this change separately to be able to discuss it
yannham
left a comment
There was a problem hiding this comment.
Just trying to understand the blast radius: who is using the now cow-based SpanSlice implementation in practice? Is it only for tests, or do others have to pay the cow tax? Maybe it's unavoidable, because any SDK has do deal with the filter/normalization issue anyway?
|
iirc we only use it in the trace_utils decoder when decoding from a slice which is done by python and is going to be used by ruby. All sdks may need to use normalization/obfuscation but not all customers will (for now only those using trace filters). I can add an extra trait |
yannham
left a comment
There was a problem hiding this comment.
I see, thanks. I don't think it's worth the effort anyway, since we're moving towards native spans, and it's not clear that Cow has any measurable impact (it does double the size of &str, but whether that makes any difference...).
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 3f09f0b | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2011 +/- ##
==========================================
+ Coverage 72.67% 72.71% +0.03%
==========================================
Files 452 452
Lines 74889 74946 +57
==========================================
+ Hits 54427 54494 +67
+ Misses 20462 20452 -10
🚀 New features to boost your workflow:
|
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
|
# Release proposal for libdd-data-pipeline and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-trace-utils **Next version:** `5.0.0` **Semver bump:** `major` **Tag:** `libdd-trace-utils-v5.0.0` ### Commits - feat(trace-utils)!: add from_string to span text (#2011) - feat!: add encoder from v04 to v1 (#1896) ## libdd-trace-obfuscation **Next version:** `3.1.0` **Semver bump:** `minor` **Tag:** `libdd-trace-obfuscation-v3.1.0` ### Commits - fix(libdd-trace-obfuscation): cargo clippy fix with all lints (#1947) ## libdd-trace-stats (bumped manually) **Next version:** ~~`3.1.0`~~`4.0.0` **Semver bump:** ~~`minor`~~`major` **Tag:** ~~`libdd-trace-stats-v3.1.0`~~`libdd-trace-stats-v4.0.0` ### Commits - feat(trace-utils)!: add from_string to span text (#2011) - feat!: add encoder from v04 to v1 (#1896) ## libdd-data-pipeline **Next version:** `5.0.0` **Semver bump:** `major` **Tag:** `libdd-data-pipeline-v5.0.0` ### Commits - feat(trace-utils)!: add from_string to span text (#2011) - feat!: add encoder from v04 to v1 (#1896) - fix(data-pipeline): allow old PascalCase fields in obfuscation config scheme (#2008) - feat(trace_buffer)!: flush based on size of chunks in bytes (#1953) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com> Co-authored-by: iunanua <igor.unanua@datadoghq.com>
# Release proposal for libdd-sampling and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-common **Next version:** `4.2.0` **Semver bump:** `minor` **Tag:** `libdd-common-v4.2.0` ### Commits - refactor(trace-utils): replace use_v05_format bool and remove infallible expect (#1946) - feat(libdd-common): recognize PCF Garden container IDs (#2025) ## libdd-trace-utils (bumped manually due to breaking in #1946) **Next version:** ~~`5.1.0`~~ `6.0.0` **Semver bump:** ~~`minor`~~ `major` **Tag:** ~~`libdd-trace-utils-v5.1.0`~~ `libdd-trace-utils-v6.0.0` ### Commits - feat(trace-utils)!: introduce VecMap datastructure (#2022) - feat: update test agent version (#2038) - refactor(trace-utils): replace use_v05_format bool and remove infallible expect (#1946) The breaking change is the signature of the public function `libdd_trace_utils::trace_utils::collect_trace_chunks`: - Before: `pub fn collect_trace_chunks<T: TraceData>(traces: ..., use_v05_format: bool)` -> ... - After: `pub fn collect_trace_chunks<T: TraceData>(traces: ..., format: TraceEncoding)` -> ... ## libdd-sampling **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-sampling-v2.0.0` ### :warning: major bump forced due to: - `libdd-trace-utils`: ^4.0.0 → ^6.0.0 ### Commits - fix(sampling): disable libdd-common default features (#2057) - feat(trace-utils)!: add from_string to span text (#2011) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com> Co-authored-by: iunanua <igor.unanua@datadoghq.com>
#What does this PR do? Bumps the libdatadog workspace version from 34.0.0 → 35.0.0 (Cargo.toml + regenerated Cargo.lock) to cut the 35.0.0 release. Breaking changes affecting the FFI layer (34.0.0 → 35.0.0) 1. Tracer FFI: response body now returned as ByteSlice (#2029) — feat! - ddog_trace_exporter_response_get_body no longer takes an out_len: *mut usize out-parameter and returns *const u8. It now returns a single ByteSlice value, matching the slice conventions in libdd-common-ffi. - Tracer constructor functions now validate nullable pointers and return ErrorCode::InvalidArgument instead of risking UB; panics across the boundary are caught and surfaced as ErrorCode::Panic. - C consumers (e.g. dd-trace-rb) can now reuse the standard read_ddogerr_string_and_drop / get_error_details_and_drop helpers from datadog_ruby_common.h. - Action for callers: drop the out_len argument and read length/pointer from the returned ByteSlice. 2. Crashtracker: error.threads flattened to []ThreadData (#2054) — fix(crashtracking)! - The crash-report payload now emits error.threads as an optional flat array of thread objects (unified runtime stack schema 1.8) instead of the previous nested threads object. - This is a wire/payload-format change consumed by downstream pipelines and the product UI. - Action for callers: consumers parsing crash reports must update to the 1.8 thread layout. Other breaking changes since 34.0.0 (Rust API, not C ABI) These are !-marked breaking changes in libdd-trace-utils that affect Rust consumers of the library but do not change the C FFI surface or generated headers: - feat(trace-utils)!: introduce VecMap datastructure (#2022) — adds a HashMap replacement optimized for span construction (not yet wired into span fields). - feat(trace-utils)!: add from_string to span text (#2011) — requires From<String> on SpanText and switches SpanSlice to Cow<str> to allow span-field mutation/normalization. Notable new FFI surface (additive) - feat: Add FFI for trace exporter (#1952) — new tracer FFI surface in libdd-data-pipeline-ffi (the change above, #2029, refines it). Co-authored-by: julio.gonzalez <julio.gonzalez@datadoghq.com>
This reverts commit ecdca7d. # What does this PR do? !1985 is using an alternative way which doesn't require to normalize fields. Since this is not needed right an introduce some overhead, this can be reverted. It may be reintroduced in the future if we need to mutate span fields. # Motivation What inspired you to submit this pull request? # Additional Notes Anything else we should know when reviewing? # How to test the change? Describe here in detail how the change can be validated. Co-authored-by: vianney.ruhlmann <vianney.ruhlmann@datadoghq.com>
# Release proposal for libdd-sampling and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-trace-utils **Next version:** `7.0.0` **Semver bump:** `major` **Tag:** `libdd-trace-utils-v7.0.0` ### Commits - feat(trace-utils)!: add dedup convenience to VecMap (#2049) - fix(trace-utils): match the Go trace agent when parsing `datadog-client-computed-*` bool headers (#2071) - revert!: add from_string to span text (#2011) (#2073) - fix(send_with_retry): follow max retries of the strategy (#2047) ## libdd-sampling (manually bumped due to breaking in #2073) **Next version:** ~~`2.1.1`~~ `3.0.0` **Semver bump:** ~~`patch`~~ `major` **Tag:** ~~`libdd-sampling-v2.1.1`~~ `libdd-sampling-v3.0.0` ### Commits - fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant digits (#2086) - revert!: add from_string to span text (#2011) (#2073) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com> Co-authored-by: iunanua <igor.unanua@datadoghq.com>
What does this PR do?
Make the span fields mutable by requiring From on SpanText and switching SpanSlice to use Cow
Motivation
Needed to apply normalization on the span, required by trace filters.
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.