Skip to content

Conversation

julienbourdeau
Copy link
Contributor

Description

Alerting is coming and we need to calculate CurrentUsage only once per subscription for all services.
This PR breaks down RecalculateAndCheckService into 2 services:

  • CalculateService: was already there but current_usage can be injected (not used yet)
  • CheckThresholdsService: The same as RecalculateAndCheckService except I removed the inner call to CalculateService.

@julienbourdeau julienbourdeau self-assigned this Apr 24, 2025
@julienbourdeau julienbourdeau force-pushed the feat/breakdown-progressivebilling-job branch from bfa8d5a to 4558742 Compare April 24, 2025 07:51
@julienbourdeau julienbourdeau requested a review from nudded April 24, 2025 07:54
@julienbourdeau julienbourdeau marked this pull request as ready for review April 24, 2025 07:57
@julienbourdeau julienbourdeau force-pushed the feat/breakdown-progressivebilling-job branch from 4558742 to 3b4363d Compare April 24, 2025 08:03
@julienbourdeau julienbourdeau merged commit 73ee744 into main Apr 24, 2025
14 checks passed
@julienbourdeau julienbourdeau deleted the feat/breakdown-progressivebilling-job branch April 24, 2025 09:04
julienbourdeau added a commit that referenced this pull request Apr 29, 2025
## Context

First big step toward Alerting feature

## Description

Follows: #3528

* Every time an event is received, we insert a SubscriptionActivity in
the db, unique per subscription
* Every 5 minutes, we recompute `current_usage` for all active
subscription
  * If org has progressive billings, we check the thresholds
* If org is using alerting, we'll check the alert at the same time
(later
* Stop using `lifetime_usage.recalculate_current_usage` but the job
keeps looking at this column until there are not more jobs to process

---------

Co-authored-by: Vincent Pochet <vincent@getlago.com>
annvelents pushed a commit that referenced this pull request May 12, 2025
## Context

First big step toward Alerting feature

## Description

Follows: #3528

* Every time an event is received, we insert a SubscriptionActivity in
the db, unique per subscription
* Every 5 minutes, we recompute `current_usage` for all active
subscription
  * If org has progressive billings, we check the thresholds
* If org is using alerting, we'll check the alert at the same time
(later
* Stop using `lifetime_usage.recalculate_current_usage` but the job
keeps looking at this column until there are not more jobs to process

---------

Co-authored-by: Vincent Pochet <vincent@getlago.com>
julienbourdeau added a commit that referenced this pull request May 22, 2025
…alerts (#3690)

## Context

We're adding Alerting feature, see #3528, #3535, #3554, #3600

## Description

We introducing 2 new types of alerts:
* LifetimeUsageAmount: to define alert based on lifetime total usage
* BillableMetricUsageUnits: same as BillableMetricUsageAmount but with a
number "used units" instead of currency amount.

Creating a new alert is essentially creating a new child class of
`UsageMonitoring::Alert` and implementing `find_value`. 🙌
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.

2 participants