alerts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package alerts derives bounded alert inputs from validated operational snapshots without delivering notifications or storing time series.

Index

Constants

View Source
const (
	// MaxWorkers bounds one evaluation pass.
	MaxWorkers = 10_000
	// MaxCommands bounds one evaluation pass.
	MaxCommands = 1_000
)
View Source
const (
	// MaxAlertBatch bounds one synchronous telemetry export call.
	MaxAlertBatch = 12_000
)

Variables

View Source
var (
	// ErrInvalidInput reports malformed or unbounded operational input.
	ErrInvalidInput = errors.New("alerts: invalid input")
	// ErrInvalidPolicy reports an impossible alert threshold.
	ErrInvalidPolicy = errors.New("alerts: invalid policy")
)
View Source
var (
	// ErrInvalidTelemetryConfiguration reports an unusable metric provider.
	ErrInvalidTelemetryConfiguration = errors.New("alerts: invalid telemetry configuration")
	// ErrInvalidAlertBatch reports malformed, empty, canceled, or unbounded export input.
	ErrInvalidAlertBatch = errors.New("alerts: invalid alert batch")
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Kind       Kind      `json:"kind"`
	TenantID   string    `json:"tenant_id"`
	Resource   string    `json:"resource"`
	Value      float64   `json:"value"`
	Threshold  float64   `json:"threshold"`
	ObservedAt time.Time `json:"observed_at"`
}

Alert is a backend-neutral threshold breach suitable for telemetry export.

func Evaluate

func Evaluate(input Input, policy Policy) ([]Alert, error)

Evaluate returns deterministic alert inputs for enabled threshold breaches.

type Input

type Input struct {
	TenantID    string
	ObservedAt  time.Time
	Queues      queue.QueueStatusPage
	Workers     fleet.RegistrySnapshot
	Failures    queue.Measurement[uint64]
	DeadLetters queue.Measurement[uint64]
	Commands    []controlplane.CommandResult
}

Input is one tenant's bounded current operational snapshot.

type Kind

type Kind string

Kind identifies a stable platform alert input.

const (
	KindQueueWait       Kind = "queue_wait"
	KindFailureCount    Kind = "failure_count"
	KindStaleWorker     Kind = "stale_worker"
	KindDeadLetterCount Kind = "dead_letter_count"
	KindCommandFailure  Kind = "command_failure"
)

type Policy

type Policy struct {
	MaxQueueWait    time.Duration
	MaxFailures     uint64
	MaxDeadLetters  uint64
	StaleWorkers    bool
	CommandFailures bool
}

Policy enables alert categories and declares strict upper thresholds. Zero count or duration thresholds disable the corresponding category.

type TelemetryExporter

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

TelemetryExporter emits fixed-cardinality alert counts through the caller's telemetry meter. Tenant and resource identities are intentionally absent.

func NewTelemetryExporter

func NewTelemetryExporter(meter metric.Meter) (*TelemetryExporter, error)

NewTelemetryExporter creates the bounded platform alert metric bridge.

func (*TelemetryExporter) Export

func (e *TelemetryExporter) Export(ctx context.Context, alerts []Alert) error

Export validates one bounded evaluation result and increments only stable kind labels. Delivery and scheduling remain owned by the platform caller.

Jump to

Keyboard shortcuts

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