packagemetricsimport("encoding/json""io""time")// MarshalJSON returns a byte slice containing a JSON representation of all// the metrics in the Registry.func(r*StandardRegistry)MarshalJSON()([]byte,error){returnjson.Marshal(r.GetAll())}// WriteJSON writes metrics from the given registry periodically to the// specified io.Writer as JSON.funcWriteJSON(rRegistry,dtime.Duration,wio.Writer){forrangetime.Tick(d){WriteJSONOnce(r,w)}}// WriteJSONOnce writes metrics from the given registry to the specified// io.Writer as JSON.funcWriteJSONOnce(rRegistry,wio.Writer){json.NewEncoder(w).Encode(r)}func(p*PrefixedRegistry)MarshalJSON()([]byte,error){returnjson.Marshal(p.GetAll())}