Add support for DogStatsD v1.1 - value packing#762
Add support for DogStatsD v1.1 - value packing#762tiedotguy merged 3 commits intoatlassian:masterfrom
Conversation
| for _, v := range m.Values { | ||
| valueSum += v | ||
| } | ||
| value := int64(valueSum / m.Rate) |
There was a problem hiding this comment.
I'm not sure about this one but sum / rate is the same as sum (each / rate) so it should be fine
There was a problem hiding this comment.
It puts it on the sender to include rate as part of the consolidation key (which I know Jira has considered), but no hazard on the server side.
| return ms[i].StringValue < ms[j].StringValue | ||
| } else { | ||
| return ms[i].Value < ms[j].Value | ||
| return ms[i].Values[0] < ms[j].Values[0] |
There was a problem hiding this comment.
Note for other reviewers: this code path is used in tests, to provide stable sorting, and making it easier to compare lists. It doesn't need to be perfect in production, just good enough in tests.
| func (mm *MetricMap) receiveGauge(m *Metric, tagsKey string) { | ||
| v, ok := mm.Gauges[m.Name] | ||
| // Assuming here that the last value in value packing chain came as last | ||
| // It might be incorrect if sender sorts the array before sending but why would they |
| for _, v := range m.Values { | ||
| valueSum += v | ||
| } | ||
| value := int64(valueSum / m.Rate) |
There was a problem hiding this comment.
It puts it on the sender to include rate as part of the consolidation key (which I know Jira has considered), but no hazard on the server side.
internal/lexer/lexer.go
Outdated
| v, err := strconv.ParseFloat(l.m.StringValue, 64) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| // Count number of colons to preallocate array |
There was a problem hiding this comment.
is it count number of colons? why it starts from 1?
based on the code below I guess it's actually the count of values split by colons?
There was a problem hiding this comment.
We start at count = 1. There's always 1 more value than there is colons.
edit: unless there's empty values, but this is pre-alocation, so we're just trying to avoid re-allocations. We can go a bit over.
There was a problem hiding this comment.
I've changed the comment and logic a bit to make it clearer.
Add support for value packing, a change in protocol introduced in https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/?tab=metrics#dogstatsd-protocol-v11