clientinfo

package
v0.0.0-rehearsal.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 16 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ConnectedPeersCountMetricName          = "connected_peers_count"
	ConnectedWellknownPeersCountMetricName = "connected_wellknown_peers_count"
	EthConnectivityMetricName              = "eth_connectivity"
	BtcConnectivityMetricName              = "btc_connectivity"
	ClientInfoMetricName                   = "client_info"
)

Names under which metrics are exposed.

NOTE: ConnectedWellknownPeersCountMetricName was renamed from "connected_bootstrap_count" in v2.6.0. Update any Prometheus queries or Grafana dashboards that reference the old name.

View Source
const (
	// DefaultNetworkMetricsTick is the default duration of the
	// observation tick for network metrics.
	DefaultNetworkMetricsTick = 1 * time.Minute
	// DefaultEthereumMetricsTick is the default duration of the
	// observation tick for Ethereum metrics.
	DefaultEthereumMetricsTick = 10 * time.Minute
	// DefaultBitcoinMetricsTick is the default duration of the
	// observation tick for Bitcoin metrics.
	DefaultBitcoinMetricsTick = 10 * time.Minute
	// The duration of the observation tick for all application-specific
	// metrics.
	ApplicationMetricsTick = 1 * time.Minute
)
View Source
const (
	// DKG Metrics
	MetricDKGJoinedTotal              = "dkg_joined_total"
	MetricDKGFailedTotal              = "dkg_failed_total"
	MetricDKGDurationSeconds          = "dkg_duration_seconds"
	MetricDKGValidationTotal          = "dkg_validation_total"
	MetricDKGChallengesSubmittedTotal = "dkg_challenges_submitted_total"
	MetricDKGApprovalsSubmittedTotal  = "dkg_approvals_submitted_total"

	// Signing Metrics
	MetricSigningOperationsTotal      = "signing_operations_total"
	MetricSigningSuccessTotal         = "signing_success_total"
	MetricSigningFailedTotal          = "signing_failed_total"
	MetricSigningDurationSeconds      = "signing_duration_seconds"
	MetricSigningAttemptsPerOperation = "signing_attempts_per_operation"
	MetricSigningTimeoutsTotal        = "signing_timeouts_total"

	// Redemption Metrics
	MetricRedemptionExecutionsTotal        = "redemption_executions_total"
	MetricRedemptionExecutionsSuccessTotal = "redemption_executions_success_total"
	MetricRedemptionExecutionsFailedTotal  = "redemption_executions_failed_total"
	MetricRedemptionActionDurationSeconds  = "redemption_action_duration_seconds"

	// Redemption Proof Submission Metrics (SPV maintainer)
	MetricRedemptionProofSubmissionsTotal        = "redemption_proof_submissions_total"
	MetricRedemptionProofSubmissionsSuccessTotal = "redemption_proof_submissions_success_total"
	MetricRedemptionProofSubmissionsFailedTotal  = "redemption_proof_submissions_failed_total"

	// Wallet Action Metrics (aggregate)
	MetricWalletActionsTotal                 = "wallet_actions_total"
	MetricWalletActionSuccessTotal           = "wallet_action_success_total"
	MetricWalletActionFailedTotal            = "wallet_action_failed_total"
	MetricWalletActionDurationSeconds        = "wallet_action_duration_seconds"
	MetricWalletHeartbeatFailuresTotal       = "wallet_heartbeat_failures_total"
	MetricStuckWalletTransactionsTotal       = "stuck_wallet_transactions_total"
	MetricUnmonitoredWalletTransactionsTotal = "unmonitored_wallet_transactions_total"

	// Coordination Metrics
	MetricCoordinationWindowsDetectedTotal    = "coordination_windows_detected_total"
	MetricCoordinationProceduresExecutedTotal = "coordination_procedures_executed_total"
	MetricCoordinationFailedTotal             = "coordination_failed_total"         // Only when node is leader
	MetricCoordinationLeaderTimeoutTotal      = "coordination_leader_timeout_total" // When follower observes leader timeout
	MetricCoordinationDurationSeconds         = "coordination_duration_seconds"

	// Coordination Window Metrics (per-window tracking)
	MetricCoordinationWindowDurationSeconds    = "coordination_window_duration_seconds"
	MetricCoordinationWindowWalletsCoordinated = "coordination_window_wallets_coordinated"
	MetricCoordinationWindowWalletsSuccessful  = "coordination_window_wallets_successful"
	MetricCoordinationWindowWalletsFailed      = "coordination_window_wallets_failed"
	MetricCoordinationWindowTotalFaults        = "coordination_window_total_faults"
	MetricCoordinationWindowCoordinationBlock  = "coordination_window_coordination_block"

	// Network Metrics
	MetricIncomingMessageQueueSize = "incoming_message_queue_size"
	MetricMessageHandlerQueueSize  = "message_handler_queue_size"
	MetricPeerConnectionsTotal     = "peer_connections_total"
	MetricPeerDisconnectionsTotal  = "peer_disconnections_total"
	MetricMessageBroadcastTotal    = "message_broadcast_total"
	MetricMessageReceivedTotal     = "message_received_total"
	MetricPingTestsTotal           = "ping_test_total"
	MetricPingTestSuccessTotal     = "ping_test_success_total"
	MetricPingTestFailedTotal      = "ping_test_failed_total"
	MetricPingTestDurationSeconds  = "ping_test_duration_seconds"

	// Network Join Request Metrics (inbound connection attempts from peers)
	MetricNetworkJoinRequestsTotal        = "network_join_requests_total"         // Total inbound join attempts
	MetricNetworkJoinRequestsSuccessTotal = "network_join_requests_success_total" // Successful joins
	MetricNetworkJoinRequestsFailedTotal  = "network_join_requests_failed_total"  // Failed joins (handshake failure)
	MetricNetworkHandshakeDurationSeconds = "network_handshake_duration_seconds"  // Handshake duration
	MetricFirewallRejectionsTotal         = "firewall_rejections_total"           // Firewall rejections
	MetricFirewallOnChainChecksTotal      = "firewall_onchain_checks_total"       // Live on-chain IsRecognized calls

	// Wallet Dispatcher Metrics
	MetricWalletDispatcherActiveActions = "wallet_dispatcher_active_actions"
	MetricWalletDispatcherRejectedTotal = "wallet_dispatcher_rejected_total"

	// System Metrics
	MetricCPUUtilization         = "cpu_utilization_percent"
	MetricMemoryUsageMB          = "memory_usage_mb"
	MetricGoroutineCount         = "goroutine_count"
	MetricCPULoadPercent         = "cpu_load_percent"
	MetricRAMUtilizationPercent  = "ram_utilization_percent"
	MetricSwapUtilizationPercent = "swap_utilization_percent"
)

