Skip to content

Commit

Permalink
Marshal nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
elv-nate committed Mar 15, 2024
1 parent 2bf96e9 commit f940e38
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions util/histogram/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ func (h *DurationHistogram) MarshalJSON() ([]byte, error) {
return json.Marshal(h.MarshalGeneric())
}

func (h *DurationHistogram) MarshalArray() []SerializedDurationBin {
v := make([]SerializedDurationBin, len(h.bins))
for i, b := range h.bins {
v[i].Label = b.Label
v[i].Count = b.Count.Load()
v[i].DSum = b.DSum.Load()
}
return v
}

// String returns a string representation of the histogram.
func (h *DurationHistogram) String() string {
bb, err := json.Marshal(h)
Expand Down

0 comments on commit f940e38

Please sign in to comment.