metrics

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceFee       = "fee"
	ServiceTxIndexer = "tx_indexer"
	ServiceVault     = "vault"
	ServiceWorker    = "worker"
	ServiceHTTP      = "http"
)

Service names for metrics registration

Variables

This section is empty.

Functions

func NewTxIndexerMetrics

func NewTxIndexerMetrics() metrics.TxIndexerMetrics

NewTxIndexerMetrics creates a new instance of TxIndexerMetrics

func RegisterMetrics

func RegisterMetrics(services []string, registry *prometheus.Registry, logger *logrus.Logger)

RegisterMetrics registers metrics for the specified services with a custom registry

Types

type Config

type Config struct {
	Enabled bool   `mapstructure:"enabled" json:"enabled,omitempty"`
	Host    string `mapstructure:"host" json:"host,omitempty"`
	Port    int    `mapstructure:"port" json:"port,omitempty"`
}

Config holds metrics server configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default metrics configuration

type HTTPMetrics added in v0.1.16

type HTTPMetrics struct{}

HTTPMetrics provides methods to update HTTP-related metrics

func NewHTTPMetrics added in v0.1.16

func NewHTTPMetrics() *HTTPMetrics

NewHTTPMetrics creates a new instance of HTTPMetrics

func (*HTTPMetrics) Middleware added in v0.1.16

func (hm *HTTPMetrics) Middleware() echo.MiddlewareFunc

Middleware returns an Echo middleware for HTTP metrics collection

func (*HTTPMetrics) RecordRequest added in v0.1.16

func (hm *HTTPMetrics) RecordRequest(method, path, statusCode string, duration float64)