Metric names for performance metrics

View Source
const (
	// JoinFailureReasonTimeout is a handshake aborted by an I/O deadline.
	JoinFailureReasonTimeout = "timeout"
	// JoinFailureReasonEOFReset is a connection closed or reset mid-handshake.
	JoinFailureReasonEOFReset = "eof_reset"
	// JoinFailureReasonProtocolCrypto is a handshake protocol violation or a
	// cryptographic failure (bad signature, key mismatch, malformed message).
	JoinFailureReasonProtocolCrypto = "protocol_crypto"
	// JoinFailureReasonFirewallUnrecognized is a peer rejected because no
	// application recognizes its operator (including negative-cache hits).
	JoinFailureReasonFirewallUnrecognized = "firewall_unrecognized"
	// JoinFailureReasonFirewallRPCError is a firewall validation aborted by
	// an application/RPC error rather than a genuine non-recognition.
	JoinFailureReasonFirewallRPCError = "firewall_rpc_error"
)

Network join request failure reasons. These are the low-cardinality dimensions of MetricNetworkJoinRequestsFailedTotal, exposed as per-reason counters generated with NetworkJoinFailureMetricName. They tell apart the distinct causes that the aggregate failed-joins counter conflates.

Variables

This section is empty.

Functions

func GetAllNetworkJoinFailureReasons

func GetAllNetworkJoinFailureReasons() []string

GetAllNetworkJoinFailureReasons returns all network join request failure reasons that should be tracked.

func GetAllWalletActionTypes

func GetAllWalletActionTypes() []string

GetAllWalletActionTypes returns all wallet action types that should be tracked. ActionNoop is excluded as it's a no-op action.

func NetworkJoinFailureMetricName

func NetworkJoinFailureMetricName(reason string) string

NetworkJoinFailureMetricName generates the per-reason counter name for a network join request failure. reason should be one of the JoinFailureReason* constants. Format: network_join_requests_failed_{reason}_total Example: network_join_requests_failed_timeout_total

func WalletActionMetricName

func WalletActionMetricName(actionType string, metricType string) string

WalletActionMetricName generates a metric name for a specific wallet action type. actionType should be the string representation of the action (e.g., "heartbeat", "deposit_sweep"). metricType should be one of: "total", "success_total", "failed_total", "duration_seconds"

Types

type ApplicationInfo

type ApplicationInfo map[string]interface{}

ApplicationInfo describes data structure of application information.

type Chain

type Chain struct {
	LatestBlockNumber uint `json:"latest_block_number"`
}

Chain describes data structure of a chain information.

type Client

