-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(billing-platform): Add daily usage breakdown endpoint protos #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package sentry_protos.billing.v1.services.usage_pricer.v1; | ||
|
|
||
| import "sentry_protos/billing/v1/date.proto"; | ||
| import "sentry_protos/billing/v1/usage_data.proto"; | ||
|
|
||
| // Compiles per-day, per-line-item usage breakdowns spanning one or more | ||
| // contracts. UsagePricer evaluates each contract's package | ||
| // ``BillableMetric.expression`` once per outcome field of the raw | ||
| // usage, so callers receive the package-projected ``UsageData`` view | ||
| // rather than the raw outcomes returned by ``BillingUsageService``. | ||
| // | ||
| // This is the "non-pricing" derived view UsagePricer exposes -- the | ||
| // projection step pricing already performs internally, lifted out so | ||
| // other presentation services (e.g. ChargeService for CSV / UI) can | ||
| // consume it without re-implementing evaluation. | ||
| message GetDailyBreakdownRequest { | ||
| // The contracts whose daily breakdowns should be returned. | ||
| repeated string contract_ids = 1; | ||
| } | ||
|
|
||
| // One line item's projected per-outcome quantities on a given date. | ||
| message LineItemDailyOutcomes { | ||
| // Package line item uid (UsagePricer's native vocabulary). | ||
| string line_item_uid = 1; | ||
|
|
||
| // The seven outcome fields, each populated by evaluating the line | ||
| // item's ``BillableMetric.expression`` against that outcome's raw | ||
| // counts in the day's usage. | ||
| sentry_protos.billing.v1.UsageData outcomes = 2; | ||
| } | ||
|
|
||
| // One row per calendar date spanning the union of the requested | ||
| // contracts' on-demand periods. | ||
| message DailyLineItemOutcomes { | ||
| sentry_protos.billing.v1.Date date = 1; | ||
|
|
||
| // Per-line-item outcomes on this date. Every metered line item from | ||
| // the union of the requested contracts' packages is emitted, | ||
| // including line items with zero usage, so consumers can render | ||
| // zero-rows without a separate zero-fill pass. | ||
| repeated LineItemDailyOutcomes line_items = 2; | ||
| } | ||
|
|
||
| message GetDailyBreakdownResponse { | ||
| // Days in ascending date order. A given calendar date appears at | ||
| // most once regardless of how many of the requested contracts | ||
| // overlap it (BillingUsageService reports usage at calendar-day | ||
| // granularity, so a day straddling a mid-day rollover is still one | ||
| // row carrying the day's full outcomes). Contract ids from the | ||
| // request that do not resolve contribute no rows. | ||
| repeated DailyLineItemOutcomes days = 1; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,11 @@ pub struct BillingConfig { | |
| /// (1 = monthly, 12 = annual). Frozen for the life of the contract. | ||
| #[prost(uint32, tag = "7")] | ||
| pub month_interval: u32, | ||
| /// Whether the org is allowed to incur pay-as-you-go usage. | ||
| /// Credit-card orgs always support payg; invoiced orgs that should | ||
| /// support it are an explicit override. | ||
| #[prost(bool, tag = "8")] | ||
| pub supports_payg: bool, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rust field missing proto sourceMedium Severity Generated Reviewed by Cursor Bugbot for commit 2060a5f. Configure here. |
||
| } | ||
| /// Indicates how the account is billed. | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contract IDs use wrong type
High Severity
GetDailyBreakdownRequestdeclarescontract_idsasrepeated string, while contract identifiers elsewhere in billing protos (includingGetPriceForContractRequestandContractmetadata) areuint64. Callers and implementations that follow the established contract API will use the wrong wire type and field encoding for this request.Reviewed by Cursor Bugbot for commit 2060a5f. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of think we should start using string, we can always represent a uint64 as a string