Documentation
¶
Overview ¶
Package stats turns events.db rows into the refetch stats report: how many web reads failed, how many refetch picked up and how many it resolved, and which step won.
Index ¶
Constants ¶
const InlineTool = "refetch:inline"
InlineTool is the tool name recorded for a page the hook fetched itself (mode = "inline"); it counts as a fetch_page call.
const PickupWindow = 10 * time.Minute
PickupWindow is how long after a failed read a fetch_page call for the same URL still counts as picking it up.
Variables ¶
This section is empty.
Functions ¶
func IsFetchPage ¶
IsFetchPage reports whether a tool name is refetch's fetch_page, as a plugin (mcp__plugin_refetch_refetch__fetch_page) or added with claude mcp add (mcp__refetch__fetch_page), or an inline fetch by the hook.
Types ¶
type Fetches ¶
type Fetches struct {
Total int `json:"total"`
OK int `json:"ok"`
OKBy map[string]int `json:"ok_by,omitempty"`
FailedBy map[string]int `json:"failed_by,omitempty"`
MedianMS int64 `json:"median_ms"`
}
Fetches summarizes the attempts table by fetch: what fetch_page (and refetch get) did, whether or not a hook saw the call.
type Header ¶
type Header struct {
Version string
DataPath string
Bytes int64
Chrome string // like "Chrome 155"; "" when none was found
RenderTimeout string // like "15s"
}
Header is context outside the report data.
type Headless ¶
type Headless struct {
Needed int `json:"needed"`
Ran int `json:"ran"`
OK int `json:"ok"`
TimedOut int `json:"timed_out"`
Failed int `json:"failed"`
SkippedByCall int `json:"skipped_by_call"`
SkippedOff int `json:"skipped_off"`
NoChrome int `json:"no_chrome"`
SkippedRoot int `json:"skipped_root"`
MedianMS int64 `json:"median_ms"` // of the runs
}
Headless counts the headless Chrome step: needed whenever the HTTP clients got a challenge or a JavaScript-only page, then either ran or was skipped.
type HostRow ¶
type HostRow struct {
Host string `json:"host"`
Reads int `json:"reads"`
Failed int `json:"failed"`
PickedUp int `json:"picked_up"`
Resolved int `json:"resolved"`
Fetches int `json:"fetches"`
}
HostRow is one host's funnel.
type Report ¶
type Report struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
Sessions int `json:"sessions"`
Reads int `json:"reads"`
OKFirst int `json:"ok_first_time"`
Failed int `json:"failed"`
PickedUp int `json:"picked_up"`
Resolved int `json:"resolved"`
ResolvedBy map[string]int `json:"resolved_by,omitempty"` // winning client
StillFailed int `json:"still_failed"`
FailedWhy map[string]int `json:"still_failed_by,omitempty"` // last attempt's outcome
NotPickedUp int `json:"not_picked_up"`
Direct int `json:"direct_fetch_page"`
DirectOK int `json:"direct_fetch_page_ok"`
TopHosts []HostCount `json:"top_hosts,omitempty"` // hosts of picked-up reads
HeadlessWins map[string]int `json:"headless_wins_by_trigger,omitempty"` // resolved by headless Chrome, by what sent the page there
Fetches Fetches `json:"fetches"` // every fetch_page and refetch get, from the attempts table
Headless Headless `json:"headless"` // the headless Chrome step over all fetches
Wayback Wayback `json:"wayback"` // the Wayback Machine step over all fetches
Hosts []HostRow `json:"hosts,omitempty"` // filled for --by host
}
Report is the efficiency report. Counts are of web reads unless named otherwise.