-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 base64 encoding issue in stats #7187
Conversation
@e-dard, thanks for your PR! By analyzing the annotation information on this pull request, we identified @joelegasse and @gunnaraasen to be potential reviewers |
👍 |
1 similar comment
👍 |
excellent, thanks! |
can this be cherry-picked into 1.0? |
I think a better way to do this would be just to make a func (s *Statistic) MarshalJSON() ([]byte, error) {
var o struct {
Name string `json:"name"`
Tags map[string]string `json:"tags"`
Values map[string]interface{} `json:"values"`
}
o.Name = s.Name
o.Tags = s.Tags.Map()
o.Values = s.Values
return json.Marshal(&o)
} Then you don't have to make any other changes and you potentially get the performance improvements you're supposed to get from Ben's change to reduce memory allocations. |
@jsternberg that was the initial quick-fix yes. But then looking through the code it was clear there was a lot of extra complexity we could remove. I don't think we would get any performance improvements with the |
Required for all non-trivial PRs
Fixes #7177.
This PR changes the tags in
/debug/vars
to use amap[string]string
, which ensures they're encoded correctly in the JSON response, as well as saving on some cycles by reducing the amount of sorting and hashing we are doing of various values.It also fixes some possible bugs:
opentsdb.Service.Statistics
was ignoring any passed in tags;udp.Service.Statistics
was ignoring any passed in tags;subsriber.balancewriter.Statistics
was overwriting passed in tags with default values.@jwilder @sparrc @corylanou