regression

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("regression not found")

Functions

This section is empty.

Types

type AlertCallback

type AlertCallback func(ctx context.Context, r Regression)

AlertCallback is called when a regression is detected or resolved. It is defined here to avoid an import cycle with the incident package.

type AlgorithmConfig

type AlgorithmConfig struct {
	LatencyRegression LatencyConfig   `yaml:"latency_regression" json:"latency_regression"`
	ErrorRate         ErrorConfig     `yaml:"error_rate" json:"error_rate"`
	TenantOutlier     OutlierConfig   `yaml:"tenant_outlier" json:"tenant_outlier"`
	CacheMiss         CacheMissConfig `yaml:"cache_miss" json:"cache_miss"`
	DBFanout          FanoutConfig    `yaml:"db_fanout" json:"db_fanout"`
	PayloadGrowth     PayloadConfig   `yaml:"payload_growth" json:"payload_growth"`
}

Algorithm configs

func DefaultAlgorithmConfig

func DefaultAlgorithmConfig() AlgorithmConfig

type AlgorithmType

type AlgorithmType string
const (
	AlgoLatencyRegression AlgorithmType = "latency_regression"
	AlgoErrorRate         AlgorithmType = "error_rate"
	AlgoTenantOutlier     AlgorithmType = "tenant_outlier"
	AlgoCacheMiss         AlgorithmType = "cache_miss"
	AlgoDBFanout          AlgorithmType = "db_fanout"
	AlgoPayloadGrowth     AlgorithmType = "payload_growth"
)

type CacheMissConfig

type CacheMissConfig struct {
	ThresholdPP   float64 `yaml:"threshold_pp" json:"threshold_pp"`
	MinSampleSize int     `yaml:"min_sample_size" json:"min_sample_size"`
}

type Engine

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

Engine orchestrates continuous regression detection and deploy-triggered evaluation.

func New

func New(source MetricSource, store RegressionStore, deploys dataplane.ConfigStore, cfg AlgorithmConfig, interval, window time.Duration) *Engine

New creates a new regression detection engine.

func (*Engine) OnDeploy

func (e *Engine) OnDeploy(deploy dataplane.DeployEvent)

OnDeploy enqueues a deploy event for evaluation at predefined intervals.

func (*Engine) Scan

func (e *Engine) Scan(ctx context.Context) error

Scan performs continuous regression detection across all services.

func (*Engine) SetAlertCallback

func (e *Engine) SetAlertCallback(fn AlertCallback)

SetAlertCallback registers a callback that is invoked whenever a regression is saved or resolved. The callback is optional; nil disables alerting.

func (*Engine) Start

func (e *Engine) Start(ctx context.Context)

Start launches the scan ticker and deploy consumer goroutines.

func (*Engine) Stop

func (e *Engine) Stop()

Stop signals the engine to shut down and waits for goroutines to finish.

func (*Engine) Store

func (e *Engine) Store() RegressionStore

Store exposes the regression store for API handlers.

type ErrorConfig

type ErrorConfig struct {
	ThresholdPP   float64 `yaml:"threshold_pp" json:"threshold_pp"`
	MinSampleSize int     `yaml:"min_sample_size" json:"min_sample_size"`
}

type FanoutConfig

type FanoutConfig struct {
	ThresholdPercent float64 `yaml:"threshold_percent" json:"threshold_percent"`
	MinSampleSize    int     `yaml:"min_sample_size" json:"min_sample_size"`
}

type LatencyConfig

type LatencyConfig struct {
	P99ThresholdPercent float64 `yaml:"p99_threshold_percent" json:"p99_threshold_percent"`
	MinSampleSize       int     `yaml:"min_sample_size" json:"min_sample_size"`
}

type MetricSource

type MetricSource interface {
	WindowMetrics(ctx context.Context, service, action string, window TimeWindow) (*WindowMetrics, error)
	TenantWindowMetrics(ctx context.Context, service, tenantID string, window TimeWindow) (*WindowMetrics, error)
	FleetWindowMetrics(ctx context.Context, service string, window TimeWindow) (*WindowMetrics, error)
	ListServices(ctx context.Context) ([]string, error)
	ListTenants(ctx context.Context, service string) ([]string, error)
}

func NewMetricSource

func NewMetricSource(prom promv1.API, db *sql.DB) MetricSource

NewMetricSource returns a MetricSource backed by Prometheus (for latency/error/count aggregates) and DuckDB (for cache miss, fanout, and payload metrics derived from spans).

type OutlierConfig

type OutlierConfig struct {
	Multiplier    float64 `yaml:"multiplier" json:"multiplier"`
	MinSampleSize int     `yaml:"min_sample_size" json:"min_sample_size"`
	MaxTenants    int     `yaml:"max_tenants" json:"max_tenants"`
}

type PayloadConfig

type PayloadConfig struct {
	ThresholdPercent float64 `yaml:"threshold_percent" json:"threshold_percent"`
	MinSampleSize    int     `yaml:"min_sample_size" json:"min_sample_size"`
}

type Regression

type Regression struct {
	ID            string
	Algorithm     AlgorithmType
	Severity      Severity
	Confidence    int
	Service       string
	Action        string
	DeployID      string
	TenantID      string
	Title         string
	BeforeValue   float64
	AfterValue    float64
	ChangePercent float64
	SampleSize    int64
	DetectedAt    time.Time
	WindowBefore  TimeWindow
	WindowAfter   TimeWindow
	Status        string // "active", "resolved", "dismissed"
	ResolvedAt    *time.Time
}

type RegressionFilter

type RegressionFilter struct {
	Service   string
	DeployID  string
	Algorithm AlgorithmType
	Severity  Severity
	Status    string
	Limit     int
}

type RegressionStore

type RegressionStore interface {
	Save(ctx context.Context, r *Regression) error
	List(ctx context.Context, filter RegressionFilter) ([]Regression, error)
	Get(ctx context.Context, id string) (*Regression, error)
	UpdateStatus(ctx context.Context, id string, status string) error
	ActiveForDeploy(ctx context.Context, deployID string) ([]Regression, error)
}

type Severity

type Severity string
const (
	SeverityCritical Severity = "critical"
	SeverityWarning  Severity = "warning"
	SeverityInfo     Severity = "info"
)

type TimeWindow

type TimeWindow struct {
	Start time.Time
	End   time.Time
}

type WindowMetrics

type WindowMetrics struct {
	Service       string
	Action        string
	P50Ms         float64
	P95Ms         float64
	P99Ms         float64
	ErrorRate     float64
	RequestCount  int64
	CacheMissRate float64
	AvgSpanCount  float64
	AvgRespSize   float64
}

Directories

Path Synopsis
Package dynamostore implements regression.RegressionStore backed by DynamoDB via the generic dynamostore package.
Package dynamostore implements regression.RegressionStore backed by DynamoDB via the generic dynamostore package.

Jump to

Keyboard shortcuts

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