-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
reporter.go
31 lines (28 loc) · 947 Bytes
/
reporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package metrics provides metrics collection and reporting interfaces for libp2p.
package metrics
import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
)
// Stats represents a point-in-time snapshot of bandwidth metrics.
//
// The TotalIn and TotalOut fields record cumulative bytes sent / received.
// The RateIn and RateOut fields record bytes sent / received per second.
type Stats struct {
TotalIn int64
TotalOut int64
RateIn float64
RateOut float64
}
// Reporter provides methods for logging and retrieving metrics.
type Reporter interface {
LogSentMessage(int64)
LogRecvMessage(int64)
LogSentMessageStream(int64, protocol.ID, peer.ID)
LogRecvMessageStream(int64, protocol.ID, peer.ID)
GetBandwidthForPeer(peer.ID) Stats
GetBandwidthForProtocol(protocol.ID) Stats
GetBandwidthTotals() Stats
GetBandwidthByPeer() map[peer.ID]Stats
GetBandwidthByProtocol() map[protocol.ID]Stats
}