@@ -25,7 +25,6 @@ func marshalJSONIsEmpty(ptr unsafe.Pointer) bool {
25
25
return false
26
26
}
27
27
28
- // from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
29
28
// MarshalTimestamp marshals a point timestamp using the passed jsoniter stream.
30
29
func MarshalTimestamp (t int64 , stream * jsoniter.Stream ) {
31
30
// Write out the timestamp as a float divided by 1000.
@@ -48,7 +47,6 @@ func MarshalTimestamp(t int64, stream *jsoniter.Stream) {
48
47
}
49
48
}
50
49
51
- // from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
52
50
// MarshalValue marshals a point value using the passed jsoniter stream.
53
51
func MarshalValue (v float64 , stream * jsoniter.Stream ) {
54
52
stream .WriteRaw (`"` )
@@ -68,7 +66,8 @@ func MarshalValue(v float64, stream *jsoniter.Stream) {
68
66
stream .WriteRaw (`"` )
69
67
}
70
68
71
- // adapted from https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go
69
+ // MarshalHistogramBucket writes something like: [ 3, "-0.25", "0.25", "3"]
70
+ // See MarshalHistogram to understand what the numbers mean
72
71
func MarshalHistogramBucket (b HistogramBucket , stream * jsoniter.Stream ) {
73
72
stream .WriteArrayStart ()
74
73
stream .WriteInt32 (b .Boundaries )
@@ -81,7 +80,29 @@ func MarshalHistogramBucket(b HistogramBucket, stream *jsoniter.Stream) {
81
80
stream .WriteArrayEnd ()
82
81
}
83
82
84
- // adapted from https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go
83
+ // MarshalHistogram writes something like:
84
+ //
85
+ // {
86
+ // "count": "42",
87
+ // "sum": "34593.34",
88
+ // "buckets": [
89
+ // [ 3, "-0.25", "0.25", "3"],
90
+ // [ 0, "0.25", "0.5", "12"],
91
+ // [ 0, "0.5", "1", "21"],
92
+ // [ 0, "2", "4", "6"]
93
+ // ]
94
+ // }
95
+ //
96
+ // The 1st element in each bucket array determines if the boundaries are
97
+ // inclusive (AKA closed) or exclusive (AKA open):
98
+ //
99
+ // 0: lower exclusive, upper inclusive
100
+ // 1: lower inclusive, upper exclusive
101
+ // 2: both exclusive
102
+ // 3: both inclusive
103
+ //
104
+ // The 2nd and 3rd elements are the lower and upper boundary. The 4th element is
105
+ // the bucket count.
85
106
func MarshalHistogram (h SampleHistogram , stream * jsoniter.Stream ) {
86
107
stream .WriteObjectStart ()
87
108
stream .WriteObjectField (`count` )
0 commit comments