diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-15 14:54:55 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-15 17:37:47 +0000 |
| commit | e634f4672260dac9c086a06bfe10e4e3859c77a1 (patch) | |
| tree | 07557e75a7e9869bcc68ae88a0cd5c327107b1c2 /pkg | |
| parent | ff69821062c71ece966b670566a493b83c868187 (diff) | |
vm: export VM output metric
VM output we receive on the host is effectively equivalent to RPC recv metric.
If we stop printing programs in the fuzzer, traffic will move from output to RPC.
It will be useful to see this change via metrics.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/rpctype/rpc.go | 8 | ||||
| -rw-r--r-- | pkg/stats/set.go | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/pkg/rpctype/rpc.go b/pkg/rpctype/rpc.go index ef434ebef..39a299653 100644 --- a/pkg/rpctype/rpc.go +++ b/pkg/rpctype/rpc.go @@ -33,18 +33,14 @@ func NewRPCServer(addr, name string, receiver interface{}, useCompression bool) if err := s.RegisterName(name, receiver); err != nil { return nil, err } - formatMB := func(v int, period time.Duration) string { - const KB, MB = 1 << 10, 1 << 20 - return fmt.Sprintf("%v MB (%v kb/sec)", (v+MB/2)/MB, (v+KB/2)/KB/int(period/time.Second)) - } serv := &RPCServer{ ln: ln, s: s, useCompression: useCompression, statSent: stats.Create("rpc sent", "Uncompressed outbound RPC traffic", - stats.Graph("RPC traffic"), stats.Rate{}, formatMB), + stats.Graph("traffic"), stats.Rate{}, stats.FormatMB), statRecv: stats.Create("rpc recv", "Uncompressed inbound RPC traffic", - stats.Graph("RPC traffic"), stats.Rate{}, formatMB), + stats.Graph("traffic"), stats.Rate{}, stats.FormatMB), } return serv, nil } diff --git a/pkg/stats/set.go b/pkg/stats/set.go index 54e44e457..f5671148d 100644 --- a/pkg/stats/set.go +++ b/pkg/stats/set.go @@ -190,6 +190,11 @@ func LenOf(containerPtr any, mu *sync.RWMutex) func() int { } } +func FormatMB(v int, period time.Duration) string { + const KB, MB = 1 << 10, 1 << 20 + return fmt.Sprintf("%v MB (%v kb/sec)", (v+MB/2)/MB, (v+KB/2)/KB/int(period/time.Second)) +} + // Addittionally a custom 'func() int' can be passed to read the metric value from the function. // and 'func(int, time.Duration) string' can be passed for custom formatting of the metric value. |
