Adapted from https://github.com/prometheus/client_golang/blob/4b158abea9470f75b6f07460cdc2189b91914562/api/prometheus/v1/api.go#L252.
(iter *jsoniter.Iterator)
| 638 | |
| 639 | // Adapted from https://github.com/prometheus/client_golang/blob/4b158abea9470f75b6f07460cdc2189b91914562/api/prometheus/v1/api.go#L252. |
| 640 | func unmarshalHistogramBucket(iter *jsoniter.Iterator) (*HistogramBucket, error) { |
| 641 | b := HistogramBucket{} |
| 642 | if !iter.ReadArray() { |
| 643 | return nil, errors.New("HistogramBucket must be [boundaries, lower, upper, count]") |
| 644 | } |
| 645 | boundaries, err := iter.ReadNumber().Int64() |
| 646 | if err != nil { |
| 647 | return nil, err |
| 648 | } |
| 649 | b.Boundaries = int32(boundaries) |
| 650 | if !iter.ReadArray() { |
| 651 | return nil, errors.New("HistogramBucket must be [boundaries, lower, upper, count]") |
| 652 | } |
| 653 | f, err := strconv.ParseFloat(iter.ReadString(), 64) |
| 654 | if err != nil { |
| 655 | return nil, err |
| 656 | } |
| 657 | b.Lower = f |
| 658 | if !iter.ReadArray() { |
| 659 | return nil, errors.New("HistogramBucket must be [boundaries, lower, upper, count]") |
| 660 | } |
| 661 | f, err = strconv.ParseFloat(iter.ReadString(), 64) |
| 662 | if err != nil { |
| 663 | return nil, err |
| 664 | } |
| 665 | b.Upper = f |
| 666 | if !iter.ReadArray() { |
| 667 | return nil, errors.New("HistogramBucket must be [boundaries, lower, upper, count]") |
| 668 | } |
| 669 | f, err = strconv.ParseFloat(iter.ReadString(), 64) |
| 670 | if err != nil { |
| 671 | return nil, err |
| 672 | } |
| 673 | b.Count = f |
| 674 | if iter.ReadArray() { |
| 675 | return nil, errors.New("HistogramBucket has too many values, must be [boundaries, lower, upper, count]") |
| 676 | } |
| 677 | return &b, nil |
| 678 | } |
| 679 | |
| 680 | // Adapted from https://github.com/prometheus/client_golang/blob/4b158abea9470f75b6f07460cdc2189b91914562/api/prometheus/v1/api.go#L137. |
| 681 | func MarshalSampleHistogramPairJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) { |
no outgoing calls
no test coverage detected