metrics

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2021 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 7 Imported by: 7

Documentation

Overview

Package metrics provides metrics collection and reporting interfaces for p2p.

Package metrics provides metrics collection and reporting interfaces for p2p.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllViews

func AllViews() []*view.View

AllViews returns all registered views as a single slice

func LookupViews

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

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

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

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

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

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

func (bwc *BandwidthCounter) Reset()

Reset clears all stats.

func (*BandwidthCounter) TrimIdle

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

TrimIdle trims all timers idle since the given time.

type ErrDuplicateNamespaceRegistration

type ErrDuplicateNamespaceRegistration ErrNamespace

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

func (ErrDuplicateNamespaceRegistration) Error

type ErrNamespace

type ErrNamespace struct {
	Namespace string
}

type ErrUnregisteredNamespace

type ErrUnregisteredNamespace ErrNamespace

ErrUnregisteredNamespace is an error for lookup of requested unregistered Namespace

func (ErrUnregisteredNamespace) Error

func (e ErrUnregisteredNamespace) Error() string

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.

type Stats

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL