metrics

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package metrics defines the Prometheus collectors the proxy exposes and the configuration that enables them. Metrics are off unless Config.Enable is set.

A nil *Metrics is a valid no-op, so call sites wire unconditionally and a disabled group costs only a nil check.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable       bool
	HTTP         bool
	Storage      bool
	Queue        bool
	Voting       bool
	ActiveVoters bool
	Result       bool
	Wallet       bool
	Info         bool
	Attestation  bool
	Policy       bool
	Liveness     bool
	Node         bool
	Runtime      bool
}

Config selects which metric groups are collected. The zero value collects nothing; groups take effect only when Enable is true.

type Metrics

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

Metrics owns the Prometheus registry and the collectors for the enabled groups. Collectors for disabled groups are left nil; all methods are safe on a nil receiver.

func New

func New(cfg Config) *Metrics

New builds the registry and registers the collectors for the enabled groups. With Enable false it returns a disabled Metrics over an empty registry.

func (*Metrics) ActionDequeued

func (m *Metrics) ActionDequeued(queue, result string)

ActionDequeued records one dequeue attempt by queue and result.

func (*Metrics) ActionEnqueued added in v0.0.20

func (m *Metrics) ActionEnqueued(queue, result string)

ActionEnqueued records one enqueue attempt by queue and result.

func (*Metrics) ActiveVotersEnabled

func (m *Metrics) ActiveVotersEnabled() bool

ActiveVotersEnabled reports whether the distinct-voter gauge is collected.

func (*Metrics) AttestationVerified

func (m *Metrics) AttestationVerified(result, reason string)

AttestationVerified records one attestation verification by result ("ok"/"error") and bounded reason.

func (*Metrics) Enabled

func (m *Metrics) Enabled() bool

Enabled reports whether metrics collection and the /metrics endpoint are active.

func (*Metrics) FinalizedActionEnqueueFailed

func (m *Metrics) FinalizedActionEnqueueFailed()

FinalizedActionEnqueueFailed records a finalized action that failed to enqueue.

func (*Metrics) FinalizedActionLost added in v0.0.20

func (m *Metrics) FinalizedActionLost(reason string)

FinalizedActionLost records a finalized action lost before the main-queue enqueue or on send to the node, by bounded reason ("build_error", "send_cancelled", "send_failed"). Callers pass compile-time constants, so the reason enum stays closed. It is a sibling of FinalizedActionEnqueueFailed, which keeps counting enqueue failures separately.

func (*Metrics) HTTPEnabled

func (m *Metrics) HTTPEnabled() bool

HTTPEnabled reports whether per-request HTTP metrics are collected.

func (*Metrics) InfoRefreshFailed

func (m *Metrics) InfoRefreshFailed(stage string)

InfoRefreshFailed records a TEE info refresh failure at the given pipeline stage.

func (*Metrics) InfoRefreshObserved

func (m *Metrics) InfoRefreshObserved(d time.Duration, err error)

InfoRefreshObserved records one completed TEE-info refresh by duration and outcome ("ok"/"error"). It gives the failure counter a denominator; the per-stage breakdown stays in info_refresh_failures_total.

func (*Metrics) InstructionReceived

func (m *Metrics) InstructionReceived()

InstructionReceived records one submitted instruction.

func (*Metrics) InstructionRejected

func (m *Metrics) InstructionRejected(reason string)

InstructionRejected records one rejected instruction under a bounded reason.

func (*Metrics) LivenessEnabled

func (m *Metrics) LivenessEnabled() bool

LivenessEnabled reports whether liveness metrics are collected.

func (*Metrics) MachinepathPollObserved added in v0.0.20

func (m *Metrics) MachinepathPollObserved(result string)

MachinepathPollObserved records one machine-path poll-loop outcome under a bounded result ("fetch_error"/"build_error"/"no_authorization"/"enqueue_error"/"wait_error"/"no_change"/"rejected"/"confirmed"); "no_authorization" is an activated list with no forwardable authorization evidence (neither direct signatures nor a verifiable Safe approval — a governance-config condition, split out of "build_error" so it does not read as an infra fault), "rejected" is a node status!=1 rejection (err==nil, so invisible to node_response_wait_total), "wait_error" a failed or timed-out confirmation wait (shutdown cancellations excluded).

func (*Metrics) NodeEnabled added in v0.0.21

func (m *Metrics) NodeEnabled() bool

NodeEnabled reports whether node-interaction metrics are collected.

func (*Metrics) Observe

func (m *Metrics) Observe(backend, ns, operation, outcome string, d time.Duration)

Observe records one storage operation; it satisfies storage.Observer.

func (*Metrics) ObserveHTTP

func (m *Metrics) ObserveHTTP(server, route string, status int, d time.Duration)

ObserveHTTP records one served request. An empty route is reported as "unmatched".

func (*Metrics) ObserveNodeWait

func (m *Metrics) ObserveNodeWait(path string, d time.Duration, err error)

ObserveNodeWait records one synchronous wait for a TEE-node response on the given path ("info"/"machinepath"/"wallet_key_info"/"wallet_key_proof"/"policy_update"), classifying the outcome from err ("ok"/"timeout"/"cancelled"/"error").

