feat: add API event recorder interface for billing#1266
Merged
zhenghaoz merged 4 commits intogorse-io:masterfrom May 7, 2026
Merged
feat: add API event recorder interface for billing#1266zhenghaoz merged 4 commits intogorse-io:masterfrom
zhenghaoz merged 4 commits intogorse-io:masterfrom
Conversation
Add common/event package with: - APIEvent struct for recording API call metadata - Recorder interface for event storage backends - NopRecorder (disabled/no-op implementation) - BufferRecorder (in-memory buffer for testing) - Global recorder setter/getter functions This provides the foundation for future billing and metering functionality.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1266 +/- ##
==========================================
+ Coverage 72.89% 72.95% +0.05%
==========================================
Files 91 92 +1
Lines 16743 16764 +21
==========================================
+ Hits 12205 12230 +25
+ Misses 3293 3288 -5
- Partials 1245 1246 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add event.Handle call in server LogFilter - Record API request metadata for billing - Add global handler with AddFlags/SetHandler pattern (like log package) - Rename Recorder to Handler for consistency
Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new common/event package intended to record API and storage usage events for future billing/metering, and wires it into the REST access filter and master dataset-loading path.
Changes:
- Added
common/eventwithAPIEvent/StorageEventtypes, aRecorderinterface, and a global recorder setter/getter (defaulting toNopRecorder). - Hooked API event recording into
server.RestServer.LogFilter. - Hooked storage event recording into
master.(*Master).loadDataset, plus added basic unit tests for recorder swapping.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| server/rest.go | Records API call metadata via the global event recorder from the REST logging filter. |
| master/tasks.go | Records storage usage counts after dataset load via the global event recorder. |
| common/event/event.go | New event types + recorder interface + global recorder wiring (defaults to no-op). |
| common/event/event_test.go | Adds a mock-based test verifying SetEventRecorder/EventRecorder behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Add common/event package for recording API call events, designed for future billing/metering functionality.
Changes
Usage
Future Extensions
Testing
go build ./common/event/