metrics

package
v0.0.0-...-a3efb56 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package metrics provides a metric logging wrappers for Prometheus server.

Package metrics provides a metric logging wrappers for Prometheus server.

Package metrics provides a metric logging wrappers for Prometheus server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NetworkIncomingConnections Number of incoming connections
	NetworkIncomingConnections = MetricName{Name: "algod_network_incoming_connections", Description: "Number of incoming connections"}
	// NetworkOutgoingConnections Number of outgoing connections
	NetworkOutgoingConnections = MetricName{Name: "algod_network_outgoing_connections", Description: "Number of outgoing connections"}
	// NetworkOutgoingUniqueConnections Total number of unique outgoing addresses connections ever seen by node.
	NetworkOutgoingUniqueConnections = MetricName{Name: "algod_network_unique_outgoing_connections", Description: "Number of unique outgoing connections"}
	// NetworkPeersGarbageCollected How many peers were not caught by event-based cleanup but instead polling garbage collection thread.
	NetworkPeersGarbageCollected = MetricName{Name: "algod_network_peer_gc", Description: "Number of peers garbage collected instead of normal inline close flow"}
	// NetworkSentBytesTotal Total number of bytes that were sent over the network
	NetworkSentBytesTotal = MetricName{Name: "algod_network_sent_bytes_total", Description: "Total number of bytes that were sent over the network"}
	// NetworkReceivedBytesTotal Total number of bytes that were received from the network
	NetworkReceivedBytesTotal = MetricName{Name: "algod_network_received_bytes_total", Description: "Total number of bytes that were received from the network"}
	// NetworkMessageReceivedTotal Total number of complete messages that were received from the network
	NetworkMessageReceivedTotal = MetricName{Name: "algod_network_message_received_total", Description: "Total number of complete messages that were received from the network"}
	// NetworkMessageSentTotal Total number of complete messages that were sent to the network
	NetworkMessageSentTotal = MetricName{Name: "algod_network_message_sent_total", Description: "Total number of complete messages that were sent to the network"}
	// NetworkConnectionsDroppedTotal Total number of connections that were dropped before a message
	NetworkConnectionsDroppedTotal = MetricName{Name: "algod_network_connections_dropped_total", Description: "Total number of connections that were dropped before a message"}
	// NetworkSentDecompressedBytesTotal Total number of bytes that were sent over the network prior of being compressed
	NetworkSentDecompressedBytesTotal = MetricName{Name: "algod_network_sent_decompressed_bytes_total", Description: "Total number of bytes that were sent over the network prior of being compressed"}
	// NetworkReceivedDecompressedBytesTotal Total number of bytes that were received from the network after of being decompressed
	NetworkReceivedDecompressedBytesTotal = MetricName{Name: "algod_network_received_decompressed_bytes_total", Description: "Total number of bytes that were received from the network after being decompressed"}
	// DuplicateNetworkMessageReceivedTotal Total number of duplicate messages that were received from the network
	DuplicateNetworkMessageReceivedTotal = MetricName{Name: "algod_network_duplicate_message_received_total", Description: "Total number of duplicate messages that were received from the network"}
	// DuplicateNetworkMessageReceivedBytesTotal The total number ,in bytes, of the duplicate messages that were received from the network
	DuplicateNetworkMessageReceivedBytesTotal = MetricName{Name: "algod_network_duplicate_message_received_bytes_total", Description: "The total number ,in bytes, of the duplicate messages that were received from the network"}
	// DuplicateNetworkFilterReceivedTotal Total number of duplicate filter messages (tag MsgDigestSkipTag) that were received from the network
	DuplicateNetworkFilterReceivedTotal = MetricName{Name: "algod_network_duplicate_filter_received_total", Description: "Total number of duplicate filter messages that were received from the network"}
	// OutgoingNetworkMessageFilteredOutTotal Total number of messages that were not sent per peer request
	OutgoingNetworkMessageFilteredOutTotal = MetricName{Name: "algod_outgoing_network_message_filtered_out_total", Description: "Total number of messages that were not sent per peer request"}
	// OutgoingNetworkMessageFilteredOutBytesTotal Total number of bytes saved by not sending messages that were asked not to be sent by peer
	OutgoingNetworkMessageFilteredOutBytesTotal = MetricName{Name: "algod_outgoing_network_message_filtered_out_bytes_total", Description: "Total number of bytes saved by not sending messages that were asked not to be sent by peer"}
	// UnknownProtocolTagMessagesTotal Total number of out-of-protocol tag messages received from the network
	UnknownProtocolTagMessagesTotal = MetricName{Name: "algod_network_unk_tag_messages_total", Description: "Total number of unknown protocol tag messages received from the network"}
	// CryptoGenSigSecretsTotal Total number of calls to GenerateSignatureSecrets()
	CryptoGenSigSecretsTotal = MetricName{Name: "algod_crypto_signature_secrets_generate_total", Description: "Total number of calls to GenerateSignatureSecrets"}
	// CryptoSigSecretsSignTotal Total number of calls to SignatureSecrets.Sign
	CryptoSigSecretsSignTotal = MetricName{Name: "algod_crypto_signature_secrets_sign_total", Description: "Total number of calls to SignatureSecrets.Sign"}
	// CryptoSigSecretsSignBytesTotal Total number of calls to SignatureSecrets.signBytes
	CryptoSigSecretsSignBytesTotal = MetricName{Name: "algod_crypto_signature_secrets_bytes_sign_total", Description: "Total number of calls to SignatureSecrets.signBytes"}
	// CryptoSigSecretsVerifyTotal Total number of calls to SignatureVerifier.Verify
	CryptoSigSecretsVerifyTotal = MetricName{Name: "algod_crypto_signature_secrets_verify_total", Description: "Total number of calls to SignatureVerifier.Verify"}
	// CryptoVRFGenerateTotal Total number of calls to GenerateVRFSecrets()
	CryptoVRFGenerateTotal = MetricName{Name: "algod_crypto_vrf_generate_total", Description: "Total number of calls to GenerateVRFSecrets"}
	// CryptoVRFProveTotal Total number of calls to VRFSecrets.Prove
	CryptoVRFProveTotal = MetricName{Name: "algod_crypto_vrf_prove_total", Description: "Total number of calls to VRFSecrets.Prove"}
	// CryptoVRFHashTotal Total number of calls to VRFProof.Hash
	CryptoVRFHashTotal = MetricName{Name: "algod_crypto_vrf_hash_total", Description: "Total number of calls to VRFProof.Hash"}
	// CryptoVRFVerifyTotal Total number of calls to VRFVerifier.Verify
	CryptoVRFVerifyTotal = MetricName{Name: "algod_crypto_vrf_verify_total", Description: "Total number of calls to VRFVerifier.Verify"}
	// CryptoSigSecretsVerifyBytesTotal Total number of calls to SignatureVerifier.VerifyBytes
	CryptoSigSecretsVerifyBytesTotal = MetricName{Name: "algod_crypto_vrf_bytes_verify_total", Description: "Total number of calls to SignatureVerifier.VerifyBytes"}
	// LedgerTransactionsTotal Total number of transactions written to the ledger
	LedgerTransactionsTotal = MetricName{Name: "algod_ledger_transactions_total", Description: "Total number of transactions written to the ledger"}
	// LedgerRewardClaimsTotal Total number of reward claims written to the ledger
	LedgerRewardClaimsTotal = MetricName{Name: "algod_ledger_reward_claims_total", Description: "Total number of reward claims written to the ledger"}
	// LedgerRound Last round written to ledger
	LedgerRound = MetricName{Name: "algod_ledger_round", Description: "Last round written to ledger"}
	// LedgerDBRound Last round written to ledger
	LedgerDBRound = MetricName{Name: "algod_ledger_dbround", Description: "Last round written to the ledger DB"}

	// AgreementMessagesHandled "Number of agreement messages handled"
	AgreementMessagesHandled = MetricName{Name: "algod_agreement_handled", Description: "Number of agreement messages handled"}
	// AgreementMessagesDropped "Number of agreement messages dropped"
	AgreementMessagesDropped = MetricName{Name: "algod_agreement_dropped", Description: "Number of agreement messages dropped"}

	// TransactionMessagesHandled "Number of transaction messages handled"
	TransactionMessagesHandled = MetricName{Name: "algod_transaction_messages_handled", Description: "Number of transaction messages handled"}
	// TransactionMessagesDroppedFromBacklog "Number of transaction messages dropped from backlog"
	TransactionMessagesDroppedFromBacklog = MetricName{Name: "algod_transaction_messages_dropped_backlog", Description: "Number of transaction messages dropped from backlog"}
	// TransactionMessagesDroppedFromPool "Number of transaction messages dropped from pool"
	TransactionMessagesDroppedFromPool = MetricName{Name: "algod_transaction_messages_dropped_pool", Description: "Number of transaction messages dropped from pool"}
	// TransactionMessagesAlreadyCommitted "Number of duplicate or error transaction messages before placing into a backlog"
	TransactionMessagesAlreadyCommitted = MetricName{Name: "algod_transaction_messages_err_or_committed", Description: "Number of duplicate or error transaction messages after TX handler backlog"}
	// TransactionMessagesTxGroupInvalidFee "Number of transaction messages with invalid txgroup fee"
	TransactionMessagesTxGroupInvalidFee = MetricName{Name: "algod_transaction_messages_txgroup_invalid_fee", Description: "Number of transaction messages with invalid txgroup fee"}
	// TransactionMessagesTxnDroppedCongestionManagement "Number of transaction messages dropped because the tx backlog is under congestion management"
	TransactionMessagesTxnDroppedCongestionManagement = MetricName{Name: "algod_transaction_messages_txn_dropped_congestion_ctrl", Description: "Number of transaction messages dropped because the tx backlog is under congestion management"}
	// TransactionMessagesTxnNotWellFormed "Number of transaction messages not well formed"
	TransactionMessagesTxnNotWellFormed = MetricName{Name: "algod_transaction_messages_txn_notwell_formed", Description: "Number of transaction messages not well formed"}
	// TransactionMessagesTxnSigNotWellFormed "Number of transaction messages with bad formed signature"
	TransactionMessagesTxnSigNotWellFormed = MetricName{Name: "algod_transaction_messages_sig_bad_formed", Description: "Number of transaction messages with bad formed signature"}
	// TransactionMessagesTxnMsigNotWellFormed "Number of transaction messages with bad formed multisig"
	TransactionMessagesTxnMsigNotWellFormed = MetricName{Name: "algod_transaction_messages_msig_bad_formed", Description: "Number of transaction messages with bad formed msig"}
	// TransactionMessagesTxnLogicSig "Number of transaction messages with invalid logic sig"
	TransactionMessagesTxnLogicSig = MetricName{Name: "algod_transaction_messages_logic_sig_failed", Description: "Number of transaction messages with invalid logic sig"}
	// TransactionMessagesTxnSigVerificationFailed "Number of transaction messages with signature verification failed"
	TransactionMessagesTxnSigVerificationFailed = MetricName{Name: "algod_transaction_messages_sig_verify_failed", Description: "Number of transaction messages with signature verification failed"}
	// TransactionMessagesBacklogErr "Number of transaction messages with some validation error"
	TransactionMessagesBacklogErr = MetricName{Name: "algod_transaction_messages_backlog_err", Description: "Number of transaction messages with some validation error"}
	// TransactionMessagesRemember "Number of transaction messages remembered in TX handler"
	TransactionMessagesRemember = MetricName{Name: "algod_transaction_messages_remember", Description: "Number of transaction messages remembered in TX handler"}
	// TransactionMessageTxGroupFull "Number of transaction messages with max txns allowed"
	TransactionMessageTxGroupFull = MetricName{Name: "algod_transaction_messages_txgroup_full", Description: "Number of transaction messages with max txns allowed"}
	// TransactionMessageTxGroupExcessive "Number of transaction messages with greater than max allowed txns"
	TransactionMessageTxGroupExcessive = MetricName{Name: "algod_transaction_messages_txgroup_excessive", Description: "Number of transaction messages with greater than max allowed txns"}
	// TransactionMessagesDupRawMsg "Number of dupe raw transaction messages dropped"
	TransactionMessagesDupRawMsg = MetricName{Name: "algod_transaction_messages_dropped_dup_raw", Description: "Number of dupe raw transaction messages dropped"}
	// TransactionMessagesDupCanonical "Number of transaction messages dropped after canonical re-encoding"
	TransactionMessagesDupCanonical = MetricName{Name: "algod_transaction_messages_dropped_dup_canonical", Description: "Number of transaction messages dropped after canonical re-encoding"}
	// TransactionMessagesAppLimiterDrop "Number of transaction messages dropped after app limits check"
	TransactionMessagesAppLimiterDrop = MetricName{Name: "algod_transaction_messages_dropped_app_limiter", Description: "Number of transaction messages dropped after app limits check"}
	// TransactionMessagesBacklogSize "Number of transaction messages in the TX handler backlog queue"
	TransactionMessagesBacklogSize = MetricName{Name: "algod_transaction_messages_backlog_size", Description: "Number of transaction messages in the TX handler backlog queue"}

	// TransactionGroupTxSyncHandled "Number of transaction groups handled via txsync"
	TransactionGroupTxSyncHandled = MetricName{Name: "algod_transaction_group_txsync_handled", Description: "Number of transaction groups handled via txsync"}
	// TransactionGroupTxSyncRemember "Number of transaction groups remembered via txsync"
	TransactionGroupTxSyncRemember = MetricName{Name: "algod_transaction_group_txsync_remember", Description: "Number of transaction groups remembered via txsync"}
	// TransactionGroupTxSyncAlreadyCommitted "Number of duplicate or error transaction groups received via txsync"
	TransactionGroupTxSyncAlreadyCommitted = MetricName{Name: "algod_transaction_group_txsync_err_or_committed", Description: "Number of duplicate or error transaction groups received via txsync"}

	// BroadcastSignedTxGroupSucceeded "Number of successful broadcasts of local signed transaction groups"
	BroadcastSignedTxGroupSucceeded = MetricName{Name: "algod_broadcast_txgroup_succeeded", Description: "Number of successful broadcasts of local signed transaction groups"}
	// BroadcastSignedTxGroupFailed "Number of failed broadcasts of local signed transaction groups"
	BroadcastSignedTxGroupFailed = MetricName{Name: "algod_broadcast_txgroup_failed", Description: "Number of failed broadcasts of local signed transaction groups"}
)
View Source
var (
	// ErrMetricServiceAlreadyRunning Generated when we call Start and the metric service is already running
	ErrMetricServiceAlreadyRunning = errors.New("MetricService is already running")
	// ErrMetricServiceNotRunning is not currently running
	ErrMetricServiceNotRunning = errors.New("MetricService not running")
	// ErrMetricUnableToRegister unable to register
	ErrMetricUnableToRegister = errors.New("Unable to register metric")
)

