Review
Feature-flag rollout of pricing engine v2
Runs pricing v2 in shadow mode behind a flag: v1 remains authoritative, v2 results are computed and compared, mismatches are logged with a metric for a week before any cutover decision.
FastAPITier 8architecturerollout
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
app/pricing/rollout.py+15-0
| 6 | + | def price_order(order: Order) -> Decimal: | |
| 7 | + | v1 = pricing_v1.price(order) | |
| 8 | + | if flags.enabled("pricing_v2_shadow", order.tenant_id): | |
| 9 | + | try: | |
| 10 | + | v2 = pricing_v2.price(order) | |
| 11 | + | if v2 != v1: | |
| 12 | + | metrics.incr("pricing_v2.mismatch") | |
| 13 | + | log.warning( | |
| 14 | + | "pricing v2 mismatch", | |
| 15 | + | order_id=order.id, v1=str(v1), v2=str(v2), | |
| 16 | + | ) | |
| 17 | + | except Exception: | |
| 18 | + | log.exception("pricing v2 shadow failed", order_id=order.id) | |
| 19 | + | metrics.incr("pricing_v2.error") | |
| 20 | + | return v1 |