-
Notifications
You must be signed in to change notification settings - Fork 429
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
Refactor span ID and trace ID using newtype pattern #73
Refactor span ID and trace ID using newtype pattern #73
Conversation
Wraps usages of span ID (u64) and trace ID (u128) in single-field tuple structs in order to enforce intention when passing around values of these types. Adds the "SpanId::invalid()" and "TraceId::invalid()" methods for conveniently creating zero-valued instances of both types.
be3e3d8
to
8b58457
Compare
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.
Thanks for the PR! just a few style tweaks requested.
Looks good - thanks for the contributions. I don't have any more to add than what @jtescher has already said. |
4df1714
to
d8d2e92
Compare
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.
Yeah that looks better! just last few comments 🎉
Adds the from_u64 and to_u64 methods to SpanId and the from_u128 and to_u128 methods to TraceId. Facilitates straightforward conversion between the wrapper structs and their wrapped uint types.
d8d2e92
to
d5107d5
Compare
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.
Great thanks!
…telemetry#73) Co-authored-by: Cijo Thomas <[email protected]>
Addresses #11.
This change wraps usages of span ID (u64) and trace ID (u128) in single-field tuple structs in
order to enforce intention when passing around values of these types (i.e. the newtype pattern). Discussion on the advantages and disadvantages of this pattern can be found here.
Also adds the "SpanId::invalid()" and "TraceId::invalid()" convenience methods for creating zero-valued instances of both types.