Documentation
¶
Overview ¶
Package metrics holds configuration and middleware for prometheus style metrics
Index ¶
- Constants
- Variables
- func RecordGraphQLOperation(operation string, duration float64, err error)
- func RecordHandlerError(statusCode int)
- func RecordHandlerResult(requestType string, success bool)
- func RecordLogin(success bool)
- func RecordQueueTaskProcessed(taskName string, duration float64, err error)
- func RecordQueueTaskPushed(queueName, taskName string, err error)
- func RecordRegistration()
- func RecordRequestValidation(requestType string, success bool)
- func RecordWorkerExecution(workerName string, err error)
- type LabelValues
- func (l LabelValues) ForGraphQLOperation() []string
- func (l LabelValues) ForHandlerError() []string
- func (l LabelValues) ForHandlerResult() []string
- func (l LabelValues) ForLogin() []string
- func (l LabelValues) ForQueueTask() []string
- func (l LabelValues) ForQueueTaskProcessed() []string
- func (l LabelValues) ForRequestValidation() []string
- func (l LabelValues) ForWorker() []string
- type MetricNameBuilder
- type Metrics
Constants ¶
const ( // Success values LabelSuccess = "true" LabelFailure = "false" // Common operations OperationCreate = "create" OperationRead = "read" OperationUpdate = "update" OperationDelete = "delete" OperationList = "list" // Queue names QueueEmail = "email" QueueWebhook = "webhook" QueueAnalytics = "analytics" // Task types TaskEmailWelcome = "welcome_email" TaskEmailVerification = "verification_email" TaskEmailReset = "reset_email" TaskWebhookDelivery = "webhook_delivery" )
Common label values to use across metrics
Variables ¶
var ( WorkerExecutions = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_worker_executions_total", Help: "The total number of worker executions completed", }, []string{"name"}) WorkerExecutionErrors = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_worker_execution_errors_total", Help: "The total number of worker execution errors", }, []string{"name"}) Logins = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_logins_total", Help: "The total number of login attempts", }, []string{"success"}) RequestValidations = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_request_validations_total", Help: "The total number of request validations by type and success", }, []string{"request", "success"}) HandlerErrors = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_handler_errors_total", Help: "The total number of handler errors by function and status code", }, []string{"function", "code"}) HandlerResults = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_handler_results_total", Help: "The total number of handler results by request type and success", }, []string{"request", "success"}) Registrations = prometheus.NewCounter(prometheus.CounterOpts{ Name: "openlane_registrations_total", Help: "The total number of user registrations", }) QueueTasksPushed = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_queue_tasks_pushed_total", Help: "The total number of tasks pushed to queue", }, []string{"queue", "task"}) QueueTasksPushFailures = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_queue_tasks_push_failures_total", Help: "The total number of errors pushing a task to the queue", }, []string{"queue", "task"}) QueueTasksProcessed = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_queue_tasks_processed_total", Help: "The total number of tasks processed by the consumer", }, []string{"task"}) QueueTasksProcessedErrors = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_queue_tasks_process_errors_total", Help: "The total number of errors encountered by the consumer", }, []string{"task"}) QueueTasksProcessedDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "openlane_queue_tasks_process_duration_seconds", Help: "The duration of task processing in seconds", }, []string{"task"}) GraphQLOperationTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "openlane_graphql_operations_total", Help: "The total number of GraphQL operations processed", }, []string{"operation", "success"}) GraphQLOperationDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "openlane_graphql_operation_duration_seconds", Help: "The duration of GraphQL operations in seconds", Buckets: prometheus.DefBuckets, }, []string{"operation"}) APIMetrics = []prometheus.Collector{ WorkerExecutions, WorkerExecutionErrors, Logins, Registrations, QueueTasksPushed, QueueTasksPushFailures, GraphQLOperationTotal, GraphQLOperationDuration, RequestValidations, HandlerErrors, HandlerResults, } QueueConsumerMetrics = []prometheus.Collector{ QueueTasksProcessedDuration, QueueTasksProcessed, QueueTasksProcessedErrors, } )
These variables are stubs for now ad will be added throughout the codebase
Functions ¶
func RecordGraphQLOperation ¶ added in v0.25.0
RecordGraphQLOperation records a GraphQL operation
func RecordHandlerError ¶ added in v0.25.0
func RecordHandlerError(statusCode int)
RecordHandlerError records a handler error using HTTP status code The function name is derived from http.StatusText() for consistency
func RecordHandlerResult ¶ added in v0.25.0
RecordHandlerResult records a handler result
func RecordLogin ¶ added in v0.25.0
func RecordLogin(success bool)
RecordLogin records a login attempt
func RecordQueueTaskProcessed ¶ added in v0.25.0
RecordQueueTaskProcessed records a task being processed
func RecordQueueTaskPushed ¶ added in v0.25.0
RecordQueueTaskPushed records a task being pushed to queue
func RecordRegistration ¶ added in v0.34.5
func RecordRegistration()
RecordRegistration records a registration attempt
func RecordRequestValidation ¶ added in v0.25.0
RecordRequestValidation records a request validation result
func RecordWorkerExecution ¶ added in v0.25.0
RecordWorkerExecution records a worker execution with appropriate labels
Types ¶
type LabelValues ¶ added in v0.25.0
type LabelValues struct {
// Common labels
Success string
Operation string
Method string
Status string
// Service-specific labels
WorkerName string
QueueName string
TaskName string
RequestType string
FunctionName string
ErrorCode string
// Resource labels
TableName string
CacheName string
ServiceName string
}
LabelValues provides a structured way to define metric labels This helps avoid typos and ensures consistency across the codebase
func (LabelValues) ForGraphQLOperation ¶ added in v0.25.0
func (l LabelValues) ForGraphQLOperation() []string
func (LabelValues) ForHandlerError ¶ added in v0.25.0
func (l LabelValues) ForHandlerError() []string
func (LabelValues) ForHandlerResult ¶ added in v0.25.0
func (l LabelValues) ForHandlerResult() []string
func (LabelValues) ForLogin ¶ added in v0.25.0
func (l LabelValues) ForLogin() []string
func (LabelValues) ForQueueTask ¶ added in v0.25.0
func (l LabelValues) ForQueueTask() []string
func (LabelValues) ForQueueTaskProcessed ¶ added in v0.25.0
func (l LabelValues) ForQueueTaskProcessed() []string
func (LabelValues) ForRequestValidation ¶ added in v0.25.0
func (l LabelValues) ForRequestValidation() []string
func (LabelValues) ForWorker ¶ added in v0.25.0
func (l LabelValues) ForWorker() []string
StandardLabels returns a slice of label values in the correct order for the given metric. This ensures consistency and reduces errors.
type MetricNameBuilder ¶ added in v0.25.0
type MetricNameBuilder struct {
// contains filtered or unexported fields
}
MetricNameBuilder helps construct consistent metric names
func NewMetricNameBuilder ¶ added in v0.25.0
func NewMetricNameBuilder() *MetricNameBuilder
NewMetricNameBuilder creates a new builder with default namespace
func (*MetricNameBuilder) Build ¶ added in v0.25.0
func (b *MetricNameBuilder) Build(name string) string
Build constructs the full metric name
func (*MetricNameBuilder) WithSubsystem ¶ added in v0.25.0
func (b *MetricNameBuilder) WithSubsystem(subsystem string) *MetricNameBuilder
WithSubsystem sets the subsystem for the metric
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics struct holds a distinct echo instance to report system metrics
func (*Metrics) Register ¶
func (m *Metrics) Register(metrics []prometheus.Collector) error
Register registers metrics to the default registry