@@ -16,10 +16,15 @@ package model
16
16
import (
17
17
"math"
18
18
"strconv"
19
+ "unsafe"
19
20
20
21
jsoniter "github.com/json-iterator/go"
21
22
)
22
23
24
+ func marshalJSONIsEmpty (ptr unsafe.Pointer ) bool {
25
+ return false
26
+ }
27
+
23
28
// from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
24
29
// MarshalTimestamp marshals a point timestamp using the passed jsoniter stream.
25
30
func MarshalTimestamp (t int64 , stream * jsoniter.Stream ) {
@@ -43,10 +48,9 @@ func MarshalTimestamp(t int64, stream *jsoniter.Stream) {
43
48
}
44
49
}
45
50
46
- // adapted from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
51
+ // from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
47
52
// MarshalValue marshals a point value using the passed jsoniter stream.
48
- func MarshalValue (f FloatString , stream * jsoniter.Stream ) {
49
- v := float64 (f )
53
+ func MarshalValue (v float64 , stream * jsoniter.Stream ) {
50
54
stream .WriteRaw (`"` )
51
55
// Taken from https://github.com/json-iterator/go/blob/master/stream_float.go#L71 as a workaround
52
56
// to https://github.com/json-iterator/go/issues/365 (jsoniter, to follow json standard, doesn't allow inf/nan).
@@ -69,22 +73,22 @@ func MarshalHistogramBucket(b HistogramBucket, stream *jsoniter.Stream) {
69
73
stream .WriteArrayStart ()
70
74
stream .WriteInt32 (b .Boundaries )
71
75
stream .WriteMore ()
72
- MarshalValue (b .Lower , stream )
76
+ MarshalValue (float64 ( b .Lower ) , stream )
73
77
stream .WriteMore ()
74
- MarshalValue (b .Upper , stream )
78
+ MarshalValue (float64 ( b .Upper ) , stream )
75
79
stream .WriteMore ()
76
- MarshalValue (b .Count , stream )
80
+ MarshalValue (float64 ( b .Count ) , stream )
77
81
stream .WriteArrayEnd ()
78
82
}
79
83
80
84
// adapted from https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go
81
85
func MarshalHistogram (h SampleHistogram , stream * jsoniter.Stream ) {
82
86
stream .WriteObjectStart ()
83
87
stream .WriteObjectField (`count` )
84
- MarshalValue (h .Count , stream )
88
+ MarshalValue (float64 ( h .Count ) , stream )
85
89
stream .WriteMore ()
86
90
stream .WriteObjectField (`sum` )
87
- MarshalValue (h .Sum , stream )
91
+ MarshalValue (float64 ( h .Sum ) , stream )
88
92
89
93
bucketFound := false
90
94
for _ , bucket := range h .Buckets {
0 commit comments