metrics

package
v0.2.4-0...-f8342f3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeConnectionEvents

func AnalyzeConnectionEvents(eventList []ConnectionEvents, currentTime int64) (int64, int64, float64)

filter the received Connection/Disconnection events generating a counter and the connected time

func FileExists

func FileExists(name string) bool

Exists reports whether the named file or directory exists.

func FilterClientType

func FilterClientType(fullName string) (string, string)

Client utils Main function that will analyze the client type and verion out of the Peer UserAgent return the Client Type and it's verison (if determined)

func GetFullAddress

func GetFullAddress(multiAddrs []string) string

Get the Real Ip Address from the multi Address list TODO: Implement the Private IP filter in a better way

func GetMetricsDuplicate

func GetMetricsDuplicate(original sync.Map) sync.Map

Copy the sync.Map into the local DataFrame (every given interval the main plotter loop will update the information)

func GetTimeMiliseconds

func GetTimeMiliseconds() int64

Types

type AddressList

type AddressList []string

func (*AddressList) AddItem

func (al *AddressList) AddItem(newItem string)

func (*AddressList) GetByIndex

func (al *AddressList) GetByIndex(idx int) string

type CityList

type CityList []string

func (*CityList) AddItem

func (cl *CityList) AddItem(newItem string)

func (*CityList) GetByIndex

func (cl *CityList) GetByIndex(idx int) string

type ClientTypeList

type ClientTypeList []string

func (*ClientTypeList) AddItem

func (ct *ClientTypeList) AddItem(newItem string)

Add new item to the list

func (ClientTypeList) GetArrayByIndexes

func (ct ClientTypeList) GetArrayByIndexes(idxs []int) []string

Add new item to the list

func (*ClientTypeList) GetByIndex

func (ct *ClientTypeList) GetByIndex(idx int) string

Get item from the list from index

type ClientVersionList

type ClientVersionList []string

func (*ClientVersionList) AddItem

func (cv *ClientVersionList) AddItem(newItem string)

Add new item to the list

func (ClientVersionList) GetArrayByIndexes

func (cv ClientVersionList) GetArrayByIndexes(idxs []int) []string

Add new item to the list

func (*ClientVersionList) GetByIndex

func (cv *ClientVersionList) GetByIndex(idx int) string

Get item from the list from index

type ConnectedTimeList

type ConnectedTimeList []float64 // in minutes

func (*ConnectedTimeList) AddItem

func (cl *ConnectedTimeList) AddItem(newItem float64)

func (*ConnectedTimeList) GetByIndex

func (cl *ConnectedTimeList) GetByIndex(idx int) float64

Get item from the list from index

type ConnectionEvents

type ConnectionEvents struct {
	ConnectionType string
	TimeMili       int64
}

Connection event model

type ConnectionList

type ConnectionList []int64

func (*ConnectionList) AddItem

func (cl *ConnectionList) AddItem(newItem int64)

func (*ConnectionList) GetByIndex

func (cl *ConnectionList) GetByIndex(idx int) int64

Get item from the list from index

type CountryList

type CountryList []string

func (*CountryList) AddItem

func (cl *CountryList) AddItem(newItem string)

func (*CountryList) GetByIndex

func (cl *CountryList) GetByIndex(idx int) string

Get item from the list from index

type DisconnectionList

type DisconnectionList []int64

func (*DisconnectionList) AddItem

func (cl *DisconnectionList) AddItem(newItem int64)

func (*DisconnectionList) GetByIndex

func (cl *DisconnectionList) GetByIndex(idx int) int64

Get item from the list from index

type GossipMetrics

type GossipMetrics struct {
	GossipMetrics   sync.Map
	MessageDatabase *database.MessageDatabase
	StartTime       int64 // milliseconds
}

func NewGossipMetrics

func NewGossipMetrics() GossipMetrics

func (*GossipMetrics) AddConnectionEvent

func (c *GossipMetrics) AddConnectionEvent(peerId peer.ID, connectionType string)

Add a connection Event to the given peer

func (*GossipMetrics) AddNewPeer

func (c *GossipMetrics) AddNewPeer(peerId peer.ID)

Add new peer with all the information from the peerstore to the metrics db returns: Alredy (Bool)

func (*GossipMetrics) ExportMetrics

func (c *GossipMetrics) ExportMetrics(filePath string, peerstorePath string, csvPath string, ep track.ExtendedPeerstore) error

