metrics

package
v1.2.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: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusLabel is a label for the status of a provider API response.
	StatusLabel = "internal_status"
	// StatusCodeLabel is a label for the status code of a provider API response.
	StatusCodeLabel = "status_code"
	// StatusCodeExactLabel is a label for the exact status code of a provider API response.
	StatusCodeExactLabel = "status_code_exact"
	// EndpointLabel is a label for the endpoint of a provider API response.
	EndpointLabel = "endpoint"
	// RedactedURL is a label for the redacted URL of a provider API response.
	RedactedURL = "redacted_url"
)

Variables

This section is empty.

Functions

func RedactedEndpointURL

func RedactedEndpointURL(index int) string

RedactedEndpointURL returns a redacted version of the given URL.

Types

type APIMetrics

type APIMetrics interface {
	// AddProviderResponse increments the number of ticks with a fully successful provider update.
	// This increments the number of responses by provider, id (i.e. currency pair), and status.
	//
	// TODO(david); Deprecate this since this is replicated in the base provider.
	AddProviderResponse(providerName, id string, errorCode providertypes.ErrorCode)

	// AddHTTPStatusCode increments the number of responses by provider and status.
	// This is used to track the number of responses by provider and status.
	AddHTTPStatusCode(providerName string, resp *http.Response)

	// AddRPCStatusCode increments the number of responses by provider and status for RPC requests.
	// This includes gRPC and JSON-RPC.
	AddRPCStatusCode(providerName, endpoint string, code RPCCode)

	// ObserveProviderResponseLatency records the time it took for a provider to respond for
	// within a single interval. Note that if the provider is not atomic, this will be the
	// time it took for all the requests to complete.
	ObserveProviderResponseLatency(providerName, endpoint string, duration time.Duration)
}

APIMetrics is an interface that defines the API for metrics collection for providers that implement the APIQueryHandler.

func NewAPIMetrics

func NewAPIMetrics() APIMetrics

NewAPIMetrics returns a Provider Metrics implementation that uses Prometheus.

func NewAPIMetricsFromConfig

func NewAPIMetricsFromConfig(config config.MetricsConfig) APIMetrics

NewAPIMetricsFromConfig returns a new Metrics struct given the main oracle metrics config.

func NewNopAPIMetrics

func NewNopAPIMetrics() APIMetrics

NewNopAPIMetrics returns a Provider Metrics implementation that does nothing.

type APIMetricsImpl

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

APIMetricsImpl contains metrics exposed by this package.

func (*APIMetricsImpl) AddHTTPStatusCode

func (m *APIMetricsImpl) AddHTTPStatusCode(providerName string, resp *http.Response)

AddHTTPStatusCode increments the http status code by provider and response.

func (*APIMetricsImpl) AddProviderResponse

func (m *APIMetricsImpl) AddProviderResponse(providerName string, id string, err providertypes.ErrorCode)

AddProviderResponse increments the number of requests by provider and status.

func (*APIMetricsImpl) AddRPCStatusCode

func (m *APIMetricsImpl) AddRPCStatusCode(providerName, endpoint string, code RPCCode)

AddRPCStatusCode increments the rpc status code by provider and response.

func (*APIMetricsImpl) ObserveProviderResponseLatency

func (m *APIMetricsImpl) ObserveProviderResponseLatency(providerName, endpoint string, duration time.Duration)

ObserveProviderResponseLatency records the time it took for a provider to respond.

type RPCCode

type RPCCode string

RPCCode is the status code a RPC request.

const (
	// RPCCodeOK is the status code for a successful RPC request.
	RPCCodeOK RPCCode = "ok"
	// RPCCodeError is the status code for a failed RPC request.
	RPCCodeError RPCCode = "request_error"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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