Documentation
¶
Overview ¶
Package collector defines the Collector interface and a registry for managing available collectors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRegistered = errors.New("collector already registered")
ErrAlreadyRegistered is returned by TryRegister when a collector with the same Name() is already in the registry. Wrapped with the offending name.
Functions ¶
func List ¶
func List() []string
List returns the names of all registered collectors in no particular order.
func Register ¶
func Register(c Collector)
Register adds a collector to the global registry. It panics with a descriptive message if registration fails — typically because a collector with the same Name() was already registered (usually a duplicate blank import). Intended for use from package init() where returning an error isn't an option; runtime callers should use TryRegister.
func TryRegister ¶ added in v1.8.0
TryRegister adds a collector to the global registry and returns an error if a collector with the same Name() is already registered. Prefer this over Register when the caller can handle the error (e.g. dynamic loaders, tests).
Types ¶
type Collector ¶
type Collector interface {
// Name returns the unique name of this collector (e.g., "todos", "gitlog").
Name() string
// Collect scans the repository at repoPath and returns discovered signals.
Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
}
Collector extracts raw signals from a repository.
type MetricsProvider ¶ added in v0.5.0
type MetricsProvider interface {
Metrics() any
}
MetricsProvider is an optional interface that collectors can implement to expose structured metrics from their analysis. The pipeline checks for this interface after Collect() returns and stores the result in CollectorResult.