mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 14:16:21 +00:00
b37fda7731
* Rebase on 1.8.5 * Remove outdated patches and apply all others * Use shh_post that returns hash * Use bloom filter for request to mailserver * Remove tests for sending messages without subbing first * Fix deadlock in ethdb * Expect null if receipt is not yet created * Subscribe to messages before sending them in whisper test
32 lines
749 B
Go
32 lines
749 B
Go
package metrics
|
|
|
|
import (
|
|
"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) {
|
|
return json.Marshal(r.GetAll())
|
|
}
|
|
|
|
// WriteJSON writes metrics from the given registry periodically to the
|
|
// specified io.Writer as JSON.
|
|
func WriteJSON(r Registry, d time.Duration, w io.Writer) {
|
|
for range time.Tick(d) {
|
|
WriteJSONOnce(r, w)
|
|
}
|
|
}
|
|
|
|
// WriteJSONOnce writes metrics from the given registry to the specified
|
|
// io.Writer as JSON.
|
|
func WriteJSONOnce(r Registry, w io.Writer) {
|
|
json.NewEncoder(w).Encode(r)
|
|
}
|
|
|
|
func (p *PrefixedRegistry) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(p.GetAll())
|
|
}
|