Documentation
¶
Index ¶
- Variables
- func RecordAPIRequest(path, method, status string, durationSeconds float64)
- func RecordError(component, errorType string)
- func RecordFunctionExecution(functionID, userID string, durationSeconds float64, memoryBytes float64, ...)
- func RecordGasBankTransaction(operation, status string)
- func RecordSecretOperation(userID string, operation string, status string)
- func RecordTEEAttestation(durationSeconds float64, status string)
- func UpdateBlockchainConnections(connections int)
- func UpdateDatabaseConnections(connections int)
- func UpdateGasBankBalance(asset string, balance float64)
- func UpdateSecretCount(userID string, count int)
- func UpdateSystemMetrics(cpuUsage, memoryBytes float64, goroutines int)
- type MetricsCollector
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // Function execution metrics FunctionExecutionCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_function_executions_total", Help: "The total number of function executions", }, []string{"function_id", "user_id", "status"}, ) FunctionExecutionDuration = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "service_layer_function_execution_duration_seconds", Help: "Function execution duration in seconds", Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), }, []string{"function_id", "user_id"}, ) FunctionMemoryUsage = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "service_layer_function_memory_usage_bytes", Help: "Function memory usage in bytes", Buckets: prometheus.ExponentialBuckets(1024*1024, 2, 10), }, []string{"function_id", "user_id"}, ) // Secret management metrics SecretOperationsCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_secret_operations_total", Help: "The total number of secret operations", }, []string{"user_id", "operation", "status"}, ) SecretCount = promauto.NewGaugeVec( prometheus.GaugeOpts{ Name: "service_layer_secrets_count", Help: "The number of secrets stored per user", }, []string{"user_id"}, ) // TEE metrics TEEAttestationCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_tee_attestations_total", Help: "The total number of TEE attestation operations", }, []string{"status"}, ) TEEAttestationDuration = promauto.NewHistogram( prometheus.HistogramOpts{ Name: "service_layer_tee_attestation_duration_seconds", Help: "TEE attestation duration in seconds", Buckets: prometheus.ExponentialBuckets(0.01, 2, 10), }, ) // API metrics APIRequestsCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_api_requests_total", Help: "The total number of API requests", }, []string{"path", "method", "status"}, ) APIRequestDuration = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "service_layer_api_request_duration_seconds", Help: "API request duration in seconds", Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), }, []string{"path", "method"}, ) // Health metrics SystemUptime = promauto.NewCounter( prometheus.CounterOpts{ Name: "service_layer_uptime_seconds_total", Help: "The total uptime of the service layer in seconds", }, ) DatabaseConnections = promauto.NewGauge( prometheus.GaugeOpts{ Name: "service_layer_database_connections", Help: "The number of active database connections", }, ) BlockchainConnections = promauto.NewGauge( prometheus.GaugeOpts{ Name: "service_layer_blockchain_connections", Help: "The number of active blockchain node connections", }, ) // Gas bank metrics GasBankBalance = promauto.NewGaugeVec( prometheus.GaugeOpts{ Name: "service_layer_gas_bank_balance", Help: "The current balance of the gas bank", }, []string{"asset"}, ) GasBankTransactionsCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_gas_bank_transactions_total", Help: "The total number of gas bank transactions", }, []string{"operation", "status"}, ) // Error metrics ErrorsCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "service_layer_errors_total", Help: "The total number of errors", }, []string{"component", "error_type"}, ) // System resource metrics SystemCPUUsage = promauto.NewGauge( prometheus.GaugeOpts{ Name: "service_layer_system_cpu_usage", Help: "The CPU usage of the service layer", }, ) SystemMemoryUsage = promauto.NewGauge( prometheus.GaugeOpts{ Name: "service_layer_system_memory_bytes", Help: "The memory usage of the service layer in bytes", }, ) SystemGoroutines = promauto.NewGauge( prometheus.GaugeOpts{ Name: "service_layer_goroutines", Help: "The number of goroutines", }, ) )
Functions ¶
func RecordAPIRequest ¶
RecordAPIRequest records metrics for an API request
func RecordFunctionExecution ¶
func RecordFunctionExecution(functionID, userID string, durationSeconds float64, memoryBytes float64, status string)
RecordFunctionExecution records metrics for a function execution
func RecordGasBankTransaction ¶
func RecordGasBankTransaction(operation, status string)
RecordGasBankTransaction records a gas bank transaction
func RecordSecretOperation ¶
RecordSecretOperation records metrics for a secret operation
func RecordTEEAttestation ¶
RecordTEEAttestation records metrics for a TEE attestation
func UpdateBlockchainConnections ¶
func UpdateBlockchainConnections(connections int)
UpdateBlockchainConnections updates the active blockchain connections metric
func UpdateDatabaseConnections ¶
func UpdateDatabaseConnections(connections int)
UpdateDatabaseConnections updates the active database connections metric
func UpdateGasBankBalance ¶
UpdateGasBankBalance updates the gas bank balance
func UpdateSecretCount ¶
UpdateSecretCount updates the count of secrets for a user
func UpdateSystemMetrics ¶
UpdateSystemMetrics updates system resource metrics
Types ¶
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector regularly collects and updates system metrics like memory usage, goroutines count, and other process stats. This should be a runnable service that the main app can start.
func NewMetricsCollector ¶
func NewMetricsCollector(cfg *config.MonitoringConfig, log *logger.Logger) (*MetricsCollector, error)
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) Start ¶
func (mc *MetricsCollector) Start() error
Start begins collecting metrics
func (*MetricsCollector) Stop ¶
func (mc *MetricsCollector) Stop()
Stop halts the metrics collection
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a centralized way to manage monitoring components
func NewService ¶
NewService creates a new monitoring service
func (*Service) Metrics ¶
func (s *Service) Metrics() *MetricsCollector
Metrics provides access to the metrics collector
func (*Service) Registry ¶
func (s *Service) Registry() *prometheus.Registry
Registry returns the Prometheus registry for registering additional metrics