feat(usage): add hotdata usage command#174
Merged
Merged
Conversation
SDK 0.4.0 added the usage API (`GET /v1/usage`) but the CLI exposed no surface for it. Add a `usage` command that reports workspace usage for the current billing window (or `--since <rfc3339>`): hotdata usage [--since <ts>] [-w <ws>] [-o table|json|yaml] Shows query_count, bytes_scanned, storage_bytes, and storage_captured_at. Table view renders byte counts human-readably; json/yaml keep raw integers. query_count/bytes_scanned accrue per query in real time; storage_bytes is a periodic snapshot (storage_captured_at), so uploads show up on the next capture, not instantly. Uses the seam's raw `get_json` helper (no typed SDK handle exists for usage). Documented in the core skill. Verified against production (table + --since + json).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SDK 0.4.0 (#171) added the usage API (
GET /v1/usage), but the CLI exposed no command for it. This addshotdata usage:Reports workspace usage for the current billing window (or since
--since):query_count,bytes_scanned,storage_bytes, andstorage_captured_at.Behavior
query_countandbytes_scannedaccrue per query in real time (data reads).storage_bytesis a periodic snapshot taken atstorage_captured_at, so uploads are reflected on the next capture, not instantly.21.7 MiB (22706766 B));-o json/yamlkeep raw integers.Implementation
src/usage.rs, wired throughcommand.rs+main.rs.get_json("/usage", …)helper — there's no typed SDK handle for usage (only the freeusage_api::get_usagefunction), and this matches howindexes.rsalready does untyped GETs.databases/indexes.hotdataskill (subcommand list + a Usage section).Tests / verification
storage_captured_at) and the human-bytes formatter.fmt/clippyclean for the new code.hotdata usage→ table with all five metricshotdata usage --since 2026-06-15T00:00:00Z -o json→query_countdrops from 186 (month-to-date) to 45, confirming--sinceis honored