func (*Metrics) PolicyEnabled

func (m *Metrics) PolicyEnabled() bool

PolicyEnabled reports whether signing-policy metrics are collected.

func (*Metrics) PolicyUpdate added in v0.0.20

func (m *Metrics) PolicyUpdate(result string)

PolicyUpdate records one signing-policy update-loop iteration under a bounded result (see METRICS.md; build-failure reasons come from policy.UpdateFailureReason).

func (*Metrics) QueueDepthReadFailed added in v0.0.20

func (m *Metrics) QueueDepthReadFailed(queue string)

QueueDepthReadFailed records a scrape-time queue-depth (LLEN) read failure for the given queue.

func (*Metrics) QueueEnabled

func (m *Metrics) QueueEnabled() bool

QueueEnabled reports whether queue metrics are collected.

func (*Metrics) RegisterActiveDataProviderVoters

func (m *Metrics) RegisterActiveDataProviderVoters(count func() float64)

RegisterActiveDataProviderVoters registers a scrape-time gauge of count(), the distinct data-provider voters in the current reward epoch. No-op when active-voters is disabled.

func (*Metrics) RegisterActiveDataProviderWeight added in v0.0.21

func (m *Metrics) RegisterActiveDataProviderWeight(bips func() float64)

RegisterActiveDataProviderWeight registers a scrape-time gauge of bips(), the combined weight of the current reward epoch's data-provider voters. No-op when active-voters is disabled.

func (*Metrics) RegisterActiveInitiators

func (m *Metrics) RegisterActiveInitiators(count func() float64)

RegisterActiveInitiators registers a scrape-time gauge of count(), the distinct voting initiators (proposers) in the current reward epoch. No-op when active-voters is disabled.

func (*Metrics) RegisterCChainDelay added in v0.0.20

func (m *Metrics) RegisterCChainDelay(seconds func() float64)

RegisterCChainDelay registers a scrape-time gauge of seconds since the last c-chain indexer block, read from the indexer DB. No-op when the liveness group is disabled.

func (*Metrics) RegisterGovernanceHashMatch added in v0.0.21

func (m *Metrics) RegisterGovernanceHashMatch(match func() float64)

RegisterGovernanceHashMatch registers a scrape-time gauge reporting whether the governance hash the tee-node last reported still equals the proxy's startup-resolved snapshot (1 = match, 0 = the node's governance rotated after startup, so Safe pre-verification runs against a stale snapshot). Registered only when [governance] is configured; no-op when the node group is disabled.

func (*Metrics) RegisterInfoDelay

func (m *Metrics) RegisterInfoDelay(seconds func() float64)

RegisterInfoDelay registers a gauge reporting seconds() at scrape time. It is a no-op when the liveness group is disabled, so seconds is never invoked.

func (*Metrics) RegisterMaxConsensusEpoch added in v0.0.20

func (m *Metrics) RegisterMaxConsensusEpoch(epoch func() float64)

RegisterMaxConsensusEpoch registers a scrape-time gauge of the highest reward epoch any voting has reached consensus in since process start. No-op when the policy group is disabled.

func (*Metrics) RegisterMaxVotingWeight added in v0.0.21

func (m *Metrics) RegisterMaxVotingWeight(bips func() float64)

RegisterMaxVotingWeight registers a scrape-time gauge of bips(), the highest provider weight any single voting accumulated in the reported reward epoch. No-op when active-voters is disabled.

func (*Metrics) RegisterNodeAppliedPolicy added in v0.0.20

func (m *Metrics) RegisterNodeAppliedPolicy(applied func() float64)

RegisterNodeAppliedPolicy registers a scrape-time gauge of the tee-node's last applied signing-policy reward epoch. No-op when the policy group is disabled.

func (*Metrics) RegisterOldestStoredPolicy

func (m *Metrics) RegisterOldestStoredPolicy(oldest func() float64)

RegisterOldestStoredPolicy registers a scrape-time gauge reporting the oldest reward epoch with a signing policy still resident in the in-memory voting window. The newest/active epoch is already exposed by policy_active_reward_epoch. No-op when the policy group is disabled.

func (*Metrics) RegisterQueueDepth

func (m *Metrics) RegisterQueueDepth(queue string, depth func() float64)

RegisterQueueDepth registers a gauge reporting depth() for the given queue at scrape time. It is a no-op when the queue group is disabled, so depth is never invoked.

func (*Metrics) RegisterTopUnfinalizedProposals

func (m *Metrics) RegisterTopUnfinalizedProposals(top func() []ProviderPending)

RegisterTopUnfinalizedProposals registers a scrape-time collector that emits, per provider, the number of unfinalized proposals it holds — for the providers returned by top() (intended to be the top 3), omitting any with none. No-op when active-voters is disabled.

func (*Metrics) RegisterVotingThreshold added in v0.0.21

func (m *Metrics) RegisterVotingThreshold(bips func() float64)

