histogramSamplesV2 encodes the given histogram samples.
(histograms []RefHistogramSample, b []byte)
| 1118 | |
| 1119 | // histogramSamplesV2 encodes the given histogram samples. |
| 1120 | func (*Encoder) histogramSamplesV2(histograms []RefHistogramSample, b []byte) []byte { |
| 1121 | buf := encoding.Encbuf{B: b} |
| 1122 | buf.PutByte(byte(HistogramSamplesV2)) |
| 1123 | |
| 1124 | if len(histograms) == 0 { |
| 1125 | return buf.Get() |
| 1126 | } |
| 1127 | |
| 1128 | var first, prev *RefHistogramSample |
| 1129 | for _, h := range histograms { |
| 1130 | if first == nil { |
| 1131 | first = &h |
| 1132 | buf.PutVarint64(int64(first.Ref)) |
| 1133 | buf.PutVarint64(first.T) |
| 1134 | buf.PutVarint64(first.ST) |
| 1135 | prev = first |
| 1136 | EncodeHistogram(&buf, h.H) |
| 1137 | continue |
| 1138 | } |
| 1139 | |
| 1140 | buf.PutVarint64(int64(h.Ref) - int64(prev.Ref)) |
| 1141 | buf.PutVarint64(h.T - first.T) |
| 1142 | |
| 1143 | writeSTMarker(&buf, h.ST, first.ST, prev.ST) |
| 1144 | EncodeHistogram(&buf, h.H) |
| 1145 | prev = &h |
| 1146 | } |
| 1147 | |
| 1148 | return buf.Get() |
| 1149 | } |
| 1150 | |
| 1151 | // CustomBucketsHistogramSamples appends the encoded custom-bucket histogram |
| 1152 | // samples to b and returns the resulting slice. |
no test coverage detected