-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: usage/cost exceeded events (#25)
Save usage and cost exceeded events in separate tables to get further insights and make them queryable. We plan to activate some alerts without any actual actions, but want to see how good it works at our scale first. Also upgraded to Node 22 and latest deps.
- Loading branch information
Showing
14 changed files
with
298 additions
and
271 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20 | ||
v22 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
create table | ||
if not exists orb.subscription_usage_exceeded ( | ||
id BIGSERIAL primary key, | ||
billable_metric_id varchar(255) not null, | ||
subscription_id varchar(255) not null, | ||
customer_id varchar(255) not null, | ||
external_customer_id varchar(255), | ||
timeframe_start timestamp not null, | ||
timeframe_end timestamp not null, | ||
quantity_threshold decimal not null, | ||
created_at timestamp not null default now() | ||
); | ||
|
||
create index if not exists orb_subscription_usage_exceeded_subscription_idx on orb.subscription_usage_exceeded (subscription_id); | ||
create index if not exists orb_subscription_usage_exceeded_customer_idx on orb.subscription_usage_exceeded (customer_id); | ||
create index if not exists orb_subscription_usage_exceeded_external_customer_idx on orb.subscription_usage_exceeded (external_customer_id); | ||
|
||
create table | ||
if not exists orb.subscription_cost_exceeded ( | ||
id BIGSERIAL primary key, | ||
subscription_id varchar(255) not null, | ||
customer_id varchar(255) not null, | ||
external_customer_id varchar(255), | ||
timeframe_start timestamp not null, | ||
timeframe_end timestamp not null, | ||
amount_threshold decimal not null, | ||
created_at timestamp not null default now() | ||
); | ||
|
||
|
||
create index if not exists orb_subscription_cost_exceeded_subscription_idx on orb.subscription_cost_exceeded (subscription_id); | ||
create index if not exists orb_subscription_cost_exceeded_customer_idx on orb.subscription_cost_exceeded (customer_id); | ||
create index if not exists orb_subscription_cost_exceeded_external_customer_idx on orb.subscription_cost_exceeded (external_customer_id); |
This file contains 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
Oops, something went wrong.