metrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {

	// Email statistics
	TotalEmailsSent     uint64
	TotalEmailsFailed   uint64
	TotalAttachmentSize uint64
	AvgDeliveryTime     time.Duration

	// Connection metrics
	ActiveConnections  int64
	TotalConnections   uint64
	ConnectionErrors   uint64
	ConnectionTimeouts uint64

	// Batch metrics
	BatchesProcessed uint64
	AvgBatchSize     float64
	BatchSuccessRate float64

	// Rate limiting
	ThrottleEvents   uint64
	CurrentRateLimit int64
	RateLimitHits    uint64

	// Template metrics
	TemplateCacheHits   uint64
	TemplateCacheMisses uint64
	TemplateCacheSize   int64

	// Error tracking
	ErrorCounts     map[string]uint64
	LastError       time.Time
	ConsecutiveErrs uint64
	// contains filtered or unexported fields
}

Metrics collects and exposes performance metrics for email sending

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new metrics collector

func (*Metrics) GetStats

func (m *Metrics) GetStats() string

GetStats returns current metrics as a JSON string

func (*Metrics) RecordBatch

func (m *Metrics) RecordBatch(size int, success float64)

RecordBatch records batch processing metrics

func (*Metrics) RecordConnection

func (m *Metrics) RecordConnection(success bool)

RecordConnection records connection metrics

func (*Metrics) RecordConnectionClosed

func (m *Metrics) RecordConnectionClosed()

RecordConnectionClosed records a closed connection

func (*Metrics) RecordEmailFailed

func (m *Metrics) RecordEmailFailed(err error)

RecordEmailFailed records a failed email delivery

func (*Metrics) RecordEmailSent

func (m *Metrics) RecordEmailSent(duration time.Duration)

RecordEmailSent records a successful email delivery

func (*Metrics) RecordTemplateCache

func (m *Metrics) RecordTemplateCache(hit bool, size int64)

RecordTemplateCache records template cache metrics

func (*Metrics) RecordThrottle

func (m *Metrics) RecordThrottle(limit int64)

RecordThrottle records rate limiting events

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for metrics endpoint

type Server

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

Server provides HTTP endpoints for metrics and health checks

func NewServer

func NewServer(metrics *Metrics, port int) *Server

NewServer creates a new metrics server

func (*Server) Start

func (s *Server) Start() error

Start starts the metrics server

func (*Server) Stop

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

Stop gracefully stops the server

Jump to

Keyboard shortcuts

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