Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Thanks a lot for this contribution! This is a substantial PR so we'll need some time to review it properly. Will follow up with detailed feedback once we've gone through everything. |
|
No problem! Let me know if there is anything that needs re-thinking. Happy to help :) |
|
Thanks for the detailed PR! I've done an initial review and the overall structure looks solid - clean separation, good test coverage, and consistent use of parameterized SQL. A few things I'd like to address before merging: Query bounds:
Minor code issues:
Typo:
Worth considering (non-blocking):
Happy to discuss any of these. Nice work on the docs and Python examples. |
|
Glad that the PR looks good - I've gone through your comments and made these changes: -
I didn't change Also had a couple thoughts with where to take this next. Won't be doing it anytime soon, but any thoughts?
Let me know if somethings not right, or if we should make more changes before merging :) |
99d54b4 to
6052ff6
Compare
|
Hey @sgogriff, great work on the follow-up! You addressed everything cleanly - the SQL bucketing, SQLite error codes, retention/pruning, and the bounded summary query are all solid. Really nice execution. I did a deeper pass and found a few more items to tidy up before we merge: Must fix:
Design questions (non-blocking, just want your thoughts):
Merge conflicts: The PR currently has merge conflicts with On your future ideas - both a settings tab and threshold alerts sound great. The threshold alerts especially would be a killer feature for teams monitoring spend. Happy to discuss those in separate issues when you're ready. Thanks again for the solid contribution and quick turnaround on feedback! |
…geBucketsLimit, plus tests
eb0aba7 to
2fd1fdf
Compare
|
Thanks for the detailed pass, all fixed up! Extra - removed the closing tag. Bucket query LIMIT - added apiIntegrationUsageBucketsLimit = 5000 constant as you suggested and capped the query alongside the existing summary limit. Fingerprint precision - switched to time.RFC3339Nano in eventFingerprint. String length validation - added maxIntegrationFieldLen = 256 and maxMetadataJSONLen = 4096 constants with guards in ParseUsageEventLine for integration, model, account, and compacted metadata_json. Tests added for each rejection path. source_path index - added CREATE INDEX IF NOT EXISTS idx_api_integration_usage_events_source to the schema. Since it uses IF NOT EXISTS it runs on startup and covers existing databases automatically. raw_line removal - dropped the field from the struct, removed it from INSERT/SELECT, and removed it from the schema. Added a DROP COLUMN migration in migrateSchema() for existing databases (with a TODO comment to remove it once everyone has migrated - a very very small number of users on this fork so should be quick, but nicer for us!). Also rebased onto latest main - one conflict in config.go around the CodexHasProfiles field, resolved by keeping the upstream version. Regarding the design; An alert feature is definitely on the roadmap -- it would be a very good addition. I'll get to it at some point, but you're welcome to take it on yourself if you'd rather not wait! :) |
|
Hey @sgogriff, all six must-fixes from the last round are verified and look solid. Rebase is clean. Did a security pass - parameterized SQL, XSS escaping, auth on new endpoints, input validation all check out. Three more items before merge:
The flaky test fix is fine to keep here. Will open an issue for the |
- Add 512KB cap on PartialLine with discard + warning when exceeded - Rate-limit invalid line alerts to 10 per file per scan cycle - Cap file scan to 100 files per cycle with round-robin cursor for coverage All three prevent memory/DB flooding from malformed input files.
|
Hey @prakersh, |
Summary
Adds API Integrations as a new telemetry subsystem for tracking token and cost usage from custom API-driven scripts via local JSONL ingestion.
What Changed
Notes
ONWATCH_API_INTEGRATIONS_ENABLEDONWATCH_API_INTEGRATIONS_DIRTesting
go test -race ./...go vet ./...examples/api_integrations/pythonalong with .py examples and JSONL wrapper.Screenshots!