package metrics
Import Path
github.com/libp2p/go-libp2p/core/metrics (on go.dev)
Dependency Relation
imports 4 packages, and imported by 3 packages
Involved Source Files
Package metrics provides metrics collection and reporting interfaces for libp2p.
Package metrics provides metrics collection and reporting interfaces for libp2p.
Package-Level Type Names (total 3)
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.
GetBandwidthByPeer returns a map of all remembered peers and the bandwidth
metrics with respect to each. This method may be very expensive.
GetBandwidthByProtocol returns a map of all remembered protocols and
the bandwidth metrics with respect to each. This method may be moderately
expensive.
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.
GetBandwidthForProtocol returns a Stats struct with bandwidth metrics associated with the given protocol.ID.
The metrics returned include all traffic sent / received for the protocol, regardless of which peers were
involved.
GetBandwidthTotals returns a Stats struct with bandwidth metrics for all data sent / received by the
local peer, regardless of protocol or remote peer IDs.
LogRecvMessage records the size of an incoming message
without associating the bandwidth to a specific peer or protocol.
LogRecvMessageStream records the size of an incoming message over a single logical stream.
Bandwidth is associated with the given protocol.ID and peer.ID.
LogSentMessage records the size of an outgoing message
without associating the bandwidth to a specific peer or protocol.
LogSentMessageStream records the size of an outgoing message over a single logical stream.
Bandwidth is associated with the given protocol.ID and peer.ID.
Reset clears all stats.
TrimIdle trims all timers idle since the given time.
*BandwidthCounter : Reporter
func NewBandwidthCounter() *BandwidthCounter
Reporter provides methods for logging and retrieving metrics.
( Reporter) GetBandwidthByPeer() map[peer.ID]Stats
( Reporter) GetBandwidthByProtocol() map[protocol.ID]Stats
( Reporter) GetBandwidthForPeer(peer.ID) Stats
( Reporter) GetBandwidthForProtocol(protocol.ID) Stats
( Reporter) GetBandwidthTotals() Stats
( Reporter) LogRecvMessage(int64)
( Reporter) LogRecvMessageStream(int64, protocol.ID, peer.ID)
( Reporter) LogSentMessage(int64)
( Reporter) LogSentMessageStream(int64, protocol.ID, peer.ID)
*BandwidthCounter
func github.com/libp2p/go-libp2p.BandwidthReporter(rep Reporter) libp2p.Option
func github.com/libp2p/go-libp2p/p2p/net/swarm.WithMetrics(reporter Reporter) swarm.Option
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.
RateIn float64
RateOut float64
TotalIn int64
TotalOut int64
func (*BandwidthCounter).GetBandwidthByPeer() map[peer.ID]Stats
func (*BandwidthCounter).GetBandwidthByProtocol() map[protocol.ID]Stats
func (*BandwidthCounter).GetBandwidthForPeer(p peer.ID) (out Stats)
func (*BandwidthCounter).GetBandwidthForProtocol(proto protocol.ID) (out Stats)
func (*BandwidthCounter).GetBandwidthTotals() (out Stats)
func Reporter.GetBandwidthByPeer() map[peer.ID]Stats
func Reporter.GetBandwidthByProtocol() map[protocol.ID]Stats
func Reporter.GetBandwidthForPeer(peer.ID) Stats
func Reporter.GetBandwidthForProtocol(protocol.ID) Stats
func Reporter.GetBandwidthTotals() Stats
Package-Level Functions (only one)
NewBandwidthCounter creates a new BandwidthCounter.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |