Open
Conversation
Collaborator
|
Thanks for the PR. Sorry it took so long to review. Some remarks from the review:
None of these are blockers architecturally but merging as-is will surface in someone's Grafana as "numbers changed on April XX, 2026, and nobody knows why." Thx |
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
Major refactor of the metrics export script with improved architecture, better error handling, and enhanced token attribution logic.
✨ Improvements
Architecture & Code Quality
.envfileFunctionality
--forceflag to re-process existing dates--cleanupflag to remove data outside range--days,--start-date/--end-date)Changes & Behavioral Differences
1. Token Attribution Logic (MAJOR CHANGE)
Old behavior:
prompt/completion) or 50/50 for integer tokensNew behavior:
2. Unique User Calculation
Old: Counted all messages (user + AI)
New: Only counts messages where
isCreatedByUser=trueImpact: User counts will be more accurate but numerically different
3. Messages by Model
Old: Counted all messages (user messages as "unknown")
New: Only counts AI response messages with token counts
Impact: Message counts exclude user messages entirely
4. MongoDB Read Preference
Old:
secondary(always read from replica secondaries)New:
primaryPreferred(read from primary, fallback to secondary)Impact: Better for single-instance deployments, but may increase primary load
5. Data Clearing Strategy
Old: Always truncates all tables before processing
New: Incremental by default, only clears with
--forceflagImpact: Safer, but use
--force --cleanupto match old behavior