...
1 package metrics
2
3 import (
4 "encoding/json"
5 "io"
6 "time"
7 )
8
9
10
11 func (r *StandardRegistry) MarshalJSON() ([]byte, error) {
12 return json.Marshal(r.GetAll())
13 }
14
15
16
17 func WriteJSON(r Registry, d time.Duration, w io.Writer) {
18 for _ = range time.Tick(d) {
19 WriteJSONOnce(r, w)
20 }
21 }
22
23
24
25 func WriteJSONOnce(r Registry, w io.Writer) {
26 json.NewEncoder(w).Encode(r)
27 }
28
29 func (p *PrefixedRegistry) MarshalJSON() ([]byte, error) {
30 return json.Marshal(p.GetAll())
31 }
32
View as plain text