db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ClientDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "observed_client_distribution",
		Help:      "Number of peers from each of the clients observed",
	},
		[]string{"client"},
	)
	GeoDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "geographical_distribution",
		Help:      "Number of peers from each of the crawled countries",
	},
		[]string{"country"},
	)
	TotPeers = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "total_crawled_peers",
		Help:      "The number of discovered peers with the crawler",
	})
	ConnectedPeers = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "connected_peers",
		Help:      "The number of connected peers with the crawler",
	})
	DeprecatedPeers = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "deprecated_peers",
		Help:      "The number of peers deprecated by the crawler",
	})
	ClientVersionDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "observed_client_version_distribution",
		Help:      "Number of peers from each of the clients versions observed",
	},
		[]string{"client_version"},
	)
	IpDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "observed_ip_distribution",
		Help:      "Number of Ips hosting number of nodes",
	},
		[]string{"numbernodes"},
	)
	RttDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "observed_rtt_distribution",
		Help:      "RTT distribution for the active discovered peers",
	},
		[]string{"secs"},
	)
	TotcontimeDistribution = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "crawler",
		Name:      "observed_total_connected_time_distribution",
		Help:      "Distribution of the connected time for each active discovered peer",
	},
		[]string{"mins"},
	)
)

List of metrics that we are going to export

View Source
var (
	// logging variables
	ModuleName = "PEERSTORE"
	Log        = logrus.WithField(
		"module", ModuleName,
	)

	// TODO: put it into a config-variable
	ExportLoopTime time.Duration = 30 * time.Minute
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Versions []Version
}

Client: stores the information about all versions of the client

func NewClient

func NewClient() *Client

func (*Client) AddVersion

func (c *Client) AddVersion(inputVersion string)

AddVersion This method adds one or creates a new version under the client @param inputVersion: the version to add

func (Client) ReturnTotalCount

func (c Client) ReturnTotalCount() int

ReturnTotalCount This method returns the total number of nodes in any version

type ClientDist

type ClientDist struct {
	Clients map[string]*Client
}

ClientDist: stores the distribution of all watched clients

func NewClientDist

func NewClientDist() ClientDist

Constructor for ClientDist. Instances an empty map

func (*ClientDist) AddClientVersion

func (c *ClientDist) AddClientVersion(clientName, clientVersion string)

AddClientVersion: This method will add one to the count, or create a new entry for the given version in the given client. @param clientName: the name of the client. @param clientVersion: the version to add or create in the given client.

func (ClientDist) GetClientDistribution

func (c ClientDist) GetClientDistribution() map[string]int

GetClientDistribution: This method returns the number of nodes for each watched client. @return a map where key: clientName, value: totalCount.

func (ClientDist) GetClientNames

func (c ClientDist) GetClientNames() []string

GetClientNames: This method returns the names of the watched clients. @return the string array containing the names.

func (ClientDist) GetClientVersionDistribution

func (c ClientDist) GetClientVersionDistribution() map[string]int

GetClientVersionDistribution: This method calculates the distribution of clients and versions. @return a map where key: client_version, value:count.

func (ClientDist) GetCountOfClient

func (c ClientDist) GetCountOfClient(clientName string) int

GetCountOfClient: This method returns the number of watched nodes under the given client. @param clientName: the client to count on. @return the number of nodes.

func (ClientDist) GetTotalCount

func (c ClientDist) GetTotalCount() int

GetTotalCount: This method returns the total number of watched nodes. @return the total number.

type ErrorHandling

type ErrorHandling func(*models.Peer)

type PeerStore

type PeerStore struct {
	Storage         *postgresql.PostgresDBService
	ExporterService *exporters.ExporterService
	// contains filtered or unexported fields
}

func NewPeerStore

func NewPeerStore(ctx context.Context, exporter *exporters.ExporterService, path string, endpoint string, netModel postgresql.NetworkModel) PeerStore

func (*PeerStore) Ctx

func (c *PeerStore) Ctx() context.Context

Ctx Retreives the context asigned to the Peerstore

func (*PeerStore) GetPeerData

func (c *PeerStore) GetPeerData(peerId string) (models.Peer, error)

GetPeerData: This method return a Peer object from the peerstore using the given peerID. @param peerID: the peerID to look for in string format. @return the found Peer object and an error if there was.

func (*PeerStore) GetPeerList

func (c *PeerStore) GetPeerList() []peer.ID

GetPeerList: This method returns the list of PeerIDs in the DB. @return the list of PeerIDs in string format.

func (*PeerStore) ServeMetrics added in v1.1.0

func (ps *PeerStore) ServeMetrics()

ServeMetrics * This method will serve the global peerstore values to the * local prometheus instance

func (*PeerStore) StoreOrUpdatePeer

func (c *PeerStore) StoreOrUpdatePeer(peer models.Peer)

StoreOrUpdatePeer: Updates the peer without overwritting all its content. If peer exists, aggregate data to the existing peer. Otherwise, store the peer. @param peer: the peer to store or update

func (*PeerStore) StorePeer

func (c *PeerStore) StorePeer(peer models.Peer)

StorePeer: This method stores a single peer in the peerstore. It will use the peerID as key. @param peer: the peer object to store.

type StringMapMetric

type StringMapMetric struct {
	// contains filtered or unexported fields
}

StringMapMetric: stores a standard map metric for prometheus.

func NewStringMapMetric

func NewStringMapMetric() StringMapMetric

Constructor for StringMapMetric. creates an empty map.

func (*StringMapMetric) AddOneorCreate

func (m *StringMapMetric) AddOneorCreate(inputKey string)

AddOneorCreate: In case the key does not exist: create. In case it exists, add one. @param inputKey: the key to add or create.

func (StringMapMetric) ObtainDistribution

func (m StringMapMetric) ObtainDistribution() StringMapMetric

ObtainDistribution: This method will calculate the distribution of the curent metric. @return the distribution in a StringMapMetric object.

func (StringMapMetric) SetValues

func (m StringMapMetric) SetValues(registered_name *prometheus.GaugeVec)

SetValues: Given a prometheus registered variable, dump the metrics into it. @param registered_name: the prometheus variable where to dump data.

func (*StringMapMetric) Traspose

func (m *StringMapMetric) Traspose()

Traspose: This method will traspose the current metric. This is: keys are now values and values are now keys.

type Version

type Version struct {
	Name  string
	Count int
}

Version: this struct stores information about a single Client Version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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