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 ¶
- type Config
- type Metrics
- func (m *Metrics) ActionDequeued(queue, result string)
- func (m *Metrics) ActionEnqueued(queue, result string)
- func (m *Metrics) ActiveVotersEnabled() bool
- func (m *Metrics) AttestationVerified(result, reason string)
- func (m *Metrics) Enabled() bool
- func (m *Metrics) FinalizedActionEnqueueFailed()
- func (m *Metrics) FinalizedActionLost(reason string)
- func (m *Metrics) HTTPEnabled() bool
- func (m *Metrics) InfoRefreshFailed(stage string)
- func (m *Metrics) InfoRefreshObserved(d time.Duration, err error)
- func (m *Metrics) InstructionReceived()
- func (m *Metrics) InstructionRejected(reason string)
- func (m *Metrics) LivenessEnabled() bool
- func (m *Metrics) MachinepathPollObserved(result string)
- func (m *Metrics) NodeEnabled() bool
- func (m *Metrics) Observe(backend, ns, operation, outcome string, d time.Duration)
- func (m *Metrics) ObserveHTTP(server, route string, status int, d time.Duration)
- func (m *Metrics) ObserveNodeWait(path string, d time.Duration, err error)
- func (m *Metrics) PolicyEnabled() bool
- func (m *Metrics) PolicyUpdate(result string)
- func (m *Metrics) QueueDepthReadFailed(queue string)
- func (m *Metrics) QueueEnabled() bool
- func (m *Metrics) RegisterActiveDataProviderVoters(count func() float64)
- func (m *Metrics) RegisterActiveDataProviderWeight(bips func() float64)
- func (m *Metrics) RegisterActiveInitiators(count func() float64)
- func (m *Metrics) RegisterCChainDelay(seconds func() float64)
- func (m *Metrics) RegisterGovernanceHashMatch(match func() float64)
- func (m *Metrics) RegisterInfoDelay(seconds func() float64)
- func (m *Metrics) RegisterMaxConsensusEpoch(epoch func() float64)
- func (m *Metrics) RegisterMaxVotingWeight(bips func() float64)
- func (m *Metrics) RegisterNodeAppliedPolicy(applied func() float64)
- func (m *Metrics) RegisterOldestStoredPolicy(oldest func() float64)
- func (m *Metrics) RegisterQueueDepth(queue string, depth func() float64)
- func (m *Metrics) RegisterTopUnfinalizedProposals(top func() []ProviderPending)
- func (m *Metrics) RegisterVotingThreshold(bips func() float64)
- func (m *Metrics) RegisterWalletKeysCached(count func() float64)
- func (m *Metrics) Registry() *prometheus.Registry
- func (m *Metrics) ResultChannelDropped(channel string)
- func (m *Metrics) ResultDiscarded()
- func (m *Metrics) ResultLost()
- func (m *Metrics) ResultProcessed(opCommand common.Hash, status uint8)
- func (m *Metrics) ResultRejected(reason string)
- func (m *Metrics) SetActiveRewardEpoch(epoch uint32)
- func (m *Metrics) SetAttestationPosture(settings map[string]bool)
- func (m *Metrics) SetGovernancePosture(settings map[string]bool)
- func (m *Metrics) SetPolicyFetched()
- func (m *Metrics) SetReady(ready bool)
- func (m *Metrics) StorageObserver() storage.Observer
- func (m *Metrics) VotingStarted()
- func (m *Metrics) VotingThresholdReached(d time.Duration)
- func (m *Metrics) WalletBackupApplyFailed()
- func (m *Metrics) WalletEnabled() bool
- func (m *Metrics) WalletKeyUpdateFailed()
- func (m *Metrics) WalletSyncObserved(result string)
- type ProviderPending
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 ¶
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 ¶
ActionDequeued records one dequeue attempt by queue and result.
func (*Metrics) ActionEnqueued ¶ added in v0.0.20
ActionEnqueued records one enqueue attempt by queue and result.
func (*Metrics) ActiveVotersEnabled ¶
ActiveVotersEnabled reports whether the distinct-voter gauge is collected.
func (*Metrics) AttestationVerified ¶
AttestationVerified records one attestation verification by result ("ok"/"error") and bounded reason.
func (*Metrics) Enabled ¶
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
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 ¶
HTTPEnabled reports whether per-request HTTP metrics are collected.
func (*Metrics) InfoRefreshFailed ¶
InfoRefreshFailed records a TEE info refresh failure at the given pipeline stage.
func (*Metrics) InfoRefreshObserved ¶
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 ¶
InstructionRejected records one rejected instruction under a bounded reason.
func (*Metrics) LivenessEnabled ¶
LivenessEnabled reports whether liveness metrics are collected.
func (*Metrics) MachinepathPollObserved ¶ added in v0.0.20
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
NodeEnabled reports whether node-interaction metrics are collected.
func (*Metrics) ObserveHTTP ¶
ObserveHTTP records one served request. An empty route is reported as "unmatched".
func (*Metrics) ObserveNodeWait ¶
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 ¶
PolicyEnabled reports whether signing-policy metrics are collected.
func (*Metrics) PolicyUpdate ¶ added in v0.0.20
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
QueueDepthReadFailed records a scrape-time queue-depth (LLEN) read failure for the given queue.
func (*Metrics) QueueEnabled ¶
QueueEnabled reports whether queue metrics are collected.
func (*Metrics) RegisterActiveDataProviderVoters ¶
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
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 ¶
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
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
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 ¶
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
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
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
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 ¶
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 ¶
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
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
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
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 ¶
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 ¶
ResultRejected records one result rejected before storage under a bounded reason ("bad_signer", "wrong_tee_id", "bootstrap").
func (*Metrics) SetActiveRewardEpoch ¶
SetActiveRewardEpoch records the reward epoch of the active signing policy.
func (*Metrics) SetAttestationPosture ¶ added in v0.0.20
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
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) StorageObserver ¶
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 ¶
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
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
WalletSyncObserved records one wallet key/proof sync-cycle outcome under a bounded result ("success"/"enqueue_error"/"wait_error"/"parse_error"/"skipped").
type ProviderPending ¶
ProviderPending pairs a provider address with its count of unfinalized proposals.