RecordRequest manually records an HTTP request (for cases where middleware isn't used)

type NoOpWorkerMetrics added in v0.1.16

type NoOpWorkerMetrics struct{}

NoOpWorkerMetrics provides a no-op implementation of worker metrics

func NewNoOpWorkerMetrics added in v0.1.16

func NewNoOpWorkerMetrics() *NoOpWorkerMetrics

NewNoOpWorkerMetrics creates a new instance of NoOpWorkerMetrics

func (*NoOpWorkerMetrics) Handler added in v0.1.16

func (n *NoOpWorkerMetrics) Handler(taskType string, handler asynq.HandlerFunc) asynq.HandlerFunc

Handler returns the original handler without any metrics wrapping

func (*NoOpWorkerMetrics) RecordError added in v0.1.16

func (n *NoOpWorkerMetrics) RecordError(taskType, errorType string)

func (*NoOpWorkerMetrics) RecordTaskCompleted added in v0.1.16

func (n *NoOpWorkerMetrics) RecordTaskCompleted(taskType string, duration float64)

NoOpWorkerMetrics implementations - all methods are no-ops

func (*NoOpWorkerMetrics) RecordTaskFailed added in v0.1.16

func (n *NoOpWorkerMetrics) RecordTaskFailed(taskType string, duration float64)

func (*NoOpWorkerMetrics) RecordTaskFinished added in v0.1.16

func (n *NoOpWorkerMetrics) RecordTaskFinished(taskType string)

func (*NoOpWorkerMetrics) RecordTaskStarted added in v0.1.16

func (n *NoOpWorkerMetrics) RecordTaskStarted(taskType string)

func (*NoOpWorkerMetrics) RecordVaultOperation added in v0.1.16

func (n *NoOpWorkerMetrics) RecordVaultOperation(operation, status string, duration float64)

type Server

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

Server represents the metrics HTTP server

func NewServer

func NewServer(host string, port int, logger *logrus.Logger, registry *prometheus.Registry) *Server

NewServer creates a new metrics server with a custom registry

func StartMetricsServer

func StartMetricsServer(cfg Config, services []string, logger *logrus.Logger) *Server

StartMetricsServer is a convenience function to start the metrics server with services

func StartMetricsServerWithRegistry

func StartMetricsServerWithRegistry(cfg Config, registry *prometheus.Registry, logger *logrus.Logger) *Server

StartMetricsServerWithRegistry starts a metrics server with a pre-configured registry

func (*Server) Start

func (s *Server) Start()

Start starts the metrics server in a goroutine

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the metrics server

type TxIndexerMetrics

type TxIndexerMetrics struct{}

TxIndexerMetrics provides Prometheus implementation of TxIndexerMetrics interface

func (*TxIndexerMetrics) RecordIterationDuration

func (tim *TxIndexerMetrics) RecordIterationDuration(chain common.Chain, duration float64)

RecordIterationDuration records the duration of a processing iteration

func (*TxIndexerMetrics) RecordProcessing

func (tim *TxIndexerMetrics) RecordProcessing(chain common.Chain)

RecordProcessing records a processing attempt

func (*TxIndexerMetrics) RecordProcessingError

func (tim *TxIndexerMetrics) RecordProcessingError(chain common.Chain, errorType string)

RecordProcessingError records a processing error

func (*TxIndexerMetrics) RecordRPCError

func (tim *TxIndexerMetrics) RecordRPCError(chain common.Chain)

RecordRPCError records an RPC error

func (*TxIndexerMetrics) RecordTransactionStatus

func (tim *TxIndexerMetrics) RecordTransactionStatus(chain common.Chain, status string)

RecordTransactionStatus records a transaction status change

func (*TxIndexerMetrics) SetActiveTransactions

func (tim *TxIndexerMetrics) SetActiveTransactions(chain common.Chain, status string, count float64)

SetActiveTransactions sets the number of active transactions

func (*TxIndexerMetrics) SetChainHeight

func (tim *TxIndexerMetrics) SetChainHeight(chain common.Chain, height float64)

SetChainHeight sets the current chain height

func (*TxIndexerMetrics) SetLastProcessingTimestamp

func (tim *TxIndexerMetrics) SetLastProcessingTimestamp(timestamp float64)

SetLastProcessingTimestamp sets the timestamp of the last processing iteration

type WorkerMetrics added in v0.1.16

type WorkerMetrics struct{}

WorkerMetrics provides methods to update worker-related metrics

func NewWorkerMetrics added in v0.1.16

func NewWorkerMetrics() *WorkerMetrics

NewWorkerMetrics creates a new instance of WorkerMetrics

func (*WorkerMetrics) Handler added in v0.1.16

func (wm *WorkerMetrics) Handler(taskType string, handler asynq.HandlerFunc) asynq.HandlerFunc

Handler wraps a task handler with worker metrics collection

func (*WorkerMetrics) RecordError added in v0.1.16

func (wm *WorkerMetrics) RecordError(taskType, errorType string)

RecordError records an error during task processing

func (*WorkerMetrics) RecordTaskCompleted added in v0.1.16

func (wm *WorkerMetrics) RecordTaskCompleted(taskType string, duration float64)

RecordTaskCompleted records a successfully completed task

func (*WorkerMetrics) RecordTaskFailed added in v0.1.16

func (wm *WorkerMetrics) RecordTaskFailed(taskType string, duration float64)

RecordTaskFailed records a failed task

func (*WorkerMetrics) RecordTaskFinished added in v0.1.16

func (wm *WorkerMetrics) RecordTaskFinished(taskType string)

RecordTaskFinished records when a task finishes (decrements active count)

func (*WorkerMetrics) RecordTaskStarted added in v0.1.16

func (wm *WorkerMetrics) RecordTaskStarted(taskType string)

RecordTaskStarted records when a task starts (increments active count)

func (*WorkerMetrics) RecordVaultOperation added in v0.1.16

func (wm *WorkerMetrics) RecordVaultOperation(operation, status string, duration float64)

RecordVaultOperation records a vault operation (keygen, keysign, reshare)

type WorkerMetricsInterface added in v0.1.16

type WorkerMetricsInterface interface {
	RecordTaskCompleted(taskType string, duration float64)
	RecordTaskFailed(taskType string, duration float64)
	RecordTaskStarted(taskType string)
	RecordTaskFinished(taskType string)
	RecordVaultOperation(operation, status string, duration float64)
	RecordError(taskType, errorType string)
	Handler(taskType string, handler asynq.HandlerFunc) asynq.HandlerFunc
}

WorkerMetricsInterface defines the contract for worker metrics

Jump to

Keyboard shortcuts

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