stats

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModuleMetrics

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

ModuleMetrics tracks metrics for all modules in a scan.

func (*ModuleMetrics) ConsideredCount

func (mm *ModuleMetrics) ConsideredCount() int64

ConsideredCount returns the number of distinct modules whose CanProcess has been evaluated at least once. Reaches the total enabled-module count once every module has been seen, regardless of whether any of them actually ran.

func (*ModuleMetrics) DistinctCount

func (mm *ModuleMetrics) DistinctCount() int64

DistinctCount returns the number of distinct modules that have been invoked at least once.

func (*ModuleMetrics) MarkConsidered

func (mm *ModuleMetrics) MarkConsidered(moduleID string)

MarkConsidered records that a module was evaluated against a record — i.e., CanProcess was called — regardless of whether the module actually ran. Used by the status counter so it can reach parity with the total module count even when some modules' CanProcess always rejects the input shape (e.g., POST-only modules in a GET-only scan).

func (*ModuleMetrics) Record

func (mm *ModuleMetrics) Record(moduleID string, duration time.Duration, findings int, err error)

Record records a single module invocation with its duration, finding count, and error. Safe to call on nil receiver. Implies MarkConsidered — a module that ran was necessarily considered.

func (*ModuleMetrics) Snapshot

func (mm *ModuleMetrics) Snapshot() map[string]ModuleStatsSnapshot

Snapshot returns a point-in-time snapshot of all module metrics. Safe to call on nil receiver.

func (*ModuleMetrics) TotalInvocations

func (mm *ModuleMetrics) TotalInvocations() int64

TotalInvocations returns the sum of all module invocations across all modules.

type ModuleStats

type ModuleStats struct {
	Invocations atomic.Int64
	Findings    atomic.Int64
	Errors      atomic.Int64
	TotalTimeNs atomic.Int64 // nanoseconds spent in module scan functions
}

ModuleStats tracks per-module performance metrics using atomic counters for lock-free concurrent access from multiple worker goroutines.

type ModuleStatsSnapshot

type ModuleStatsSnapshot struct {
	Invocations int64
	Findings    int64
	Errors      int64
	TotalTime   time.Duration
}

ModuleStatsSnapshot is a point-in-time snapshot of a module's metrics.

type Tracker

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

Tracker tracks scan statistics and prints progress periodically.

func New

func New(total int64, silent bool) *Tracker

New creates a new stats Tracker. Returns nil if silent is true. If total is 0, it means the total count is unknown.

func (*Tracker) Blocked

func (t *Tracker) Blocked() int64

Blocked returns the current blocked count (thread-safe).

func (*Tracker) Findings

func (t *Tracker) Findings() int64

Findings returns the current findings count (thread-safe).

func (*Tracker) Increment

func (t *Tracker) Increment()

Increment adds 1 to the processed count (thread-safe).

func (*Tracker) IncrementBlocked

func (t *Tracker) IncrementBlocked()

IncrementBlocked adds 1 to the blocked count (thread-safe).

func (*Tracker) IncrementFindings

func (t *Tracker) IncrementFindings()

IncrementFindings adds 1 to the findings count (thread-safe).

func (*Tracker) Processed

func (t *Tracker) Processed() int64

Processed returns the current processed count (thread-safe).

func (*Tracker) Start

func (t *Tracker) Start(ctx context.Context)

Start begins printing statistics every 5 seconds. Should be called once. Blocks until ctx is done or Stop is called.

func (*Tracker) Stop

func (t *Tracker) Stop()

Stop stops the tracker goroutine and waits for it to finish.

func (*Tracker) Total

func (t *Tracker) Total() int64

Total returns the known total count (0 = unknown).

Jump to

Keyboard shortcuts

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