RegisterVotingThreshold registers a scrape-time gauge of bips(), the reported reward epoch's signing-policy finalization threshold. No-op when active-voters is disabled.

func (*Metrics) RegisterWalletKeysCached added in v0.0.20

func (m *Metrics) RegisterWalletKeysCached(count func() float64)

RegisterWalletKeysCached registers a scrape-time gauge reporting count(), the key proofs cached in the wallet service's in-memory store. No-op when the wallet group is disabled.

func (*Metrics) Registry

func (m *Metrics) Registry() *prometheus.Registry

Registry returns the underlying registry for mounting on an HTTP handler, or nil if metrics are disabled.

func (*Metrics) ResultChannelDropped added in v0.0.20

func (m *Metrics) ResultChannelDropped(channel string)

ResultChannelDropped records one message dropped from a full result fan-out channel under a bounded channel name ("key_actions", "backups", "backup_trigger").

func (*Metrics) ResultDiscarded

func (m *Metrics) ResultDiscarded()

ResultDiscarded records a node delivery-failure notification dropped for lacking an action ID.

func (*Metrics) ResultLost

func (m *Metrics) ResultLost()

ResultLost records a result that was acknowledged to the node but not persisted.

func (*Metrics) ResultProcessed

func (m *Metrics) ResultProcessed(opCommand common.Hash, status uint8)

ResultProcessed records one validated TEE-node result delivery by op command and status class. It is counted after the identity gates but before storage, so a re-delivery that the storage override-guard later rejects (a duplicate of an already-persisted result) still counts here: it measures processed deliveries, not distinct stored results.

func (*Metrics) ResultRejected

func (m *Metrics) ResultRejected(reason string)

ResultRejected records one result rejected before storage under a bounded reason ("bad_signer", "wrong_tee_id", "bootstrap").

func (*Metrics) SetActiveRewardEpoch

func (m *Metrics) SetActiveRewardEpoch(epoch uint32)

SetActiveRewardEpoch records the reward epoch of the active signing policy.

func (*Metrics) SetAttestationPosture added in v0.0.20

func (m *Metrics) SetAttestationPosture(settings map[string]bool)

SetAttestationPosture records the attestation verification posture, setting the attestation_posture gauge to 1 for each active setting and 0 otherwise. The setting key set is closed — the sole caller passes a fixed-key literal map: enabled, magic_pass_allowed, audience_check, code_hash_check, platform_check, debug_status_check, max_token_age_check, sec_boot_check.

func (*Metrics) SetGovernancePosture added in v0.0.21

func (m *Metrics) SetGovernancePosture(settings map[string]bool)

SetGovernancePosture records the machine-path governance posture, setting the governance_posture gauge to 1 for each active setting and 0 otherwise. The setting key set is closed — the sole caller passes a fixed-key literal map: configured, safe_backed. Set unconditionally at startup (pure config), so the series exists even when the machine-path service itself is disabled.

func (*Metrics) SetPolicyFetched added in v0.0.20

func (m *Metrics) SetPolicyFetched()

SetPolicyFetched records that the signing-policy update loop completed an error-free iteration, refreshing the last-fetch timestamp used to detect a wedged loop.

func (*Metrics) SetReady

func (m *Metrics) SetReady(ready bool)

SetReady records the outcome of the latest readiness check.

func (*Metrics) StorageObserver

func (m *Metrics) StorageObserver() storage.Observer

StorageObserver returns an observer for the storage layer, or nil when storage metrics are disabled (so the decorator is skipped entirely).

func (*Metrics) VotingStarted

func (m *Metrics) VotingStarted()

VotingStarted records that a new voting (proposal box) was opened.

func (*Metrics) VotingThresholdReached

func (m *Metrics) VotingThresholdReached(d time.Duration)

VotingThresholdReached records the time from voting start to reaching threshold.

func (*Metrics) WalletBackupApplyFailed added in v0.0.20

func (m *Metrics) WalletBackupApplyFailed()

WalletBackupApplyFailed records a signed TEE_BACKUP result from the node that failed to decode before storage — the backup sibling of WalletKeyUpdateFailed. The storage legs are counted separately by storage_operations_total.

func (*Metrics) WalletEnabled added in v0.0.20

func (m *Metrics) WalletEnabled() bool

WalletEnabled reports whether wallet key/proof sync-cycle metrics are collected.

func (*Metrics) WalletKeyUpdateFailed added in v0.0.20

func (m *Metrics) WalletKeyUpdateFailed()

WalletKeyUpdateFailed records a signed KEY_* result from the node that failed to apply to the key cache — a protocol invariant break (node bug or version skew).

func (*Metrics) WalletSyncObserved added in v0.0.20

func (m *Metrics) WalletSyncObserved(result string)

WalletSyncObserved records one wallet key/proof sync-cycle outcome under a bounded result ("success"/"enqueue_error"/"wait_error"/"parse_error"/"skipped").

type ProviderPending

type ProviderPending struct {
	Provider string
	Pending  float64
}

ProviderPending pairs a provider address with its count of unfinalized proposals.

Jump to

Keyboard shortcuts

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