type Client struct {
	ChainAddress string `json:"chain_address"`
	NetworkID    string `json:"network_id"`
	Version      string `json:"version"`
	Revision     string `json:"revision"`
}

Client describes data structure of client information.

type Config

type Config struct {
	Port                   int
	NetworkMetricsTick     time.Duration
	EthereumMetricsTick    time.Duration
	BitcoinMetricsTick     time.Duration
	RPCHealthCheckInterval time.Duration
}

Config stores configuration for the client info.

type Diagnostics

type Diagnostics struct {
	ClientInfo     Client `json:"client_info"`
	ConnectedPeers []Peer `json:"connected_peers"`
	EthChainInfo   Chain  `json:"eth_chain_info"`
	BtcChainInfo   Chain  `json:"btc_chain_info"`
}

Diagnostics describes data structure returned by the diagnostics endpoint.

type NoOpPerformanceMetrics

type NoOpPerformanceMetrics struct{}

NoOpPerformanceMetrics is a no-op implementation of PerformanceMetricsRecorder that can be used when metrics are disabled.

func (*NoOpPerformanceMetrics) GetCounterValue

func (n *NoOpPerformanceMetrics) GetCounterValue(name string) float64

GetCounterValue always returns 0.

func (*NoOpPerformanceMetrics) GetGaugeValue

func (n *NoOpPerformanceMetrics) GetGaugeValue(name string) float64

GetGaugeValue always returns 0.

func (*NoOpPerformanceMetrics) IncrementCounter

func (n *NoOpPerformanceMetrics) IncrementCounter(name string, value float64)

IncrementCounter is a no-op.

func (*NoOpPerformanceMetrics) RecordDuration

func (n *NoOpPerformanceMetrics) RecordDuration(name string, duration time.Duration)

RecordDuration is a no-op.

func (*NoOpPerformanceMetrics) SetGauge

func (n *NoOpPerformanceMetrics) SetGauge(name string, value float64)

SetGauge is a no-op.

type Peer

type Peer struct {
	ChainAddress          string   `json:"chain_address"`
	NetworkID             string   `json:"network_id"`
	NetworkMultiAddresses []string `json:"multiaddrs"`
}

Peer describes data structure of peer information.

type PerformanceMetrics

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

PerformanceMetrics provides a way to record performance-related metrics including operation counts, durations, and queue sizes. It implements PerformanceMetricsRecorder interface.

func NewPerformanceMetrics

func NewPerformanceMetrics(ctx context.Context, registry *Registry) *PerformanceMetrics

NewPerformanceMetrics creates a new performance metrics instance.

func (*PerformanceMetrics) GetCounterValue

func (pm *PerformanceMetrics) GetCounterValue(name string) float64

GetCounterValue returns the current value of a counter.

func (*PerformanceMetrics) GetGaugeValue

func (pm *PerformanceMetrics) GetGaugeValue(name string) float64

GetGaugeValue returns the current value of a gauge.

func (*PerformanceMetrics) IncrementCounter

func (pm *PerformanceMetrics) IncrementCounter(name string, value float64)

IncrementCounter increments a counter metric by the given value. Observers are already registered in registerAllMetrics, so this method only updates the counter value without re-registering observers.

func (*PerformanceMetrics) RecordDuration

func (pm *PerformanceMetrics) RecordDuration(name string, duration time.Duration)

RecordDuration records a duration value in a histogram. The duration is recorded in seconds. Observers are already registered in registerAllMetrics, so this method only updates the histogram without re-registering observers.

func (*PerformanceMetrics) SetGauge

func (pm *PerformanceMetrics) SetGauge(name string, value float64)

SetGauge sets a gauge metric to the given value. Observers are already registered in registerAllMetrics, so this method only updates the gauge value without re-registering observers.

func (*PerformanceMetrics) Stop

func (pm *PerformanceMetrics) Stop()

Stop stops the performance metrics collection goroutines.

type PerformanceMetricsRecorder

type PerformanceMetricsRecorder interface {
	// IncrementCounter increments a counter metric
	IncrementCounter(name string, value float64)
	// RecordDuration records a duration in seconds
	RecordDuration(name string, duration time.Duration)
	// SetGauge sets a gauge metric value
	SetGauge(name string, value float64)
	// GetCounterValue returns current counter value
	GetCounterValue(name string) float64
	// GetGaugeValue returns current gauge value
	GetGaugeValue(name string) float64
}

PerformanceMetricsRecorder provides a simple interface for recording performance metrics. It can be nil if metrics are not enabled.

type RPCHealthChecker

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

RPCHealthChecker performs periodic health checks on Ethereum and Bitcoin RPC endpoints by making actual RPC calls (not just ICMP ping) to verify the services are working.

