-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 unmarshalling for pdata.Traces #1948
Add unmarshalling for pdata.Traces #1948
Conversation
|
Codecov Report
@@ Coverage Diff @@
## master #1948 +/- ##
=======================================
Coverage 91.41% 91.41%
=======================================
Files 284 284
Lines 16788 16793 +5
=======================================
+ Hits 15347 15352 +5
Misses 1009 1009
Partials 432 432
Continue to review full report at Codecov.
|
d509d24
to
925a9ef
Compare
if err := proto.Unmarshal(data, traces); err != nil { | ||
return err | ||
} | ||
*td.orig = traces.ResourceSpans |
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.
This won't work for zero-initialized td
. Instead I suggest to change FromOtlpProtoBytes to take a pointer receiver and here do
td.orig = &traces.ResourceSpans
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.
If you look at similar ToOtlpProtoBytes - it has the same problem (actually I see no problem, no one guarantees zero-initialized structure to work properly). I cannot change abovementioned function, because this would break compatibility, and in my opinion it's better to be consistent in this case. Or even return to the first solution where function wasn't on the structure
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.
Hmm, it is unfortunate that we used value receivers on Traces
, but it is too late now, so you are right, we need to use value receivers for consistency now. Please add a comment to FromOtlpProtoBytes to tell that NewTraces must be used to create the instance before calling this function. It is easy to make the mistake since one will probably try this first and will fail:
var td pdata.Traces
td.FromOtlpProtoBytes(someData)
@tigrannajaryan Added comment. Should be good to go |
Thanks @Vemmy124 |
Description:
Adding a feature - allow to unmarshal pdata.Traces from protobuf
Link to tracking Issue: #1939
Testing: unmarshal(marshal(trace)) = trace