Function that Exports the entire Metrics to a .json file (lets see if in the future we can add websockets or other implementations)

func (*GossipMetrics) FillMetrics

func (c *GossipMetrics) FillMetrics(ep track.ExtendedPeerstore)

Function that iterates through the received peers and fills the missing information

func (*GossipMetrics) ImportMetrics

func (c *GossipMetrics) ImportMetrics(importFile string) (error, bool)

Import an old GossipMetrics from given file return: - return error if there was error while reading the file

  • return bool for existing file (true if there was a file to read, return false if there wasn't a file to read)

func (*GossipMetrics) IncomingMessageManager

func (c *GossipMetrics) IncomingMessageManager(peerId peer.ID, topicName string) error

Function that Manages the metrics updates for the incoming messages

func (*GossipMetrics) MarshalMetrics

func (c *GossipMetrics) MarshalMetrics() ([]byte, error)

Function that Wraps/Marshals the content of the sync.Map to be exported as a json

func (*GossipMetrics) MarshalPeerStore

func (c *GossipMetrics) MarshalPeerStore(ep track.ExtendedPeerstore) ([]byte, error)

Function that Wraps/Marshals the content of the Entire Peerstore into a json

type GossipState

type GossipState struct {
	GsNode  pgossip.GossipSub
	CloseGS context.CancelFunc
	// string -> *pubsub.Topic
	Topics sync.Map
	// Validation Filter Flag
	SeenFilter bool
}

type IpApiMessage

type IpApiMessage struct {
	Query       string `json:"query"`
	Status      string `json:"status"`
	Country     string `json:"country"`
	CountryCode string `json:"countryCode"`
	Region      string `json:"region"`
	RegionName  string `json:"regionName"`
	City        string `json:"city"`
	Zip         string `json:"zip"`
	Lat         string `json:"lat"`
	Lon         string `json:"lon"`
	Timezone    string `json:"timezone"`
	Isp         string `json:"isp"`
	Org         string `json:"org"`
	As          string `json:"as"`
}

IP-API message structure

type IpList

type IpList []string

func (*IpList) AddItem

func (il *IpList) AddItem(newItem string)

func (*IpList) GetByIndex

func (il *IpList) GetByIndex(idx int) string

Get item from the list from index

type LatencyList

type LatencyList []float64

func (*LatencyList) AddItem

func (ll *LatencyList) AddItem(newItem float64)

func (*LatencyList) GetByIndex

func (ll *LatencyList) GetByIndex(idx int) float64

Get item from the list from index

type MessageMetrics

type MessageMetrics struct {
	Cnt              int64
	FirstMessageTime int64
	LastMessageTime  int64
}

Information regarding the messages received on the beacon_lock topic

func GetMessageMetrics

func GetMessageMetrics(c *PeerMetrics, topicName string) (mesMetr *MessageMetrics, err error)

func NewMessageMetrics

func NewMessageMetrics() MessageMetrics

func (*MessageMetrics) IncrementCnt

func (c *MessageMetrics) IncrementCnt() int64

Increments the counter of the topic

func (*MessageMetrics) StampTime

func (c *MessageMetrics) StampTime(flag string)

Stamps linux_time(millis) on the FirstMessageTime/LastMessageTime from given args: time (int64), flag string("first"/"last")

type MetricsDataFrame

type MetricsDataFrame struct {
	// Peer Related
	PeerIds        PeerIdList
	NodeIds        NodeIdList
	UserAgent      UserAgentList
	ClientTypes    ClientTypeList
	ClientVersions ClientVersionList
	PubKeys        PubKeyList
	Addresses      AddressList
	Ips            IpList
	Countries      CountryList
	Cities         CityList
	Latencies      LatencyList

	// Metrics Related
	Connections    ConnectionList
	Disconnections DisconnectionList
	ConnectedTimes ConnectedTimeList

	RBeaconBlocks       RBeaconBlockList
	RBeaconAggregations RBeaconAggregationList
	RVoluntaryExits     RVoluntaryExitList
	RProposerSlashings  RProposerSlashingList
	RAttesterSlashings  RAttesterSlashingList

	RTotalMessages TotalMessagesList

	// Aux
	Len        int
	ExportTime int64
}

Main Data Structure that will be used to analyze and plot the metrics

func NewMetricsDataFrame

func NewMetricsDataFrame(metricsCopy sync.Map) *MetricsDataFrame

Generate New DataFrame out of the GossipMetrics sync.Map copy

func (MetricsDataFrame) ExportToCSV

func (mdf MetricsDataFrame) ExportToCSV(filePath string) error

export MetricsDataFrame into a CSV format

type NodeIdList

type NodeIdList []string

func (*NodeIdList) AddItem

func (pl *NodeIdList) AddItem(newItem string)

add new item to the list

func (NodeIdList) GetArrayByIndexes

func (pl NodeIdList) GetArrayByIndexes(idxs []int) []string

get the array sorted by list of indexes

func (*NodeIdList) GetByIndex

func (pl *NodeIdList) GetByIndex(idx int) string

get item form the list by index

type PeerIdList

type PeerIdList []peer.ID

func (*PeerIdList) AddItem

func (pl *PeerIdList) AddItem(newItem peer.ID)

add new item to the list

func (PeerIdList) GetArrayByIndexes

func (pl PeerIdList) GetArrayByIndexes(idxs []int) []peer.ID

get the array sorted by list of indexes

func (*PeerIdList) GetByIndex

func (pl *PeerIdList) GetByIndex(idx int) peer.ID

get item form the list by index

type PeerMetrics

type PeerMetrics struct {
	PeerId     peer.ID
	NodeId     string
	ClientType string
	Pubkey     string
	Addrs      string
	Ip         string
	Country    string
	City       string
	Latency    float64

	ConnectionEvents []ConnectionEvents
	// Counters for the different topics
	BeaconBlock          MessageMetrics
	BeaconAggregateProof MessageMetrics
	VoluntaryExit        MessageMetrics
	ProposerSlashing     MessageMetrics
	AttesterSlashing     MessageMetrics
}

Base Struct for the topic name and the received messages on the different topics

func NewPeerMetrics

func NewPeerMetrics(peerId peer.ID) PeerMetrics

type PubKeyList

type PubKeyList []string

func (*PubKeyList) AddItem

func (pl *PubKeyList) AddItem(newItem string)

func (*PubKeyList) GetByIndex

func (pl *PubKeyList) GetByIndex(idx int) string

get item form the list by index

type RAttesterSlashingList

type RAttesterSlashingList []int64

func (*RAttesterSlashingList) AddItem

func (bb *RAttesterSlashingList) AddItem(newItem int64)

func (*RAttesterSlashingList) GetByIndex

func (bb *RAttesterSlashingList) GetByIndex(idx int) int64

get item form the list by index

type RBeaconAggregationList

type RBeaconAggregationList []int64

func (*RBeaconAggregationList) AddItem

func (bb *RBeaconAggregationList) AddItem(newItem int64)

func (*RBeaconAggregationList) GetByIndex

func (bb *RBeaconAggregationList) GetByIndex(idx int) int64

get item form the list by index

type RBeaconBlockList

type RBeaconBlockList []int64

func (*RBeaconBlockList) AddItem

func (bb *RBeaconBlockList) AddItem(newItem int64)

func (*RBeaconBlockList) GetByIndex

func (bb *RBeaconBlockList) GetByIndex(idx int) int64

get item form the list by index

type RProposerSlashingList

type RProposerSlashingList []int64

func (*RProposerSlashingList) AddItem

func (bb *RProposerSlashingList) AddItem(newItem int64)

func (*RProposerSlashingList) GetByIndex

func (bb *RProposerSlashingList) GetByIndex(idx int) int64

get item form the list by index

type RVoluntaryExitList

type RVoluntaryExitList []int64

func (*RVoluntaryExitList) AddItem

func (bb *RVoluntaryExitList) AddItem(newItem int64)

func (*RVoluntaryExitList) GetByIndex

func (bb *RVoluntaryExitList) GetByIndex(idx int) int64

get item form the list by index

type TotalMessagesList

type TotalMessagesList []int64

func (*TotalMessagesList) AddItem

func (ll *TotalMessagesList) AddItem(newItem int64)

func (*TotalMessagesList) GetByIndex

func (ll *TotalMessagesList) GetByIndex(idx int) int64

Get item from the list from index

type UserAgentList

type UserAgentList []string

func (*UserAgentList) AddItem

func (al *UserAgentList) AddItem(newItem string)

func (*UserAgentList) GetByIndex

func (al *UserAgentList) GetByIndex(idx int) string

Jump to

Keyboard shortcuts

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