Documentation
¶
Overview ¶
Package metrics provides interfaces for defining self-contained, reusable metrics.
Each metric is a computation unit that:
- Declares its input requirements
- Computes a typed output
- Provides metadata for documentation and serialization
This design allows metrics to be reused across analyzers and output formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RiskPriority ¶
RiskPriority returns a sortable integer for a risk level. Lower values indicate higher priority: CRITICAL < HIGH < MEDIUM < LOW/unknown.
Types ¶
type Metric ¶
type Metric[In, Out any] interface { // Name returns the machine-readable identifier (snake_case, unique). Name() string // DisplayName returns a human-readable name for UI/reports. DisplayName() string // Description returns detailed documentation including: // - What the metric measures. // - How to interpret the value. // - Units (if applicable). // - Any caveats or limitations. Description() string // Type returns the metric category (e.g., "aggregate", "time_series", "risk"). Type() string // Compute calculates the metric value from input data. Compute(input In) Out }
Metric is the core interface that all metrics must implement. Each metric is a self-contained computation with metadata.
type MetricMeta ¶
type MetricMeta struct {
MetricName string
MetricDisplayName string
MetricDescription string
MetricType string
}
MetricMeta holds the common metadata for a metric. Embed this in metric implementations to satisfy metadata methods.
func (MetricMeta) Description ¶
func (m MetricMeta) Description() string
Description returns detailed documentation.
func (MetricMeta) DisplayName ¶
func (m MetricMeta) DisplayName() string
DisplayName returns a human-readable name for UI/reports.
func (MetricMeta) Name ¶
func (m MetricMeta) Name() string
Name returns the machine-readable identifier.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds a collection of metrics that can be computed together.
type RiskResult ¶
type RiskResult struct {
Value any `json:"value"`
Level RiskLevel `json:"risk_level"`
Threshold float64 `json:"threshold,omitempty"`
Message string `json:"message,omitempty"`
}
RiskResult is the output of a risk metric.
type TimeSeriesPoint ¶
TimeSeriesPoint is a single data point in a time series.