-
Notifications
You must be signed in to change notification settings - Fork 110
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
Fix attributes protobuf encoding #609
Fix attributes protobuf encoding #609
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #609 +/- ##
==========================================
+ Coverage 72.26% 72.58% +0.31%
==========================================
Files 60 60
Lines 1904 1922 +18
==========================================
+ Hits 1376 1395 +19
+ Misses 528 527 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
d380416
to
1492640
Compare
Co-authored-by: Tristan Sloughter <[email protected]>
end | ||
end; | ||
to_any_value(Value) -> | ||
#{value => {string_value, to_binary(io_lib:format("~p", [Value]))}}. |
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.
Why is this used now instead of unicode:characters_to_binary
?
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.
similarly, if using ~p
I would imagine wanting ~tp
as well at least.
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 is not a new addition but only old code that changed position. It is the catch-all clause for values that do not fall into the attributes allowed types.
Be aware that it's not calling list_to_binary
but only a private to_binary
function (already defined in the old code) that is exactly unicode:characters_to_binary
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.
Ah, I see now. Got confused using the diff.
But the use of unicode:character_to_binary
to tell if a list is a string is still removed, right? That is what I noticed and lead me to misread this code as new.
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.
Yes, it has been removed, that part was the bug.
Attribute values are correctly typed to not be charlist because in that case they are totally undistinguishable from list of integers (that is an allowed attribute value).
So I removed the conversion of charlist to string_value
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.
One reason to construct an attributes record manually is to use in multiple signals, so then it'd somehow have to know if you aren't using any signal (traces, metrics, logs) to know if it should no-op.
Having the option to pass just a map/list instead of the record does at least give the user the ability to pass attributes only to a single signal in a call like with_span
and have them ignored.
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.
We can accept both raw maps/lists or attributes record and document that if a record is used the validation and truncation overhead is executed also in a noop case. If a user want to be sure to not add overhead when not needed then he should use maps/lists.
But he main point is that I would like to only save attributes in the validated record form so that exporters downstream do not need to re-validate attributes.
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.
Did we have a path forward on this? hehe
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.
No, sorry, too many open branches and I forgot about this one, I'll take a look in the next few days
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.
Closing in favor of #633
Attributes with array values are wrongly encoded by exporter:
See specification about attributes
At the moment I choose to emit an error for nested arrays and omit them from the export but not sure it is the best option