Skip to content

feat(billing): Group usage by tags in the usage service - #552

Draft
volokluev wants to merge 2 commits into
mainfrom
feat/usage-group-by-tags
Draft

volokluev wants to merge 2 commits into
mainfrom
feat/usage-group-by-tags

Conversation

@volokluev

Copy link
Copy Markdown
Member

SEER_CREDITS usage carries the Seer feature that incurred it, but GetUsage and GetUsageByProject only return a total per category. This adds a way to ask for that usage split by tag.

  • GetUsageRequest and GetUsageByProjectRequest get repeated string group_by, the tag keys to split by, e.g. ["feature"].
  • CategoryUsage gets repeated TaggedUsage tagged_usage, one entry per distinct combination of tag values. data is still the category total, so callers that don't set group_by see no change.
  • New billing.v1.UsageTag key/value message. Tags are a repeated list rather than a map so they stay in group_by order.

Tag keys are strings so other categories can add tags without a proto change. The service is expected to accept only the keys each category supports. A category without a requested tag returns one entry with an empty value, so tagged_usage always covers data.

For the getsentry implementation:

  • Seer credits are floored per conversion, so per-feature amounts can add up to less than data.total unless the remainder is handed out across features.
  • The LLM proxy cost query sums per category to keep its 10,000-row limit independent of feature count. Grouping by feature multiplies its rows by the number of features.

🤖 Generated with Claude Code

SEER_CREDITS usage carries the Seer feature that incurred it, but
GetUsage and GetUsageByProject only report a total per category. A new
group_by field on both requests names the tag keys to split usage by,
and each CategoryUsage returns the split in tagged_usage while data
keeps the category total, so existing callers see no change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedNov 24, 2026, 12:59 AM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant