Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
parse_ints
config in json parser to support parsing int or float properly #33699Add
parse_ints
config in json parser to support parsing int or float properly #33699Changes from 1 commit
06b8e50
e3b3b43
cb7ce2d
5ad9c68
87ed62a
a260977
299ec68
0a2882e
18a8d0f
66df47e
8ab600d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Do we want to expose all these options to the users?
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.
I agree, my second thought on this is at least at this moment we should only expose options we needed, to not bind to the json iterator so tight.
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.
currently
json_parser
usesjsoniter.ConfigFastest
which has 2 more options enabledto add the
use_number
config, it looks like we have to create a newjsoniter.Config
object probably to have the same config so users are not surprised, I think it makes sense to allow user to be able to turn offMarshalFloatWith6Digits
as well. any thoughts or comments on this?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.
I agree we should only expose what is needed, and we should consider that perhaps some day we need to switch json parsing libraries.
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.
I was wrong about
MarshalFloatWith6Digits
, it doesn't affect unmarshal, only marshal, which is not related to the parser. so for now I only added config forUseNumber
.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.
Doing the conversion explicitly here makes me wonder what is the actual reason for defining the
UseNumber
setting in thejson
object's config at first place 🤔 ?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.
I am not sure either. Looking at the encoding/json it looks like not as these many options as json iterator, which makes more sense to me to only expose
use_number
option for now.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.
So what's the point of enabling the
UseNumber
of thejsoniter.Config
? Is this required for some reason? If so I suggest we document this at https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33699/files#diff-158189e84f05b177451492225bc83c2c23fa140cffdd4c5f9bf7db6ada8edc3aR54.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.
Added comment, please also check this test that when UseNumber is false, regardless the data is int or float, they will be parsed as
float64
. https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33699/files#diff-f811622a59595f3ded728a9213b5e08d0c5fbe91c4cfff23b25d037f84e1f953R142-R155