prometheus

package module
v5.0.0-...-a0a15d6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 13 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Enabled controls whether enhanced metrics are collected
	Enabled bool `mapstructure:"enabled"`

	// EndpointPatterns configures endpoint pattern matching and grouping
	EndpointPatterns EndpointPatternsConfig `mapstructure:"endpoint_patterns"`

	// CollectSizes enables request/response body size tracking
	CollectSizes bool `mapstructure:"collect_sizes"`

	// CollectQueueTime enables queue time vs processing time breakdown
	CollectQueueTime bool `mapstructure:"collect_queue_time"`

	// CollectWorkerInfo enables worker pool health metrics
	CollectWorkerInfo bool `mapstructure:"collect_worker_info"`

	// DurationBuckets defines histogram buckets for duration metrics (in seconds)
	DurationBuckets []float64 `mapstructure:"duration_buckets"`

	// SizeBuckets defines histogram buckets for size metrics (in bytes)
	SizeBuckets []float64 `mapstructure:"size_buckets"`
}

Config represents the prometheus plugin configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

type Configurer

type Configurer interface {
	// UnmarshalKey reads configuration section into provided structure
	UnmarshalKey(name string, out interface{}) error
	// Has checks if configuration section exists
	Has(name string) bool
}

Configurer interface for reading plugin configuration

type EndpointMatcher

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

EndpointMatcher matches request paths to endpoint patterns Uses LRU cache to minimize regex matching overhead

func NewEndpointMatcher

func NewEndpointMatcher(config EndpointPatternsConfig) (*EndpointMatcher, error)

NewEndpointMatcher creates a new endpoint matcher from configuration

func (*EndpointMatcher) Match

func (em *EndpointMatcher) Match(path string) string

Match returns the endpoint pattern for a given path Uses cached results when available, falls back to regex matching

type EndpointPatternsConfig

type EndpointPatternsConfig struct {
	// Enabled controls whether endpoint pattern matching is active
	Enabled bool `mapstructure:"enabled"`

	// MaxPatterns limits the number of unique endpoint patterns to prevent cardinality explosion
	MaxPatterns int `mapstructure:"max_patterns"`

	// Rules defines regex patterns for grouping similar endpoints
	Rules []PatternRule `mapstructure:"rules"`

	// CacheSize defines the LRU cache size for pattern matching results
	CacheSize int `mapstructure:"cache_size"`
}

EndpointPatternsConfig configures endpoint pattern matching

type ErrorType

type ErrorType string

ErrorType classifies HTTP errors for better observability

const (
	ErrorTypeClientError ErrorType = "client_error" // 4xx errors
	ErrorTypeServerError ErrorType = "server_error" // 5xx errors
	ErrorTypeTimeout     ErrorType = "timeout"      // 408, 504
	ErrorTypeNoWorkers   ErrorType = "no_workers"   // Worker pool exhausted
)

type PatternRule

type PatternRule struct {
	// Pattern is the regex pattern to match against request paths
	Pattern string `mapstructure:"pattern"`

	// Name is the label value to use when pattern matches
	Name string `mapstructure:"name"`
}

PatternRule defines a single pattern matching rule

type Plugin

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

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer) error

func (*Plugin) MetricsCollector

func (p *Plugin) MetricsCollector() []prometheus.Collector

func (*Plugin) Middleware

func (p *Plugin) Middleware(next http.Handler) http.Handler

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop(context.Context) error

type WorkerPoolStats

type WorkerPoolStats struct {
	Active      int
	Idle        int
	Total       int
	UpdatedAt   time.Time
	Utilization float64 // Percentage 0-100
}

WorkerPoolStats represents worker pool statistics This interface allows decoupling from specific HTTP plugin implementation

Jump to

Keyboard shortcuts

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