Documentation
¶
Index ¶
- type ModuleMetrics
- func (mm *ModuleMetrics) ConsideredCount() int64
- func (mm *ModuleMetrics) DistinctCount() int64
- func (mm *ModuleMetrics) For(moduleID string) *ModuleStats
- func (mm *ModuleMetrics) LatencyQuantile(moduleID string, q float64) (time.Duration, int64)
- func (mm *ModuleMetrics) MarkConsidered(moduleID string)
- func (mm *ModuleMetrics) Record(moduleID string, duration time.Duration, findings int, err error)
- func (mm *ModuleMetrics) RecordInconclusive(moduleID string)
- func (mm *ModuleMetrics) Snapshot() map[string]ModuleStatsSnapshot
- func (mm *ModuleMetrics) TotalInvocations() int64
- type ModuleStats
- type ModuleStatsSnapshot
- type Tracker
- func (t *Tracker) Blocked() int64
- func (t *Tracker) Findings() int64
- func (t *Tracker) Increment()
- func (t *Tracker) IncrementBlocked()
- func (t *Tracker) IncrementFindings()
- func (t *Tracker) Processed() int64
- func (t *Tracker) Start(ctx context.Context)
- func (t *Tracker) Stop()
- func (t *Tracker) Total() int64
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) For ¶ added in v0.5.7
func (mm *ModuleMetrics) For(moduleID string) *ModuleStats
For returns moduleID's live stats and marks the module considered, so a caller recording several things about one module call looks it up once. Returns nil on a nil receiver; every ModuleStats recording method is nil-safe.
func (*ModuleMetrics) LatencyQuantile ¶ added in v0.5.7
LatencyQuantile returns moduleID's approximate completed-call latency at quantile q and the number of samples it is based on.
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 ¶
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) RecordInconclusive ¶ added in v0.5.7
func (mm *ModuleMetrics) RecordInconclusive(moduleID string)
RecordInconclusive counts one module call whose result is inconclusive (completed while throttled or cut short by the request budget, nothing found). Safe on a nil receiver.
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
// Requests counts wire attempts sent by the module's calls (Requester
// WithCall); request-cache hits and redirect hops are not counted.
Requests atomic.Int64
// Inconclusive counts calls that completed with no finding while the host
// throttled them (429/503): their negatives are not real negatives.
Inconclusive atomic.Int64
// contains filtered or unexported fields
}
ModuleStats tracks per-module performance metrics using atomic counters for lock-free concurrent access from multiple worker goroutines.
func (*ModuleStats) AddRequests ¶ added in v0.5.7
func (ms *ModuleStats) AddRequests(n int64)
AddRequests adds n wire requests to the module's tally. Called once per module call when its work has unwound (so requests sent after a timeout still count). Safe on a nil receiver; n <= 0 is a no-op.
func (*ModuleStats) Record ¶ added in v0.5.7
func (ms *ModuleStats) Record(duration time.Duration, findings int, err error)
Record records one invocation of the module. Safe on a nil receiver.
func (*ModuleStats) RecordCompletedDuration ¶ added in v0.5.7
func (ms *ModuleStats) RecordCompletedDuration(d time.Duration)
RecordCompletedDuration records the duration of a module call that finished inside its timeout, for the adaptive timeout's latency model. Calls that timed out or were interrupted must not be recorded: they would teach the model that the timeout itself is normal. Safe on a nil receiver.
type ModuleStatsSnapshot ¶
type ModuleStatsSnapshot struct {
Invocations int64
Findings int64
Errors int64
TotalTime time.Duration
Requests int64
// Inconclusive: calls that completed while throttled with nothing found.
Inconclusive int64
}
ModuleStatsSnapshot is a point-in-time snapshot of a module's metrics.
func (*ModuleStatsSnapshot) Add ¶ added in v0.5.7
func (s *ModuleStatsSnapshot) Add(o ModuleStatsSnapshot)
Add accumulates o's counters into s.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker tracks scan statistics and prints progress periodically.
func New ¶
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) 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) Start ¶
Start begins printing statistics every 5 seconds. Should be called once. Blocks until ctx is done or Stop is called.