Functions

This section is empty.

Types

type Counter

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

Counter represent a single counter variable.

func MakeCounter

func MakeCounter(metric MetricName) *Counter

MakeCounter create a new counter with the provided name and description.

func NewCounter

func NewCounter(name, desc string) *Counter

NewCounter is a shortcut to MakeCounter in one shorter line.

func (*Counter) AddMetric

func (counter *Counter) AddMetric(values map[string]float64)

AddMetric adds the metric into the map

func (*Counter) AddMicrosecondsSince

func (counter *Counter) AddMicrosecondsSince(t time.Time, labels map[string]string)

AddMicrosecondsSince increases counter by microseconds between Time t and now. Fastest if labels is nil

func (*Counter) AddUint64

func (counter *Counter) AddUint64(x uint64, labels map[string]string)

AddUint64 increases counter by x If labels is nil this is much faster than if labels is not nil.

func (*Counter) Deregister

func (counter *Counter) Deregister(reg *Registry)

Deregister deregisters the counter with the default/specific registry

func (*Counter) GetUint64Value

func (counter *Counter) GetUint64Value() (x uint64)

GetUint64Value returns the value of the counter.

func (*Counter) GetUint64ValueForLabels

func (counter *Counter) GetUint64ValueForLabels(labels map[string]string) uint64

GetUint64ValueForLabels returns the value of the counter for the given labels or 0 if it's not found.

func (*Counter) Inc

func (counter *Counter) Inc(labels map[string]string)

Inc increases counter by 1 Much faster if labels is nil or empty.

func (*Counter) Register

func (counter *Counter) Register(reg *Registry)

Register registers the counter with the default/specific registry

func (*Counter) WriteMetric

func (counter *Counter) WriteMetric(buf *strings.Builder, parentLabels string)

WriteMetric writes the metric into the output stream

type Gauge

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

Gauge represent a single gauge variable.

func MakeGauge

func MakeGauge(metric MetricName) *Gauge

MakeGauge create a new gauge with the provided name and description.

func (*Gauge) AddMetric

func (gauge *Gauge) AddMetric(values map[string]float64)

AddMetric adds the metric into the map

func (*Gauge) Deregister

func (gauge *Gauge) Deregister(reg *Registry)

Deregister deregisters the gauge with the default/specific registry

func (*Gauge) GetUint64ValueForLabels

func (gauge *Gauge) GetUint64ValueForLabels(labels map[string]string) uint64

GetUint64ValueForLabels returns the value of the counter for the given labels or 0 if it's not found.

func (*Gauge) Register

func (gauge *Gauge) Register(reg *Registry)

Register registers the gauge with the default/specific registry

func (*Gauge) Set

func (gauge *Gauge) Set(x uint64)

Set sets gauge to x

func (*Gauge) SetLabels

func (gauge *Gauge) SetLabels(x uint64, labels map[string]string)

SetLabels sets gauge to x with labels

func (*Gauge) WriteMetric

func (gauge *Gauge) WriteMetric(buf *strings.Builder, parentLabels string)

WriteMetric writes the metric into the output stream

type Metric

type Metric interface {
	// WriteMetric adds metrics in Prometheus exposition format to buf, including parentLabels tags if provided.
	WriteMetric(buf *strings.Builder, parentLabels string)
	// AddMetric adds metrics to a map, used for reporting in telemetry heartbeat messages.
	AddMetric(values map[string]float64)
}

Metric represent any collectable metric

type MetricName

type MetricName struct {
	Name        string
	Description string
}

MetricName describes the name and description of a single metric

type MetricReporter

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

MetricReporter represent a single running metric server instance

func MakeMetricReporter

func MakeMetricReporter(serviceConfig ServiceConfig) *MetricReporter

MakeMetricReporter creates a new metrics server at the given endpoint.

func (*MetricReporter) ReporterLoop

func (reporter *MetricReporter) ReporterLoop(ctx context.Context)

ReporterLoop is the main reporter loop. It waits until it receives a feedback from the node-exporter regarding the desired post-interval. then, it posts the collected metrics every such and such interval. Note that the context is used to "abort" this thread if needed.

type MetricService

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

MetricService represent a single running metric server instance

func MakeMetricService

func MakeMetricService(config *ServiceConfig) *MetricService

MakeMetricService creates a new metrics server at the given endpoint.

func (*MetricService) Shutdown

func (server *MetricService) Shutdown() error

Shutdown the running server

func (*MetricService) Start

func (server *MetricService) Start(ctx context.Context) error

Start starts the metric server

type Registry

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

Registry represents a single set of metrics registry

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry retrieves the default registry

func MakeRegistry

func MakeRegistry() *Registry

MakeRegistry create a new metric registry

func (*Registry) AddMetrics

func (r *Registry) AddMetrics(values map[string]float64)

AddMetrics will add all the metrics that were registered to this registry

func (*Registry) Deregister

func (r *Registry) Deregister(metric Metric)

Deregister removes the given metric to the registry

func (*Registry) Register

func (r *Registry) Register(metric Metric)

Register add the given metric to the registry

func (*Registry) WriteMetrics

func (r *Registry) WriteMetrics(buf *strings.Builder, parentLabels string)

