Documentation
¶
Overview ¶
Package metrics 提供了 dep2p 的指标收集和报告接口。
Package metrics 提供了 dep2p 的指标收集和报告接口。
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 跟踪本地节点传输的入站和出站数据。 可用的指标包括总带宽、所有对等节点/协议的带宽,以及按远程对等节点ID和协议ID分段的带宽。
func NewBandwidthCounter ¶
func NewBandwidthCounter() *BandwidthCounter
NewBandwidthCounter 创建一个新的 BandwidthCounter。
返回值:
- *BandwidthCounter: 新创建的带宽计数器实例
func (*BandwidthCounter) GetBandwidthByPeer ¶
func (bwc *BandwidthCounter) GetBandwidthByPeer() map[peer.ID]Stats
GetBandwidthByPeer 返回一个包含所有记住的对等节点和每个对等节点的带宽指标的map。 该方法可能非常昂贵。
返回值:
- map[peer.ID]Stats: 每个对等节点的带宽统计信息映射
func (*BandwidthCounter) GetBandwidthByProtocol ¶
func (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats
GetBandwidthByProtocol 返回一个包含所有记住的协议和每个协议的带宽指标的map。 该方法可能比较昂贵。
返回值:
- map[protocol.ID]Stats: 每个协议的带宽统计信息映射
func (*BandwidthCounter) GetBandwidthForPeer ¶
func (bwc *BandwidthCounter) GetBandwidthForPeer(p peer.ID) (out Stats)
GetBandwidthForPeer 返回一个包含带宽指标的Stats结构体,关联到给定的peer.ID。 返回的指标包括所有发送/接收的流量,无论协议如何。
参数:
- p: 对等节点ID
返回值:
- Stats: 包含该对等节点的带宽统计信息
func (*BandwidthCounter) GetBandwidthForProtocol ¶
func (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Stats)
GetBandwidthForProtocol 返回一个包含带宽指标的Stats结构体,关联到给定的协议ID。 返回的指标包括所有发送/接收的流量,无论哪个对等节点参与。
参数:
- proto: 协议ID
返回值:
- Stats: 包含该协议的带宽统计信息
func (*BandwidthCounter) GetBandwidthTotals ¶
func (bwc *BandwidthCounter) GetBandwidthTotals() (out Stats)
GetBandwidthTotals 返回一个包含带宽指标的Stats结构体,关联到所有发送/接收的流量,无论协议或远程对等节点ID。
返回值:
- Stats: 包含总体带宽统计信息
func (*BandwidthCounter) LogRecvMessage ¶
func (bwc *BandwidthCounter) LogRecvMessage(size int64)
LogRecvMessage 记录传入消息的大小,不关联带宽到特定对等节点或协议。
参数:
- size: 消息大小(字节)
func (*BandwidthCounter) LogRecvMessageStream ¶
LogRecvMessageStream 记录传入消息的大小,关联带宽到给定的协议ID和peer.ID。
参数:
- size: 消息大小(字节)
- proto: 协议ID
- p: 对等节点ID
func (*BandwidthCounter) LogSentMessage ¶
func (bwc *BandwidthCounter) LogSentMessage(size int64)
LogSentMessage 记录传出消息的大小,不关联带宽到特定对等节点或协议。
参数:
- size: 消息大小(字节)
func (*BandwidthCounter) LogSentMessageStream ¶
LogSentMessageStream 记录传出消息的大小,关联带宽到给定的协议ID和peer.ID。
参数:
- size: 消息大小(字节)
- proto: 协议ID
- p: 对等节点ID
func (*BandwidthCounter) TrimIdle ¶
func (bwc *BandwidthCounter) TrimIdle(since time.Time)
TrimIdle 清除所有自给定时间以来未使用的计时器。
参数:
- since: 空闲时间阈值
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 提供记录和检索指标的方法。