Current way of rating does not work for every situation. #318
Description
The formula that we have for linux-container does not work for every situation. The current formula will only work when none of the metering/rating/pricing plan changes.
The differences between non-time-based and time-based usage is that non-time-based's usage is independent of time(It is not consuming continuously). This means that anytime after metering/rating/pricing plan changes, the usage submitted by the service provider would be put into the new plan instead of the old plan (EDIT: It is possible for early submission to get tagged with the wrong price when the new pricing plan is not yet onboarded).
On the other hand, when time-based usage's metering/rating/pricing plan changes, there is no events that would trigger the switch to the new plan because currently the bridge is submitting what it receives from cf events and there is no cf events for any business related changes.
Example:
Current implementation
- Bridge / time-based submitter submit a usage from cf-event to abacus collector.
- Abacus understand that a service instance is running and it attaches the price of the time-based at the submission time to the usage doc.
- When we grab the report, the usage would be metered/rated using the price at the submission time.
This works fine when the price remains the same between the submission time and reporting time.
But when the pricing(or metering / rating) changes between the submission time and reporting time, the charge reflected in the report would be rated using the price at the submission time, and there would be no charge associated with the new price.
Example: An application is running from February 1st to February 4th consuming 1 GB-hour.
- In February 1st, Bridge / time-based submitter submit a usage from cf-event to abacus collector.
- Abacus collector put this usage in the meteringPlanA/ratingPlanA/pricingPlanA.
- In February 3rd, one of the plan, lets say the pricingPlanA changes to pricingPlanB.
- During the reporting time, the application would be rated using pricingPlanA, and abacus would not be aware of meteringPlanA/ratingPlanA/pricingPlanB.
Pricing plan A = $1 / GB
Pricing plan B = $2 / GB
Current implementation would report: 4 days * 24 hour / day * 1 GB / hour * $1 / GB = $96.
What should be reported is: 2 days * 24 hour / day * 1 GB / hour * $1 / GB + 2 days * 24 hour / day * 1 GB / hour * $2 / GB = $48 + $96 = $144
I would like to start a discussion on the proper solution to solve this issue. Some points:
- Do we need the separation of time-based and non-time-based?
- When getting the report / rating, pass multiple plans that are used during the period? Adding effective dates to each plans. (Using the example above, it would be passing pricingPlanA with effective date 1st to 3rd, and pricingPlanB with effective date 3rd to 4th )
- Anything that comes to mind that I am missing / should consider?
Thanks!