@@ -16,10 +16,15 @@ package model
1616import (
1717 "math"
1818 "strconv"
19+ "unsafe"
1920
2021 jsoniter "github.com/json-iterator/go"
2122)
2223
24+ func marshalJSONIsEmpty (ptr unsafe.Pointer ) bool {
25+ return false
26+ }
27+
2328// from https://github.com/prometheus/prometheus/blob/main/util/jsonutil/marshal.go
2429// MarshalTimestamp marshals a point timestamp using the passed jsoniter stream.
2530func MarshalTimestamp (t int64 , stream * jsoniter.Stream ) {
@@ -43,10 +48,9 @@ func MarshalTimestamp(t int64, stream *jsoniter.Stream) {
4348 }
4449}
4550
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
4752// 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 ) {
5054 stream .WriteRaw (`"` )
5155 // Taken from https://github.com/json-iterator/go/blob/master/stream_float.go#L71 as a workaround
5256 // 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) {
6973 stream .WriteArrayStart ()
7074 stream .WriteInt32 (b .Boundaries )
7175 stream .WriteMore ()
72- MarshalValue (b .Lower , stream )
76+ MarshalValue (float64 ( b .Lower ) , stream )
7377 stream .WriteMore ()
74- MarshalValue (b .Upper , stream )
78+ MarshalValue (float64 ( b .Upper ) , stream )
7579 stream .WriteMore ()
76- MarshalValue (b .Count , stream )
80+ MarshalValue (float64 ( b .Count ) , stream )
7781 stream .WriteArrayEnd ()
7882}
7983
8084// adapted from https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go
8185func MarshalHistogram (h SampleHistogram , stream * jsoniter.Stream ) {
8286 stream .WriteObjectStart ()
8387 stream .WriteObjectField (`count` )
84- MarshalValue (h .Count , stream )
88+ MarshalValue (float64 ( h .Count ) , stream )
8589 stream .WriteMore ()
8690 stream .WriteObjectField (`sum` )
87- MarshalValue (h .Sum , stream )
91+ MarshalValue (float64 ( h .Sum ) , stream )
8892
8993 bucketFound := false
9094 for _ , bucket := range h .Buckets {
0 commit comments