aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/prometheus/common/model/value_histogram.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-07-21 10:41:17 +0000
committerTaras Madan <tarasmadan@google.com>2023-07-24 06:24:36 +0000
commitb03242d7ab98645d2c936e1899aac9f0aeb9813e (patch)
tree4f74d0da1ea42a38a125b3a972b44c434b2a38fa /vendor/github.com/prometheus/common/model/value_histogram.go
parentf0f7d1e0a67964f4733690290b236755148b8188 (diff)
mod: do: bump github.com/prometheus/client_golang from 1.14.0 to 1.16.0
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.14.0 to 1.16.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.14.0...v1.16.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/prometheus/common/model/value_histogram.go')
-rw-r--r--vendor/github.com/prometheus/common/model/value_histogram.go50
1 files changed, 27 insertions, 23 deletions
diff --git a/vendor/github.com/prometheus/common/model/value_histogram.go b/vendor/github.com/prometheus/common/model/value_histogram.go
index cc221a886..54bb038cf 100644
--- a/vendor/github.com/prometheus/common/model/value_histogram.go
+++ b/vendor/github.com/prometheus/common/model/value_histogram.go
@@ -18,16 +18,8 @@ import (
"fmt"
"strconv"
"strings"
- "unsafe"
-
- jsoniter "github.com/json-iterator/go"
)
-func init() {
- jsoniter.RegisterTypeEncoderFunc("model.HistogramBucket", marshalHistogramBucketJSON, marshalJSONIsEmpty)
- jsoniter.RegisterTypeEncoderFunc("model.SampleHistogramPair", marshalSampleHistogramPairJSON, marshalJSONIsEmpty)
-}
-
type FloatString float64
func (v FloatString) String() string {
@@ -57,10 +49,24 @@ type HistogramBucket struct {
Count FloatString
}
-// marshalHistogramBucketJSON writes fmt.Sprintf("[%s,%s,%s,%s]", b.Boundaries, b.Lower, b.Upper, b.Count).
-func marshalHistogramBucketJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
- b := *((*HistogramBucket)(ptr))
- MarshalHistogramBucket(b, stream)
+func (s HistogramBucket) MarshalJSON() ([]byte, error) {
+ b, err := json.Marshal(s.Boundaries)
+ if err != nil {
+ return nil, err
+ }
+ l, err := json.Marshal(s.Lower)
+ if err != nil {
+ return nil, err
+ }
+ u, err := json.Marshal(s.Upper)
+ if err != nil {
+ return nil, err
+ }
+ c, err := json.Marshal(s.Count)
+ if err != nil {
+ return nil, err
+ }
+ return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil
}
func (s *HistogramBucket) UnmarshalJSON(buf []byte) error {
@@ -133,21 +139,19 @@ type SampleHistogramPair struct {
Histogram *SampleHistogram
}
-// marshalSampleHistogramPairJSON writes `[ts, "val"]`.
-func marshalSampleHistogramPairJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
- p := *((*SampleHistogramPair)(ptr))
- stream.WriteArrayStart()
- MarshalTimestamp(int64(p.Timestamp), stream)
- stream.WriteMore()
- MarshalHistogram(*p.Histogram, stream)
- stream.WriteArrayEnd()
-}
-
func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
if s.Histogram == nil {
return nil, fmt.Errorf("histogram is nil")
}
- return jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(s)
+ t, err := json.Marshal(s.Timestamp)
+ if err != nil {
+ return nil, err
+ }
+ v, err := json.Marshal(s.Histogram)
+ if err != nil {
+ return nil, err
+ }
+ return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
}
func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {