-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generic Span #884
Add generic Span #884
Conversation
BenchmarksComparisonBenchmark execution time: 2025-02-21 12:23:29 Comparing candidate commit 4be708f in PR branch Found 3 performance improvements and 0 performance regressions! Performance is the same for 49 metrics, 2 unstable metrics. scenario:benching deserializing traces from msgpack to their internal representation
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
BaselineOmitted due to size. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #884 +/- ##
==========================================
+ Coverage 71.77% 71.79% +0.01%
==========================================
Files 328 328
Lines 48577 48600 +23
==========================================
+ Hits 34866 34892 +26
+ Misses 13711 13708 -3
|
trace-utils/src/span/v04/span.rs
Outdated
/// from a static str. | ||
pub trait SpanValue: Eq + Hash + Borrow<str> {} | ||
/// Implement the SpanValue trait for any type which satisfies the sub trait. | ||
impl<T: Eq + Hash + Borrow<str>> SpanValue for T {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Makes things way more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🎉
I played a bit with your PR to see if associated types make sense here, but after playing I bit, I would prefer the current approach.
trace-utils/src/span/v04/span.rs
Outdated
/// Trait representing the requirements for a type to be used as a Span "string" type. | ||
/// Note: Borrow<str> is not required by the derived traits, but allows to access HashMap elements | ||
/// from a static str. | ||
pub trait SpanValue: Eq + Hash + Borrow<str> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpanValue
is too broad as name, given this is explicitly targeting the strings, I would prefer SpanString
to narrow down the scope.
a6e6591
to
4be708f
Compare
What does this PR do?
Add a span with a generic string type to be used to support BytesStrings and &str.
Motivation
Supporting slice based spans is required to support borrowed payload.
Additional Notes
The functions in
trace-utils/src/span/v04/trace_utils.rs
have been modified to use a generic span to show how to use the new type.Many files have been changed for renaming but most changes are in
trace-utils/src/span/v04
.`
How to test the change?
Describe here in detail how the change can be validated.