Skip to content
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

Unmarshall numbers in options to number not float64 #308

Merged

Conversation

pavolloffay
Copy link
Member

Resolves #302

Signed-off-by: Pavol Loffay [email protected]

@jpkrohling
Copy link
Contributor

This change is Reviewable

@codecov
Copy link

codecov bot commented Mar 13, 2019

Codecov Report

Merging #308 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #308      +/-   ##
==========================================
+ Coverage   88.64%   88.68%   +0.04%     
==========================================
  Files          70       70              
  Lines        3143     3156      +13     
==========================================
+ Hits         2786     2799      +13     
  Misses        244      244              
  Partials      113      113
Impacted Files Coverage Δ
pkg/apis/jaegertracing/v1/options.go 100% <100%> (ø) ⬆️
pkg/storage/elasticsearch.go 80.95% <0%> (+1.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac49399...475c34d. Read the comment docs.

@@ -38,7 +39,11 @@ func (o *Options) Filter(prefix string) Options {
// UnmarshalJSON implements an alternative parser for this field
func (o *Options) UnmarshalJSON(b []byte) error {
var entries map[string]interface{}
json.Unmarshal(b, &entries)
d := json.NewDecoder(bytes.NewReader(b))
d.UseNumber()
Copy link
Member Author

@pavolloffay pavolloffay Mar 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of context: JSON spec defines numbers as float64 so all number are by default unmarshalled to float64. Our Options.Args() method uses fmt.Sprintf(%v, val) to convert the value to string - the %v formats the float into exponent notation e.g. 5e+06

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details - would it be possible to provide a test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including one that fails the decode, just to improve the code coverage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from it is it ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@pavolloffay pavolloffay requested a review from objectiser March 13, 2019 13:17
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay pavolloffay merged commit 540b7e9 into jaegertracing:master Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants