metrics

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 13 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"}
	// 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"}
	// 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"}

	// 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"}
)
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 {
	deadlock.Mutex
	// 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) Add

func (counter *Counter) Add(x float64, labels map[string]string)

Add increases counter by x For adding an integer, see AddUint64(x)

func (*Counter) AddMetric

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

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 Add() Calls through to Add() 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) 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 {
	deadlock.Mutex
	// 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) Add

func (gauge *Gauge) Add(x float64, labels map[string]string)

Add increases gauge by x

func (*Gauge) AddMetric

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

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) Register

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

Register registers the gauge with the default/specific registry

func (*Gauge) Set

func (gauge *Gauge) Set(x float64, labels map[string]string)

Set sets gauge to x

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(buf *strings.Builder, parentLabels string)
	AddMetric(values map[string]string)
}

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]string)

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 Segment

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

Segment represent a single segment variable.

func MakeSegment

func MakeSegment(metric *MetricName) *Segment

MakeSegment create a new segment with the provided name and description.

func (*Segment) Deregister

func (segment *Segment) Deregister(reg *Registry)

Deregister deregisters the counter with the default/specific registry

func (*Segment) EnterSegment

func (segment *Segment) EnterSegment(labels map[string]string) (*SegmentInstance, error)

EnterSegment is called when a segment is entered.

func (*Segment) Register

func (segment *Segment) Register(reg *Registry)

Register registers the counter with the default/specific registry

type SegmentInstance

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

SegmentInstance is generated once a segments starts.

func (*SegmentInstance) LeaveSegment

func (segInstance *SegmentInstance) LeaveSegment() error

LeaveSegment is expected to be called via a "defer" statement.

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 StringGauge

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

StringGauge represents a map of key value pairs available to be written with the AddMetric

func MakeStringGauge

func MakeStringGauge() *StringGauge

MakeStringGauge create a new StringGauge.

func (*StringGauge) AddMetric

func (stringGauge *StringGauge) AddMetric(values map[string]string)

AddMetric sets all the key value pairs in the provided map.

func (*StringGauge) Deregister

func (stringGauge *StringGauge) Deregister(reg *Registry)

Deregister deregisters the StringGauge with the default/specific registry

func (*StringGauge) Register

func (stringGauge *StringGauge) Register(reg *Registry)

Register registers the StringGauge with the default/specific registry

func (*StringGauge) Set

func (stringGauge *StringGauge) Set(key string, value string)

Set updates a key with a value.

func (*StringGauge) WriteMetric

func (stringGauge *StringGauge) WriteMetric(buf *strings.Builder, parentLabels string)

WriteMetric omit string gauges from the metrics report, not sure how they act with prometheus

type TagCounter

type TagCounter struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

TagCounter holds a set of counters TagCounter는 일련의 카운터를 보유합니다

func NewTagCounter

func NewTagCounter(rootName, desc 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. NewTagCounter는 태그 카운팅을 위해 rootName 아래에 메트릭 세트를 만듭니다. rootName의 "{TAG}"는 태그로 대체되고, 그렇지 않으면 "_{TAG}"가 추가됩니다.

func (*TagCounter) Add

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

Add t[tag] += val, fast and multithread safe t[tag] += val 추가, 빠르고 다중 스레드 안전

func (*TagCounter) AddMetric

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

AddMetric is part of the Metric interface AddMetric은 Metric 인터페이스의 일부입니다. Copy the values in this TagCounter out into the string-string map. 이 TagCounter의 값을 문자열-문자열 맵으로 복사합니다.

func (*TagCounter) WriteMetric

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

WriteMetric is part of the Metric interface WriteMetric은 Metric 인터페이스의 일부입니다.

Jump to

Keyboard shortcuts

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