metrics

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 10

README

Oracle Application / Service Metrics

The following metrics are registered to the Cosmos SDK metrics port (default :26660):

oracle_response_latency

  • purpose
    • This prometheus histogram measures the RTT time taken (per request) from the metrics_client's request to the oracle's server's response.
    • Observations from this histogram are measured in nanoseconds
  • labels
    • chain_id: the chain-id of this oracle deployment

oracle_responses

  • purpose
    • This prometheus counter measures the # of oracle responses that a metrics_client has received
  • labels
    • status := (failure, success)
    • chain_id: the chain-id of this oracle deployment

ABCI_method_latency

  • purpose
    • This prometheus histogram measures the latency (per request) in seconds of ABCI method calls
    • The latency is measured over all connect-specific code, and ignores any down-stream dependencies
  • labels
    • method: one of (ExtendVote, PrepareProposal, ProcessProposal, VerifyVoteExtension, FinalizeBlock), this is the ABCI method that this latency report resulted from
    • chain_id: the chain-id of this oracle deployment

ABCI_method_status

  • purpose
    • This prometheus counter measures the number of ABCI requests, and their associated statuses
    • Each observation is either a success, or failure, and is paginated by the failure type
  • labels
    • method: one of (ExtendVote, PrepareProposal, ProcessProposal, VerifyVoteExtension, FinalizeBlock), this is the ABCI method that this latency report resulted from
    • chain_id: the chain-id of this oracle deployment
    • status: The status of the request, if it's a failure, the label is an indication of what logic failed

message_size

  • purpose
    • This prometheus histogram tracks the size of vote-extensions, and extended commits that connect is transmitting
  • labels
    • chain_id: the chain-id of this oracle deployment
    • message_type: the message-type whose size is being measured

oracle_prices

  • purpose
    • This prometheus gauge tracks the price written to state for each currency-pair
  • labels
    • chain_id: the chain-id of this oracle deployment
    • ticker: the ticker for which the price was written to state

oracle_reports_per_validator

  • purpose
    • This prometheus gauge tracks the prices that each validator has reported for any block per ticker
  • labels
    • chain_id: the chain-id of this oracle deployment
    • ticker: the ticker for which the price was written to state
    • validator: the consensus address of the validator that made the report

oracle_report_status_per_validator

  • purpose
    • This prometheus counter tracks the # of reports per validator and their status (absent: nil-vote, missing_price: the validator's vote was included but w/o a price, and with_price: validator's vote was included with a price)
  • labels
    • chain_id: the chain-id of this oracle deployment
    • ticker: the ticker for which the price was written to state
    • validator: the consensus address of the validator that made the report

Documentation

Index

Constants

View Source
const (
	// AppNamespace is the metric namespace.
	AppNamespace = "app"

	TickerLabel           = "ticker"
	InclusionLabel        = "included"
	ProviderLabel         = "provider"
	StatusLabel           = "status"
	ABCIMethodLabel       = "abci_method"
	ChainIDLabel          = "chain_id"
	ABCIMethodStatusLabel = "abci_method_status"
	MessageTypeLabel      = "message_type"
	ValidatorLabel        = "validator"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ABCIMethod

type ABCIMethod int

ABCIMethod is an identifier for ABCI methods, this is used to paginate latencies / responses in prometheus metrics.

const (
	PrepareProposal ABCIMethod = iota
	ProcessProposal
	ExtendVote
	VerifyVoteExtension
	PreBlock
)

func (ABCIMethod) String

func (a ABCIMethod) String() string

type Failure

type Failure struct{}

func (Failure) Label

func (f Failure) Label() string

type Labeller

type Labeller interface {
	Label() string
}

Labeller is an interface that can be implemented by errors to provide a label for prometheus metrics.

func StatusFromError

func StatusFromError(err error) Labeller

StatusFromError returns a Labeller that can be used to label metrics based on the error. This is used to label metrics based on the error returned from oracle client requests.

type MessageType

type MessageType int

MessageType is an identifier used to represent the different types of data that is transmitted between validators in Connect. This ID is used to paginate metrics corresponding to these messages.

const (
	ExtendedCommit MessageType = iota
	VoteExtension
)

func (MessageType) String

func (m MessageType) String() string

type Metrics

type Metrics interface {
	// ObserveOracleResponseLatency records the time it took for the oracle to respond (this is a histogram)
	ObserveOracleResponseLatency(duration time.Duration)

	// AddOracleResponse increments the number of oracle responses, this can represent a liveness counter. This metric is paginated by status.
	AddOracleResponse(status Labeller)

	// ObserveABCIMethodLatency reports the given latency (as a duration), for the given ABCIMethod, and updates the ABCIMethodLatency histogram w/ that value.
	ObserveABCIMethodLatency(method ABCIMethod, duration time.Duration)

	// AddABCIRequest updates a counter corresponding to the given ABCI method and status.
	AddABCIRequest(method ABCIMethod, status Labeller)

	// ObserveMessageSize updates a histogram per Connect message type with the size of that message
	ObserveMessageSize(msg MessageType, size int)

	// ObservePriceForTicker updates a gauge with the price for the given ticker, this is updated each time a price is written to state
	ObservePriceForTicker(ticker connecttypes.CurrencyPair, price float64)

	// AddValidatorPriceForTicker updates a gauge per validator with the price they observed for a given ticker, this is updated when prices
	// to be written to state are aggregated
	AddValidatorPriceForTicker(validator string, ticker connecttypes.CurrencyPair, price float64)

	// AddValidatorReportForTicker updates a counter per validator + status. This counter represents the number of times a validator
	// for a ticker with a price, w/o a price, or w/ an absent.
	AddValidatorReportForTicker(validator string, ticker connecttypes.CurrencyPair, status ReportStatus)
}

func NewMetrics

func NewMetrics(chainID string) Metrics

func NewMetricsFromConfig

func NewMetricsFromConfig(cfg config.AppConfig, chainID string) (Metrics, error)

NewMetricsFromConfig returns a new Metrics implementation based on the config. The Metrics returned is safe to be used in the client, and in the Oracle used by the PreBlocker. If the metrics are not enabled, a nop implementation is returned.

func NewNopMetrics

func NewNopMetrics() Metrics

NewNopMetrics returns a Metrics implementation that does nothing.

type ReportStatus

type ReportStatus int

ReportStatus is an identifier for the status of a report, this is used to label what kind of report a validator has given, i.e. absent, missing_price, with_price.

const (
	Absent ReportStatus = iota
	MissingPrice
	WithPrice
)

func (ReportStatus) String

func (rs ReportStatus) String() string

type Success

type Success struct{}

func (Success) Label

func (s Success) Label() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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