Documentation ¶
Overview ¶
Package metrics provides metrics collection and reporting interfaces for libp2p.
Package metrics provides metrics collection and reporting interfaces for libp2p.
Index ¶
- type BandwidthCounter
- func (bwc *BandwidthCounter) GetBandwidthByPeer() map[peer.ID]Stats
- func (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats
- func (bwc *BandwidthCounter) GetBandwidthForPeer(p peer.ID) (out Stats)
- func (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Stats)
- func (bwc *BandwidthCounter) GetBandwidthTotals() (out Stats)
- func (bwc *BandwidthCounter) LogRecvMessage(size int64)
- func (bwc *BandwidthCounter) LogRecvMessageStream(size int64, proto protocol.ID, p peer.ID)
- func (bwc *BandwidthCounter) LogSentMessage(size int64)
- func (bwc *BandwidthCounter) LogSentMessageStream(size int64, proto protocol.ID, p peer.ID)
- func (bwc *BandwidthCounter) Reset()
- func (bwc *BandwidthCounter) TrimIdle(since time.Time)
- type Reporter
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BandwidthCounter ¶
type BandwidthCounter struct {
// contains filtered or unexported fields
}
BandwidthCounter tracks incoming and outgoing data transferred by the local peer. Metrics are available for total bandwidth across all peers / protocols, as well as segmented by remote peer ID and protocol ID.
func NewBandwidthCounter ¶
func NewBandwidthCounter() *BandwidthCounter
NewBandwidthCounter creates a new BandwidthCounter.
func (*BandwidthCounter) GetBandwidthByPeer ¶
func (bwc *BandwidthCounter) GetBandwidthByPeer() map[peer.ID]Stats
GetBandwidthByPeer returns a map of all remembered peers and the bandwidth metrics with respect to each. This method may be very expensive.
func (*BandwidthCounter) GetBandwidthByProtocol ¶
func (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats
GetBandwidthByProtocol returns a map of all remembered protocols and the bandwidth metrics with respect to each. This method may be moderately expensive.
func (*BandwidthCounter) GetBandwidthForPeer ¶
func (bwc *BandwidthCounter) GetBandwidthForPeer(p peer.ID) (out Stats)
GetBandwidthForPeer returns a Stats struct with bandwidth metrics associated with the given peer.ID. The metrics returned include all traffic sent / received for the peer, regardless of protocol.
func (*BandwidthCounter) GetBandwidthForProtocol ¶
func (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Stats)
GetBandwidthForProtocol returns a Stats struct with bandwidth metrics associated with the given protocol.ID. The metrics returned include all traffic sent / recieved for the protocol, regardless of which peers were involved.
func (*BandwidthCounter) GetBandwidthTotals ¶
func (bwc *BandwidthCounter) GetBandwidthTotals() (out Stats)
GetBandwidthTotals returns a Stats struct with bandwidth metrics for all data sent / recieved by the local peer, regardless of protocol or remote peer IDs.
func (*BandwidthCounter) LogRecvMessage ¶
func (bwc *BandwidthCounter) LogRecvMessage(size int64)
LogRecvMessage records the size of an incoming message without associating the bandwith to a specific peer or protocol.
func (*BandwidthCounter) LogRecvMessageStream ¶
LogRecvMessageStream records the size of an incoming message over a single logical stream. Bandwidth is associated with the given protocol.ID and peer.ID.
func (*BandwidthCounter) LogSentMessage ¶
func (bwc *BandwidthCounter) LogSentMessage(size int64)
LogSentMessage records the size of an outgoing message without associating the bandwidth to a specific peer or protocol.
func (*BandwidthCounter) LogSentMessageStream ¶
LogSentMessageStream records the size of an outgoing message over a single logical stream. Bandwidth is associated with the given protocol.ID and peer.ID.
func (*BandwidthCounter) TrimIdle ¶
func (bwc *BandwidthCounter) TrimIdle(since time.Time)
TrimIdle trims all timers idle since the given time.
type Reporter ¶
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 }
Reporter provides methods for logging and retrieving metrics.