Add metrics command#19
Conversation
WalkthroughAdds a new Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
skills/apitally-cli/SKILL.md (1)
59-144: Add fence languages to the new workflow examples.The new CLI and SQL snippets are currently untyped, which is what the MD040 warnings are complaining about. Adding
bashfor command blocks andsqlfor query blocks will keep the skill docs lint-clean.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/apitally-cli/SKILL.md` around lines 59 - 144, The code fences in SKILL.md for CLI commands (e.g., the npx `@apitally/cli` examples such as the endpoints, consumers, metrics, request-logs, request-details commands) and the SQL examples (the DuckDB queries under "Query DuckDB" and the investigation SQL blocks) need explicit languages to satisfy MD040; update each backtick-fenced block so command examples use ```bash and SQL examples use ```sql (search for snippets containing npx `@apitally/cli` and the SELECT ... FROM request_logs / metrics queries) to remove the lint warnings.skills/apitally-cli/references/commands.md (1)
84-144: Add language identifiers to the new metrics fences.Markdownlint is already flagging these new blocks. Tag the CLI example as
bashand the filter/output samples asjsonso the reference stays lint-clean.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/apitally-cli/references/commands.md` around lines 84 - 144, The markdown code fences for the `metrics` CLI docs are missing language identifiers; update the three new fences so the first command block (the npx `@apitally/cli` metrics example) is tagged as bash, and the two JSON example blocks (the Filters examples block and the Example NDJSON output block) are tagged as json—look for the triple-backtick blocks surrounding the npx command, the filter examples JSON array, and the NDJSON output and add the appropriate language identifiers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/metrics.rs`:
- Around line 13-31: The DuckDB refresh is too weak because deletion/refresh
logic only keys off app_id and period bounds, allowing mixed rollups to
conflict; add persistent fetch-shape discriminator columns to the metrics table
(e.g., interval, group_by, metric_set or similar column names used in your
ingest path) and change the refresh/delete logic in the refresh routine to
include those discriminator columns when deleting/upserting rows for a staged
load (replace the current app_id + MIN/MAX(period_*) logic). Also ensure the
refresh path (the code that computes staged MIN/MAX(period_start/period_end))
rejects empty staged fetches or falls back to a safe sentinel so NULL MIN/MAX
cannot cause no-op deletions; if you prefer, alternatively make db writes reject
mixed-shape writes by validating the staged fetch-shape against existing stored
discriminator values before deleting/upserting.
---
Nitpick comments:
In `@skills/apitally-cli/references/commands.md`:
- Around line 84-144: The markdown code fences for the `metrics` CLI docs are
missing language identifiers; update the three new fences so the first command
block (the npx `@apitally/cli` metrics example) is tagged as bash, and the two
JSON example blocks (the Filters examples block and the Example NDJSON output
block) are tagged as json—look for the triple-backtick blocks surrounding the
npx command, the filter examples JSON array, and the NDJSON output and add the
appropriate language identifiers.
In `@skills/apitally-cli/SKILL.md`:
- Around line 59-144: The code fences in SKILL.md for CLI commands (e.g., the
npx `@apitally/cli` examples such as the endpoints, consumers, metrics,
request-logs, request-details commands) and the SQL examples (the DuckDB queries
under "Query DuckDB" and the investigation SQL blocks) need explicit languages
to satisfy MD040; update each backtick-fenced block so command examples use
```bash and SQL examples use ```sql (search for snippets containing npx
`@apitally/cli` and the SELECT ... FROM request_logs / metrics queries) to remove
the lint warnings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ffeba5e0-82f2-4174-b157-bf101a2c8761
📒 Files selected for processing (8)
AGENTS.mdREADME.mdskills/apitally-cli/SKILL.mdskills/apitally-cli/references/commands.mdskills/apitally-cli/references/duckdb_tables.mdsrc/main.rssrc/metrics.rssrc/reset_db.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
==========================================
- Coverage 91.30% 90.80% -0.51%
==========================================
Files 11 12 +1
Lines 1565 1817 +252
==========================================
+ Hits 1429 1650 +221
- Misses 136 167 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skills/apitally-cli/references/commands.md`:
- Around line 86-90: Add a language tag (e.g., bash) to the fenced code block
that contains the npx `@apitally/cli` metrics usage example so the markdown fence
becomes ```bash ... ```, updating the block that starts with "npx `@apitally/cli`
metrics <app-id> --since <datetime> --metrics <json> \" to include the language
identifier for proper linting and rendering.
- Around line 103-104: Update the "Deduplication in DuckDB" description to
precisely reflect the implemented bounded delete semantics: state that for each
app_id the process deletes existing rows where period_start >= min(period_start)
and period_end <= max(period_end) of the staged (fetched) rows, rather than
saying "within the fetched time range", so readers understand the delete uses
those exact bounds and not arbitrary overlap matching.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e6b375f9-1a5e-4af5-8884-f4515776edda
📒 Files selected for processing (1)
skills/apitally-cli/references/commands.md
Summary by CodeRabbit
New Features
metricscommand to fetch aggregated per-app metrics with required--sinceand--metrics, optional--until,--interval,--group-by,--filters,--timezone, and--dbto persist results to DuckDB.Documentation
metricsusage and schema.Tests