Refactor exporter into modules
This commit is contained in:
@@ -108,6 +108,9 @@ Derived from `sessions.json`:
|
||||
- `openclaw_exporter_files_scanned`
|
||||
- `openclaw_exporter_lines_scanned`
|
||||
- `openclaw_exporter_parse_errors`
|
||||
- `openclaw_exporter_negative_cost_entries_skipped`
|
||||
- `openclaw_exporter_negative_cost_fields_skipped{cost_field=...}`
|
||||
- `openclaw_exporter_negative_cost_amount_skipped{cost_field=...}`
|
||||
- `openclaw_exporter_history_days_retained`
|
||||
- `openclaw_exporter_history_hours_retained`
|
||||
- `openclaw_usage_cost_cache_files_tracked`
|
||||
@@ -120,6 +123,17 @@ This exporter intentionally skips obvious revealing fields like message content,
|
||||
|
||||
Session ids are exported.
|
||||
|
||||
It also ignores invalid negative cost values found in some legacy/raw usage records and exposes exporter metrics for how many were skipped.
|
||||
|
||||
## Code layout
|
||||
|
||||
- `app.py` keeps the uvicorn entrypoint tiny
|
||||
- `openclaw_usage_exporter/config.py` holds env-driven paths and retention settings
|
||||
- `openclaw_usage_exporter/models.py` holds report dataclasses and cost handling
|
||||
- `openclaw_usage_exporter/collectors.py` reads session files and cache/index data
|
||||
- `openclaw_usage_exporter/metrics.py` renders Prometheus output
|
||||
- `openclaw_usage_exporter/utils.py` keeps shared helpers small
|
||||
|
||||
## Run locally
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user