EncodeHistogram encodes a Histogram into a byte slice. Handles both regular and custom bucket histograms.
(buf *encoding.Encbuf, h *histogram.Histogram)
| 1184 | // EncodeHistogram encodes a Histogram into a byte slice. Handles both |
| 1185 | // regular and custom bucket histograms. |
| 1186 | func EncodeHistogram(buf *encoding.Encbuf, h *histogram.Histogram) { |
| 1187 | buf.PutByte(byte(h.CounterResetHint)) |
| 1188 | |
| 1189 | buf.PutVarint64(int64(h.Schema)) |
| 1190 | buf.PutBE64(math.Float64bits(h.ZeroThreshold)) |
| 1191 | |
| 1192 | buf.PutUvarint64(h.ZeroCount) |
| 1193 | buf.PutUvarint64(h.Count) |
| 1194 | buf.PutBE64(math.Float64bits(h.Sum)) |
| 1195 | |
| 1196 | buf.PutUvarint(len(h.PositiveSpans)) |
| 1197 | for _, s := range h.PositiveSpans { |
| 1198 | buf.PutVarint64(int64(s.Offset)) |
| 1199 | buf.PutUvarint32(s.Length) |
| 1200 | } |
| 1201 | |
| 1202 | buf.PutUvarint(len(h.NegativeSpans)) |
| 1203 | for _, s := range h.NegativeSpans { |
| 1204 | buf.PutVarint64(int64(s.Offset)) |
| 1205 | buf.PutUvarint32(s.Length) |
| 1206 | } |
| 1207 | |
| 1208 | buf.PutUvarint(len(h.PositiveBuckets)) |
| 1209 | for _, b := range h.PositiveBuckets { |
| 1210 | buf.PutVarint64(b) |
| 1211 | } |
| 1212 | |
| 1213 | buf.PutUvarint(len(h.NegativeBuckets)) |
| 1214 | for _, b := range h.NegativeBuckets { |
| 1215 | buf.PutVarint64(b) |
| 1216 | } |
| 1217 | |
| 1218 | if histogram.IsCustomBucketsSchema(h.Schema) { |
| 1219 | buf.PutUvarint(len(h.CustomValues)) |
| 1220 | for _, v := range h.CustomValues { |
| 1221 | buf.PutBEFloat64(v) |
| 1222 | } |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | // FloatHistogramSamples encodes exponential float histogram samples. |
| 1227 | func (e *Encoder) FloatHistogramSamples(histograms []RefFloatHistogramSample, b []byte) ([]byte, []RefFloatHistogramSample) { |
no test coverage detected
searching dependent graphs…