You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(statapi): add /wait0 stats endpoint and refresh metrics
- add authenticated GET /wait0 and /wait0/ control endpoint with stats:read scope
- add 5s snapshot-cached stats payload for cache, memory, sitemap, and refresh durations
- instrument revalidation durations and expose min/avg/max as refresh_duration_ms
- extend cache metadata snapshots for efficient aggregate calculations
- update debug config, docs, architecture notes, and tests for new endpoint behavior
|`generated_at`| RFC3339Nano string | UTC timestamp when this snapshot was generated. |`time.Now().UTC()` at snapshot build time. | New value only when snapshot is recomputed. |
126
+
|`snapshot_ttl_seconds`| integer | Snapshot cache TTL used by `/wait0`. | Fixed constant `5`. | Endpoint may return identical payload for calls within this TTL. |
127
+
|`cache.urls_total`| integer | Total number of unique cached keys currently known to wait0. Includes active + inactive entries. | Unique union of RAM keys and disk keys. | Recomputed per snapshot. |
128
+
|`cache.responses_size_bytes_total`| integer (bytes) | Total logical size of cached responses for all unique keys. | Sum over unique keys of per-entry logical size (`headers + body` bytes). | Recomputed per snapshot. |
129
+
|`cache.response_size_bytes.min`| integer (bytes) | Smallest logical response size among unique cached keys. | Min of per-key logical response size. | Recomputed per snapshot; `0` when no keys. |
130
+
|`cache.response_size_bytes.avg`| integer (bytes) | Average logical response size among unique cached keys. |`responses_size_bytes_total / urls_total` (integer division). | Recomputed per snapshot; `0` when no keys. |
131
+
|`cache.response_size_bytes.max`| integer (bytes) | Largest logical response size among unique cached keys. | Max of per-key logical response size. | Recomputed per snapshot; `0` when no keys. |
132
+
|`memory.rss_bytes`| integer (bytes) | Current process resident memory (RSS) as seen by OS probes. |`ProcessRSSBytes()`; `0` when unavailable on platform/runtime. | Recomputed per snapshot. |
133
+
|`memory.go_alloc_bytes`| integer (bytes) | Current heap bytes allocated by Go runtime. |`runtime.ReadMemStats(&ms); ms.Alloc`. | Recomputed per snapshot. |
134
+
|`refresh_duration_ms.min`| integer (ms) | Fastest observed revalidation execution time. | Min of observed `revalidation.Once(...)` durations, converted to milliseconds. | Process-lifetime aggregate since current process start. |
135
+
|`refresh_duration_ms.avg`| integer (ms) | Average observed revalidation execution time. | Sum of all observed revalidation durations / count, converted to ms (integer division). | Process-lifetime aggregate since current process start. |
136
+
|`refresh_duration_ms.max`| integer (ms) | Slowest observed revalidation execution time. | Max of observed `revalidation.Once(...)` durations, converted to milliseconds. | Process-lifetime aggregate since current process start. |
137
+
|`sitemap.discovered_urls`| integer | Number of unique cached keys whose discovery source is sitemap. | Count of unique keys where `discovered_by == "sitemap"` (case-insensitive). | Recomputed per snapshot. |
138
+
|`sitemap.crawled_urls`| integer | Number of sitemap-discovered keys that are currently active (not inactive seed entries). | Count of sitemap keys where `inactive == false`. | Recomputed per snapshot. |
139
+
|`sitemap.crawl_percentage`| float | Share of sitemap-discovered keys currently crawled/active. |`crawled_urls * 100 / discovered_urls`; `0` if `discovered_urls == 0`. | Recomputed per snapshot. |
140
+
141
+
### Additional interpretation notes
142
+
143
+
- Snapshot caching: `/wait0` returns cached stats for up to `snapshot_ttl_seconds`; polling faster than TTL will often return unchanged values.
144
+
- Lifetime vs point-in-time:
145
+
-`refresh_duration_ms.*` is lifetime cumulative for this process (does not reset per warmup batch).
146
+
-`cache.*`, `memory.*`, `sitemap.*` are point-in-time values at snapshot generation.
147
+
- Duplicate keys across RAM and disk are deduplicated as one logical cached URL in all `cache.*` and `sitemap.*` counts.
0 commit comments