Skip to content

Decouple scrape path with cached scans and add scan observability#5

Draft
Codex wants to merge 2 commits intomainfrom
codex/review-collect-function-errors
Draft

Decouple scrape path with cached scans and add scan observability#5
Codex wants to merge 2 commits intomainfrom
codex/review-collect-function-errors

Conversation

@Codex
Copy link

@Codex Codex AI commented Feb 24, 2026

Prometheus scrapes were performing heavy filesystem IO inline, risking timeouts and partial data; defaults also assumed a macOS system skills path and markdown heading parsing was narrow.

  • Background scanning cache
    • Added timed background scan with mutex-protected snapshot; Collect now only serves cached metrics, avoiding scrape-thread IO and tracking last duration/errors.
  • Observability
    • New metrics: openclaw_scan_duration_seconds, openclaw_scan_errors_total; scan latency recorded via registered ResponseLatencyCollector.
  • Robustness tweaks
    • System skills dir resolved only when explicitly set or on macOS with existing path; markdown section counting accepts whitespace after ##.

Example (cached collect path):

// Collect now reads from cached snapshot
c.mu.RLock()
snap := c.snapshot
c.mu.RUnlock()

ch <- prometheus.MustNewConstMetric(c.scrapeSuccess, prometheus.GaugeValue, snap.scrapeSuccess)

@Codex Codex AI changed the title [WIP] Improve error handling in Collect function Decouple scrape path with cached scans and add scan observability Feb 24, 2026
@Codex Codex AI requested a review from JetSquirrel February 24, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants