go-libp2p-core: github.com/libp2p/go-libp2p-core/metrics Index | Files

package metrics

import "github.com/libp2p/go-libp2p-core/metrics"

Package metrics provides metrics collection and reporting interfaces for libp2p.

Package metrics provides metrics collection and reporting interfaces for libp2p.

Index

Package Files

bandwidth.go register.go reporter.go

func AllViews Uses

func AllViews() []*view.View

AllViews returns all registered views as a single slice

func LookupViews Uses

func LookupViews(name string) ([]*view.View, error)

LookupViews returns all views for a Namespace name. Returns an error if the Namespace has not been registered.

func RegisterViews Uses

func RegisterViews(namespace string, views ...*view.View) error

RegisterViews accepts a namespace and a slice of Views, which will be registered with opencensus and maintained in the global registered views map

type BandwidthCounter Uses

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 Uses

func NewBandwidthCounter() *BandwidthCounter

NewBandwidthCounter creates a new BandwidthCounter.

func (*BandwidthCounter) GetBandwidthByPeer Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (bwc *BandwidthCounter) LogRecvMessageStream(size int64, proto protocol.ID, p peer.ID)

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 Uses

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 Uses

func (bwc *BandwidthCounter) LogSentMessageStream(size int64, proto protocol.ID, p peer.ID)

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) Reset Uses

func (bwc *BandwidthCounter) Reset()

Reset clears all stats.

func (*BandwidthCounter) TrimIdle Uses

func (bwc *BandwidthCounter) TrimIdle(since time.Time)

TrimIdle trims all timers idle since the given time.

type ErrDuplicateNamespaceRegistration Uses

type ErrDuplicateNamespaceRegistration ErrNamespace

ErrDuplicateNamespaceRegistration is an error for a Namespace that has already registered views

func (ErrDuplicateNamespaceRegistration) Error Uses

func (e ErrDuplicateNamespaceRegistration) Error() string

type ErrNamespace Uses

type ErrNamespace struct {
    Namespace string
}

type ErrUnregisteredNamespace Uses

type ErrUnregisteredNamespace ErrNamespace

ErrUnregisteredNamespace is an error for lookup of requested unregistered Namespace

func (ErrUnregisteredNamespace) Error Uses

func (e ErrUnregisteredNamespace) Error() string

type Reporter Uses

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.

type Stats Uses

type Stats struct {
    TotalIn  int64
    TotalOut int64
    RateIn   float64
    RateOut  float64
}

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.

Package metrics imports 7 packages (graph) and is imported by 50 packages. Updated 2020-06-11. Refresh now. Tools for package owners.