-
Notifications
You must be signed in to change notification settings - Fork 9
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
Skip serialization of field Span.error if equals to 0 #500
Conversation
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.
Thank you!
Can we easily add a utest?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #500 +/- ##
=======================================
Coverage ? 69.39%
=======================================
Files ? 201
Lines ? 26745
Branches ? 0
=======================================
Hits ? 18560
Misses ? 8185
Partials ? 0
|
0a23b17
to
75db04e
Compare
Done! |
75db04e
to
2fd168a
Compare
@@ -63,6 +63,10 @@ fn generate_protobuf() { | |||
".pb.Span.spanLinks", | |||
"#[serde(skip_serializing_if = \"::prost::alloc::vec::Vec::is_empty\")]", | |||
); | |||
config.field_attribute( | |||
".pb.Span.error", | |||
"#[serde(skip_serializing_if = \"is_default\")]", |
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.
You can use ::std::i32::is_zero instead.
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.
It fails with
error[E0425]: cannot find function `is_zero` in module `std::i32`
--> libdatadog/trace-protobuf/src/pb.rs:115:35
|
115 | #[serde(skip_serializing_if = "::std::i32::is_zero")]
|
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.
Hm. Well, try i32::is_zero
without the std stuff.
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.
Same.
At first try, I used is_negative
(https://moshg.github.io/rust-std-ja/std/primitive.i32.html#method.is_negative), but it gave me an other error:
error[E0308]: mismatched types
--> trace-protobuf/src/pb.rs:57:23
|
57 | #[derive(Deserialize, Serialize)]
| ^^^^^^^^^ expected `i32`, found `&i32`
...
114 | #[serde(skip_serializing_if = "i32::is_negative")]
| ------------------ arguments to this function are incorrect
2fd168a
to
934db37
Compare
dd150af
to
aa7241c
Compare
021a3bc
to
2f33ff5
Compare
* Skip serialization of field Span.error if equals to 0 * Add tests * Move serde_json in dev-dependencies * Fix clippy
What does this PR do?
It skips the serialization of the field
Span.error
if the value is 0 as it's done by tracers (at least .net and PHP)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.