WriteMetrics will write all the metrics that were registered to this registry

type RuntimeMetrics

type RuntimeMetrics struct {
	deadlock.Mutex
	// contains filtered or unexported fields
}

RuntimeMetrics gathers selected metrics from Go's builtin runtime.metrics package and makes them available as Prometheus metrics.

func NewRuntimeMetrics

func NewRuntimeMetrics(enabledMetrics ...string) *RuntimeMetrics

NewRuntimeMetrics creates a RuntimeMetrics object, provided a list of metric names matching names in Go's metrics.All(). Otherwise, a default list of runtime metrics will be used.

func (*RuntimeMetrics) AddMetric

func (rm *RuntimeMetrics) AddMetric(m map[string]float64)

AddMetric adds runtime metrics to the map used for heartbeat metrics.

func (*RuntimeMetrics) WriteMetric

func (rm *RuntimeMetrics) WriteMetric(buf *strings.Builder, parentLabels string)

WriteMetric writes runtime metrics to the output stream in prometheus exposition format.

type ServiceConfig

type ServiceConfig struct {
	NodeExporterListenAddress string
	Labels                    map[string]string
	NodeExporterPath          string
}

ServiceConfig would contain all the information we need in order to create a listening server endpoint. We might want to support rolling port numbers so that we could easily support multiple endpoints per machine. ( note that multiple endpoints per machine doesn't solve the question "how would the prometheus server figure that out")

type TagCounter

type TagCounter struct {
	Name        string
	Description string

	AllowedTags map[string]bool

	UnknownTag string
	// contains filtered or unexported fields
}

TagCounter holds a set of counters

func NewTagCounter

func NewTagCounter(rootName, desc string, declaredTags ...string) *TagCounter

NewTagCounter makes a set of metrics under rootName for tagged counting. "{TAG}" in rootName is replaced by the tag, otherwise "_{TAG}" is appended. Optionally provided declaredTags counters for these names up front (making them easier to discover).

func NewTagCounterFiltered

func NewTagCounterFiltered(rootName, desc string, allowedTags []string, unknownTag string) *TagCounter

NewTagCounterFiltered makes a set of metrics under rootName for tagged counting. "{TAG}" in rootName is replaced by the tag, otherwise "_{TAG}" is appended. Tags not in allowedTags will be filtered out and ignored. unknownTag may be "" or a value that will be counted for tags not in allowedTags.

func (*TagCounter) Add

func (tc *TagCounter) Add(tag string, val uint64)

Add t[tag] += val, fast and multithread safe

func (*TagCounter) AddMetric

func (tc *TagCounter) AddMetric(values map[string]float64)

AddMetric is part of the Metric interface Copy the values in this TagCounter out into the string-string map.

func (*TagCounter) WriteMetric

func (tc *TagCounter) WriteMetric(buf *strings.Builder, parentLabels string)

WriteMetric is part of the Metric interface

Jump to

Keyboard shortcuts

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