func NewRPCHealthChecker

func NewRPCHealthChecker(
	registry *Registry,
	ethBlockCounter chain.BlockCounter,
	btcChain bitcoin.Chain,
	checkInterval time.Duration,
) *RPCHealthChecker

NewRPCHealthChecker creates a new RPC health checker instance.

func (*RPCHealthChecker) GetBitcoinBenignHeaderErrorCount

func (r *RPCHealthChecker) GetBitcoinBenignHeaderErrorCount() float64

GetBitcoinBenignHeaderErrorCount returns the number of known-benign -32602 GetBlockHeader errors observed by the Bitcoin health check.

func (*RPCHealthChecker) GetBitcoinHealthStatus

func (r *RPCHealthChecker) GetBitcoinHealthStatus() (isHealthy bool, lastCheck time.Time, lastSuccess time.Time, lastError error, lastDuration time.Duration)

GetBitcoinHealthStatus returns the current Bitcoin RPC health status.

func (*RPCHealthChecker) GetEthereumHealthStatus

func (r *RPCHealthChecker) GetEthereumHealthStatus() (isHealthy bool, lastCheck time.Time, lastSuccess time.Time, lastError error, lastDuration time.Duration)

GetEthereumHealthStatus returns the current Ethereum RPC health status.

func (*RPCHealthChecker) Start

func (r *RPCHealthChecker) Start(ctx context.Context)

Start begins periodic health checks for both Ethereum and Bitcoin RPC endpoints. Safe to call multiple times - only the first call will execute.

type Registry

type Registry struct {
	*clientinfo.Registry
	// contains filtered or unexported fields
}

Registry wraps keep-common clientinfo registry and exposes additional functions for registering client-custom metrics and diagnostics

func Initialize

func Initialize(
	ctx context.Context,
	port int,
) (*Registry, bool)

Initialize set up the client info registry and enables metrics and diagnostics server.

func (*Registry) ObserveApplicationSource

func (r *Registry) ObserveApplicationSource(
	application string,
	inputs map[string]Source,
)

ObserveApplicationSource triggers an observation process of application-specific metrics.

func (*Registry) ObserveBtcConnectivity

func (r *Registry) ObserveBtcConnectivity(
	btcChain bitcoin.Chain,
	tick time.Duration,
)

ObserveBtcConnectivity triggers an observation process of the btc_connectivity metric.

func (*Registry) ObserveConnectedPeersCount

func (r *Registry) ObserveConnectedPeersCount(
	netProvider net.Provider,
	tick time.Duration,
)

ObserveConnectedPeersCount triggers an observation process of the connected_peers_count metric.

func (*Registry) ObserveConnectedWellknownPeersCount

func (r *Registry) ObserveConnectedWellknownPeersCount(
	netProvider net.Provider,
	wellknownPeers []string,
	tick time.Duration,
)

ObserveConnectedWellknownPeersCount triggers an observation process of the connected_wellknown_peers_count metric.

func (*Registry) ObserveEthConnectivity

func (r *Registry) ObserveEthConnectivity(
	blockCounter chain.BlockCounter,
	tick time.Duration,
)

ObserveEthConnectivity triggers an observation process of the eth_connectivity metric.

func (*Registry) RegisterApplicationSource

func (r *Registry) RegisterApplicationSource(
	application string,
	fetchApplicationDiagnostics func() ApplicationInfo,
)

RegisterApplicationSource registers the diagnostics source providing information about the application.

func (*Registry) RegisterBtcChainInfoSource

func (r *Registry) RegisterBtcChainInfoSource(
	btcChain bitcoin.Chain,
)

RegisterBtcChainInfoSource registers the diagnostics source providing information about btc chain.

func (*Registry) RegisterClientInfoSource

func (r *Registry) RegisterClientInfoSource(
	netProvider net.Provider,
	signing chain.Signing,
	clientVersion string,
	clientRevision string,
)

RegisterClientInfoSource registers the diagnostics source providing information about the client itself.

func (*Registry) RegisterConnectedPeersSource

func (r *Registry) RegisterConnectedPeersSource(
	netProvider net.Provider,
	signing chain.Signing,
)

RegisterConnectedPeersSource registers the diagnostics source providing information about connected peers.

func (*Registry) RegisterEthChainInfoSource

func (r *Registry) RegisterEthChainInfoSource(
	blockCounter chain.BlockCounter,
)

RegisterEthChainInfoSource registers the diagnostics source providing information about eth chain.

func (*Registry) RegisterMetricClientInfo

func (r *Registry) RegisterMetricClientInfo(version string)

RegisterMetricClientInfo registers static client information labels for metrics.

type Source

type Source func() float64

Jump to

Keyboard shortcuts

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