Something broke and nobody noticed: business alarms that find silent failures within hours
TL;DR
Difficulty: Intermediate
A silent failure is a shop that is up and still cannot sell to some customers. Its cost is the hours it runs.
- In the example, Apple Pay broke after a release and stayed broken for 72 hours: 58 orders and €1,302 of contribution lost, found at month end.
- Uptime checks, error trackers and server metrics stayed green. Only the business data showed it.
- Business alarms watch volume, mix (payment method, browser, country), completion (unpaid orders, stuck checkouts) and freshness (feeds, stock, tracking).
- Thresholds come from a baseline per hour of the week, the Poisson and binomial models, and a backtest on your own history.
- The payment failure alarm would have fired after 1 hour 35 minutes. Four late found incidents a year cost €5,206; found within two hours, about €145.
What to read first
The most expensive failures in an online shop do not take the site down. They quietly stop one group of customers from buying, while every technical check stays green. This chapter shows how to notice within hours instead of at month end: which business signals to watch, how to set thresholds that do not cry wolf, and how to build the alarms on Ruby on Rails and Solidus.
The failure that does not look like one
Most things that go wrong in an online shop announce themselves. The site is down, the phone rings, an email arrives in capital letters. The expensive failures are the other kind. The shop is up, every page loads, the server is calm, and yet one group of customers cannot buy. Nobody gets an error they can report, because the error is the absence of something: an order that never arrives.
I call these silent failures. They are quiet leaks in the purest form, because the money leaves after the customer has already decided to buy. The first chapter of this series put a number on them for the example shop. This chapter is about the one lever that decides how much they cost: how long it takes you to notice. It shows how to build alarms that watch the business rather than the machine, how to set them so they fire within hours and still do not cry wolf, and how to wire them into a Ruby on Rails and Solidus shop with a few queries and one scheduled job.
Example: Niamh finds a hole at month end
The example for the whole series is Shannonside Home, an online homeware shop in Limerick (shannonsidehome.example). Niamh owns it, and Callum is her developer and data engineer. The shop runs on Ruby on Rails and Solidus with PostgreSQL, takes about 1,980 orders a month at an average of €84, and keeps a contribution of €22.44 on each order before marketing. All figures in this chapter are the example's, invented for teaching.
On Tuesday 27 October 2026 at 6.10pm, Callum released a small change to the checkout. Everything looked grand. On Friday 30 October, while Niamh was pulling the October figures early, she noticed that Tuesday to Thursday looked weak. Callum dug in and found the cause within the hour: the release had changed the code that passes Apple Pay payments to the payment provider. Every Apple Pay attempt since Tuesday evening had failed. The checkout caught the error politely, said "Sorry, that did not work, please try another way to pay", and carried on. He fixed it at 6.10pm that Friday.
Seventy two hours. On those three days the shop would normally have taken about 198 orders. It took 140. Most of the 58 missing customers were on iPhones and Macs, tried Apple Pay, saw a vague message and left. At €22.44 each, that is €1,301.52 of contribution gone, and nobody had any idea for three days.
Why the usual monitoring stays green
Most shops that have any monitoring at all have three kinds. An uptime check calls the home page every minute and alerts if it does not answer. An error tracker collects exceptions from the code. Server metrics show memory, processor load and response times. All three watch the machine. None of them watches whether people are buying.
Google's site reliability engineers describe the gap well. Their book defines an error as a request that fails "explicitly", such as a server error, or "implicitly", for example a success response "coupled with the wrong content", and notes that catching the second kind takes tests of the whole system from the outside1. A shop's silent failures are almost all of the implicit kind. The page answers with a cheerful 200, the code handles the problem as designed, and the customer goes elsewhere. The same book separates symptoms (what is broken) from causes (why), and recommends alerting on symptoms1. For a shop, the symptom that matters is simple: fewer paid orders than there should be.
Example: what each tool saw during the three days
Here is what Shannonside Home's monitoring reported between Tuesday 6.10pm and Friday 6.10pm, set against what was really happening.
| Tool | What it watched | What it reported |
|---|---|---|
| Uptime check | Home page and checkout page answer | 100% up |
| Error tracker | Unhandled exceptions in the code | No new errors, because the checkout handled the provider's rejection on purpose |
| Server metrics | Memory, processor, response time | Normal, slightly quieter than usual |
| The order table | Paid orders | 140 instead of about 198, Apple Pay at zero |
Every technical signal was green. The only place the failure showed was in the business data, and nobody was looking at it until month end.
Seven ways a shop breaks quietly
Silent failures are not rare accidents. They follow a handful of patterns that repeat in almost every shop, whatever it runs on. Knowing the patterns tells you what to watch.
- A checkout step breaks in one browser or on one payment method after a release. The shop works for the developer, who tests in one browser with a card. It fails for everyone using another browser or wallet.
- A payment method is switched off. Someone unticks a box in the admin while testing, or a provider account needs a document and pauses the method.
- A webhook endpoint fails. A webhook is a message the payment provider sends to the shop to say "this payment went through". If the shop stops accepting those messages, paid orders can sit as unpaid, and the warehouse may not ship them.
- The shipping rate table returns nothing for one country. The customer fills in an address and is told the shop cannot calculate delivery. In Solidus the checkout simply refuses to continue and shows a message that shipping rates cannot be calculated for the selected items2.
- A consent banner update cuts tracking. Orders keep coming, but analytics and the ad platforms stop seeing them, and the bidding goes astray.
- A product feed stops updating. Google Merchant Center removes products 30 days after their last refresh unless Google refreshes them itself from the website3, and prices in the adverts drift from prices in the shop long before that.
- A stock sync marks everything as out of stock. One bad file from the warehouse and the shop politely tells every visitor that nothing is available.
What they share: the site is up, there is no unhandled error, and the cost grows by the hour.
Example: what each failure would do to Shannonside Home's numbers
To see which signal catches which failure, Callum wrote down what each one would look like in Shannonside Home's own data. The normal values are the example's: about 66 orders a day, Safari on 48% of orders, Apple Pay on 32%, PayPal on 12%, about 2.5 orders a day to the UK, 91% of products in stock, and GA4 seeing about 85% of the shop's purchases because of consent and blockers.
| Failure | What the customer sees | Normal value | During the failure | Signal that catches it |
|---|---|---|---|---|
| Apple Pay broken after a release | "Please try another way to pay" | 4 in 100 Apple Pay attempts fail | All fail | Failure share per payment method |
| PayPal switched off | PayPal missing at checkout | PayPal active | Inactive | A settings check, every 15 minutes |
| Webhook endpoint failing | Nothing, until the parcel does not come | Nearly every order paid within minutes | Orders pile up as unpaid | Unpaid orders older than 30 minutes |
| No delivery rates for the UK | "Unable to calculate shipping rates" | UK checkouts reach payment | UK checkouts stop at delivery | Checkouts stuck at delivery, per country |
| Consent banner update | Nothing | GA4 sees about 85% of orders | GA4 sees 41% | Daily ratio of GA4 purchases to shop orders |
| Feed upload failing | Old prices in adverts, then no adverts | Feed file under 26 hours old | Days old | Age of the last successful upload |
| Stock sync failure | "Out of stock" everywhere | 91% of products in stock | 6% | Change in the in stock share within an hour |
Two things stand out. Only the first failure needs statistics at all. Several are better caught by checking a setting or a time stamp than by counting orders. And none of them would have moved the total number of orders enough, in the first hours, to stand out from an ordinary quiet Tuesday. That is the heart of the problem, and the next sections deal with it.
What a quiet failure costs, and why detection time is the lever
The cost of a silent failure is almost entirely set by how long it runs. The rate at which it loses orders is fixed by the fault. The contribution per order is fixed by the business. The only thing you control is time.
Here is the contribution lost in one incident, is the rate at which the failure loses orders (orders per hour), is the number of hours from the moment it starts until it is fixed, and is the contribution per order. Over a year, with incidents of this kind, the expected loss is , an expected value in the sense of Foundations: expected value.
Example: the Apple Pay incident, then four a year
The incident lost 58 orders in 72 hours, so the rate was:
Over the full hours at euro per order, using the unrounded rate:
So , or €1,301.52 for one incident. Niamh and Callum looked back over the year and assume, for the example, four incidents of this kind that are only found late, each costing the same 58 orders. That is 232 orders a year:
So about €5,206 a year. Now the same incidents found within two hours. With the loss per incident is orders, so about 6.4 orders over four incidents, or €145 a year. The alarm is worth the difference, about €5,061 a year in this one category of leak, before counting the customers who never came back after a failed checkout.
The chart is a straight line on purpose. Every hour costs the same. The question is never whether to look, only how soon.
Business alarms watch the outcome, not the machine
A business alarm is a scheduled check on business data that tells a person when a number has left its normal range. It does not ask "is the server alive?" but "are people buying the way they usually do?". Four families of signal cover almost every silent failure in a shop.
- Volume: paid orders in a window of time, against what is normal for that hour and weekday.
- Mix: the share of orders, or of failed attempts, by browser, payment method and delivery country. Mix signals catch a failure that hits one group while the total still looks plausible.
- Completion: whether things that start also finish. Orders that stay unpaid, checkouts that stop at the delivery step, webhooks that were expected and never arrived.
- Freshness and settings: time stamps and switches. When did the feed last upload? When did the stock sync last run? Is every payment method that should be active still active?
Every alarm needs four things written down before it is built: the query, the window, the threshold and the person who gets the message. An alarm without an owner is a log entry.
Example: Shannonside Home's first alarm list
After the October incident, Callum built seven alarms. Niamh gets every message on her mobile. Callum gets the same message and owns the first look.
| Alarm | Data | Window | Fires when | Runs |
|---|---|---|---|---|
| Orders below expected | spree_orders | 3 hours | Fewer orders than a 0.1% chance allows, if at least 8 were expected | Hourly |
| Payment failures by method | spree_payments | 2 hours | Failure share far above normal, at least 4 orders tried | Every 15 minutes |
| Browser mix | spree_orders, browser column | Since the last release | Safari share far below 48% | Hourly |
| Unpaid orders | spree_orders | Rolling | 3 or more orders complete for 30 minutes and still not paid | Every 15 minutes |
| Stuck at delivery | Incomplete orders by country | 24 hours | At least 5 checkouts reached delivery, none reached payment | Hourly |
| Payment methods active | spree_payment_methods | Now | A method on the list is inactive | Every 15 minutes |
| Freshness | Feed and stock sync time stamps, GA4 ratio | Daily and hourly | Feed older than 26 hours, in stock share down 20 points, GA4 below 70% of orders | Hourly, GA4 daily |
Seven alarms, all on data the shop already has. The rest of this chapter shows how the thresholds are set and how the job is written.
What "expected" means: a baseline for every hour of the week
Before an alarm can say "too few", it needs to know how many is normal. A shop has a strong rhythm. Shannonside Home sells almost nothing at 3am and most in the evening between 7pm and 10pm. Weekdays differ from weekends. A fixed threshold such as "alarm below two orders an hour" would ring every night and stay quiet in the evening even when half the orders are missing. This regular pattern is called seasonality, and it is covered in Foundations: seasonality and in depth in the article on forecasting demand with autocorrelation and seasonality.
The simplest honest baseline for an alarm is the average of the same window, on the same weekday, over the last few weeks:
Here is the expected number of orders in window (for example, Tuesday 7pm to 10pm), is the number of past weeks used, and is the number of orders in the same window weeks ago. It is a plain mean (Foundations: mean). Two rules keep it honest. Leave out weeks that were not normal, such as a big promotion or a past incident, or the baseline learns the failure. And count in local time, not in the time the database stores.
The second rule caught Callum out. Rails stores times in the database in Coordinated Universal Time (UTC) by default4. In Ireland, as across the EU, the clocks go back one hour at 1am UTC on the last Sunday in October5, in 2026 on Sunday 25 October. A baseline counted in UTC therefore compares 7pm this week with 8pm on the Tuesdays before the change, and expects the evening peak an hour too early.
Example: the Tuesday evening baseline
Callum counts Shannonside Home's orders between 7pm and 10pm, Irish time, on the eight Tuesdays before 27 October: 16, 19, 18, 15, 20, 17, 18 and 17.
So : Shannonside Home expects 17.5 orders on a Tuesday evening between 7pm and 10pm. The same calculation for 3am to 4am gives 0.2. Over a whole weekday the hours add up to the shop's usual 66 orders.
In Rails, counting the same window on past weeks is short, and Active Support takes care of the clock change, because subtracting weeks from a time in a named zone moves the calendar date and keeps the local time6.
# app/models/order_baseline.rb
# Expected completed orders in the window ending at window_end,
# from the same weekday and time in the previous weeks (Irish local time).
class OrderBaseline
def self.expected(window_end:, hours: 3, weeks: 8, skip_dates: [])
counts = (1..weeks).filter_map do |k|
to = window_end - k.weeks # keeps 10pm as 10pm across the clock change
next if skip_dates.include?(to.to_date)
Spree::Order.complete.where(completed_at: (to - hours.hours)...to).count
end
return nil if counts.empty?
counts.sum.to_f / counts.size
end
end
# With config.time_zone = "Dublin" in config/application.rb:
# OrderBaseline.expected(window_end: Time.zone.parse("2026-10-27 22:00"))
# => 17.5
Spree::Order.complete is Solidus's own scope for orders with a completion time2. The skip_dates list is where Callum puts promotion days and past incidents, so the baseline does not learn them.
How unusual is unusual? The Poisson band
Knowing that 17.5 orders are expected does not yet tell you whether 12 is a problem. Orders arrive one at a time and independently of each other, more or less, so the count in a window naturally wobbles. The classic model for such counts is the Poisson distribution, which describes "the number of events occurring within a given time interval"7. Its useful property is that one number, the expected count, fixes the whole spread. The article on Poisson regression goes further with it, and Foundations: distributions introduces it from scratch.
The probability of seeing or fewer orders when are expected is:
Here is the number of orders that actually arrive in the window, is the number you observed, is the expected number from the baseline, is Euler's number (about 2.718) and is the factorial of (). The sum adds up the chances of exactly 0, 1, 2 and so on up to orders. If that total chance is tiny, the low count is unlikely to be bad luck (Foundations: probability).
Example: when is a quiet Tuesday evening too quiet?
With for Tuesday 7pm to 10pm, Callum works out the chance of each low count. The first term, for zero orders, is , and each further term is the one before multiplied by . Adding them up:
| Orders observed (k) | Chance of k or fewer, P(X ≤ k) |
|---|---|
| 4 | 0.012% |
| 5 | 0.047% |
| 6 | 0.147% |
| 7 | 0.397% |
| 10 | 3.9% |
He sets the threshold at 0.1%. Five orders or fewer in that window fires the alarm, six does not. Twelve orders, the number the shop actually took that evening during the Apple Pay failure, has a chance of about 11.2% and does not come close. That is the uncomfortable truth of the October incident: losing a third of Safari's orders does not make a Tuesday evening look abnormal in total.
Two more cases show why the window size matters. For a single evening hour with , the chance of zero orders is , already close to the threshold. For 3am to 4am, with , the chance of zero orders is . Zero orders at 3am is the normal state of affairs and must never ring a mobile.
Alarms that do not cry wolf
An alarm that rings too often is worse than none, because people learn to ignore it, and then it is ignored on the day it matters. Google's guide to alerting names four qualities to balance: precision (the share of alerts that were real), recall (the share of real problems that raised an alert), detection time and reset time (how long an alert keeps firing after the fix)8. It also warns that low traffic services are hard, because a single failure can look like a large rate8. Almost every small shop is a low traffic service in that sense.
The arithmetic of false alarms is simple. If an alarm checks times and each check has a probability of firing by chance, the expected number of false alarms is:
Here is the expected number of false alarms in a period, is the number of checks in that period and is the chance that one check fires although nothing is wrong (Foundations: expected value). Three habits keep small: only judge windows where enough orders are expected, set low, and test the rule on history before it goes live.
There is a catch with the Poisson model. Real orders vary more than it predicts, because of weather, newsletters, a mention on the radio. Statisticians call this overdispersion. The model then underestimates how often a quiet window happens by chance, and the alarm rings more than suggests. The honest fix is the backtest: run the rule over the last few months of real history and count what it would have done.
Example: Callum's backtest over twelve weeks
Callum takes the 12 weeks up to Sunday 8 November and asks each candidate rule how often it would have fired. On paper, the "any hour with zero orders" rule fires about 5.3 times a day, because nights are full of empty hours. His three hour rule only judges windows with at least eight expected orders. On a weekday that is 14 windows, from 8am to 11am through to 9pm to midnight, so over 12 weeks:
With each check firing at most 0.1% of the time by chance, at most false alarms are expected, and because counts are whole numbers the true figure on paper is about 0.5. The history contained two real problems: a two hour checkout outage after a database change on Tuesday 15 September, and the Apple Pay failure.
| Rule | Alarms in 12 weeks | Real problems caught |
|---|---|---|
| Any hour with zero orders | 437 | 1 of 2 |
| Fewer than half the usual orders for the hour | 598 | 1 of 2 |
| Three hours, at least 8 expected, below 0.1%, counted in UTC | 3 | 1 of 2 |
| The same, counted in Irish local time | 1 | 1 of 2 |
| Payment failure share by method, counted per order | 1 | 1 of 2 |
| The last two together | 2 | 2 of 2 |
The first two rules would have sent hundreds of messages for two real problems. Within a week Niamh would have muted them, and fair play to her. The UTC version fired twice in the week after the clock change, both false. In local time the volume rule fired once, for the real outage, and missed the Apple Pay failure, because the total never dropped far enough. Only the mix rule caught that one. Together they have perfect precision and perfect recall on this history, which is as good as a backtest gets and better than real life will be. Callum writes down the result and repeats the backtest every quarter.
Segment alarms: browser, payment method and country
A failure that hits one group of customers hides inside the total. The fix is to watch the group itself. For a group with few orders, counting orders is too slow, as the Tuesday evening showed. The faster signal is the share: of the people who tried Apple Pay, how many failed? Of today's orders, how many came from Safari?
A share is a count out of a known number of tries, and the right model for it is the binomial distribution9. The chance of seeing or more failures among attempts, when the usual failure share is , is:
Here is the number of failures, is the number of orders where the method was tried, is the number that failed, is the normal failure share from history, and is the number of ways to choose of the orders (Foundations: distributions). A small result means the failures are unlikely to be bad luck.
One detail matters more than the maths: count per order, not per attempt. A customer whose card is blocked may tap the button five times. Counted per attempt, one unlucky person looks like a broken payment method. In Callum's first version that is exactly what produced a false alarm on a Saturday afternoon.
Example: the alarm that would have fired at 7.45pm
Over the previous eight weeks, 4 in 100 orders that tried Apple Pay at Shannonside Home saw the attempt fail, for ordinary reasons such as a cancelled payment sheet or a declined card. So . Callum replays 27 October against the new rule, which checks every 15 minutes, needs at least four orders that tried the method in the last two hours, and fires below 0.1%.
The release went out at 6.10pm. By 7.45pm, four customers had tried Apple Pay and all four had failed. With and the sum has a single term:
That is , or 0.000256%, far below 0.1%. The alarm would have fired at 7.45pm, one hour and 35 minutes after the release. For comparison, two failures out of four on an ordinary evening give:
That is , or 0.91%, above the threshold, so normal bad luck stays quiet.
The browser mix alarm would also have fired, but much later. It counts all orders since the release and compares the Safari share with the usual 48%. By Wednesday 9pm, 57 orders had come in and only 15 were from Safari, where about 27 would be normal. The chance of 15 or fewer is about 0.07%, so it would have fired about 27 hours after the release. That is still far better than month end, but the payment signal was faster because it watches the step that broke.
The chart makes the point visually. Each block alone looks like a quiet patch. Only the steady run below the line, or the failure share at the payment step, reveals the fault.
Where the browser and payment method come from
The payment method is already in Solidus: every payment row in spree_payments has a payment_method_id and a state, and a payment that fails during processing moves to the state failed10. In the example, Apple Pay is set up as its own payment method in the admin, so its attempts are easy to count. Whether your integration writes a row for every failed attempt depends on how it was built, so check that first with a test order that fails on purpose.
The browser is not stored by Solidus. Callum adds one small column and fills it when the checkout completes.
# db/migrate/20261102090000_add_browser_family_to_spree_orders.rb
class AddBrowserFamilyToSpreeOrders < ActiveRecord::Migration[8.0]
def change
add_column :spree_orders, :browser_family, :string
end
end
# app/models/browser_family.rb
# Reduces the User-Agent header to a broad family. The full string is not stored.
module BrowserFamily
def self.from(user_agent)
ua = user_agent.to_s
return "edge" if ua.include?("Edg/")
return "firefox" if ua.include?("Firefox/") || ua.include?("FxiOS/")
return "chrome" if ua.include?("Chrome/") || ua.include?("CriOS/")
return "safari" if ua.include?("Safari/")
"other"
end
end
# In the controller that completes the checkout (its name depends on your front end):
# current_order.update_column(:browser_family, BrowserFamily.from(request.user_agent))
The order of the checks matters, because Chrome's browser string also contains the word Safari, and Edge's contains Chrome. A unit test with one real string per browser pins that down.
The query for the payment alarm then reads like the question it answers.
-- PostgreSQL: orders that tried each payment method in the last two hours,
-- and how many of them saw every attempt fail
WITH tried AS (
SELECT p.order_id,
p.payment_method_id,
bool_and(p.state IN ('failed', 'invalid')) AS all_failed
FROM spree_payments p
WHERE p.created_at >= now() AT TIME ZONE 'UTC' - interval '2 hours'
GROUP BY p.order_id, p.payment_method_id
)
SELECT m.name,
count(*) AS orders_tried,
count(*) FILTER (WHERE all_failed) AS orders_failed
FROM tried t
JOIN spree_payment_methods m ON m.id = t.payment_method_id
GROUP BY m.name
ORDER BY orders_failed DESC;
created_at is stored in UTC without a zone, which is why the query converts now() to UTC before subtracting two hours. At 7.45pm on 27 October it would have returned one line that matters:
| name | orders_tried | orders_failed |
|---|---|---|
| Apple Pay | 4 | 4 |
| Card | 5 | 0 |
| PayPal | 2 | 0 |
Money the shop never heard about: webhooks and unpaid orders
Many payment methods confirm a payment after the customer has left the page: a redirect to a bank, a buy now pay later approval, an extra security check. The provider then tells the shop with a webhook. If the shop's webhook endpoint starts rejecting those messages, for example after a secret key was changed in one place but not the other, the money arrives at the provider and the shop never finds out.
The providers do retry, which buys time but also hides the problem. Stripe retries failed webhook deliveries in live mode for up to three days with an exponential back off, and after that a missed event can be resent by hand from the dashboard for 15 days or from the command line for 30 days11. PayPal retries up to 25 times over three days and then marks the delivery as failed12. Three days is long enough for a warehouse to skip every affected parcel and for the "where is my order" emails to start, the cost the chapter on order emails counts at €5.25 per contact.
The alarm signal is the completion of the payment. In Solidus, an order's payment_state is paid when the payments cover the total, balance_due while they do not, and failed when the latest payment has failed10. In a healthy shop, almost no completed order stays at balance_due for long.
Example: a webhook secret that changed
Suppose, as an invented scenario, that a weekday release at 10am rotates the webhook signing secret in the shop but not at the provider. From then on, every confirmation is rejected. Shannonside Home normally has zero, at most one, completed orders that are still unpaid after 30 minutes. Callum's rule fires at three.
-- PostgreSQL: completed orders still waiting for their payment after 30 minutes
SELECT number, completed_at, payment_state, total
FROM spree_orders
WHERE completed_at IS NOT NULL
AND completed_at <= now() AT TIME ZONE 'UTC' - interval '30 minutes'
AND completed_at >= now() AT TIME ZONE 'UTC' - interval '24 hours'
AND payment_state = 'balance_due'
AND state = 'complete'
ORDER BY completed_at;
Between 10am and 11am the shop expects about 3.4 orders. If a third of all orders use a method confirmed by webhook (an assumption for this example), that is a little over one such order an hour, so the third unpaid order arrives at about 12.40pm, and with the 30 minute wait the alarm fires a little after 1pm. Without it, the first sign would be a customer email two or three days later, after the provider had stopped retrying. Whether this signal fits your shop depends on how your payment integration completes orders, so confirm it with a test order before relying on it.
When the data stops: settings, feeds, stock and tracking
Some silent failures are not about orders at all. They are about a setting that changed or a job that stopped. For these, statistics is the wrong tool. A direct check on the setting or the time stamp is faster, simpler and never cries wolf.
- Payment methods: keep a list of the methods that should be live and check every 15 minutes that each one is
activeand available to customers inspree_payment_methods13. - Feed: store the time of the last successful upload to Merchant Center and alarm when it is older than your schedule plus a margin. The article on Google Shopping and the product feed covers what goes into the feed.
- Stock: the share of products with stock on hand changes slowly in a normal hour. A sudden fall means a bad sync, not a run on the shop. In Solidus, stock lives in
spree_stock_items.count_on_hand, and an item counts as in stock when that number is above zero or it can be backordered14. - Shipping by country: watch for checkouts that reach the delivery step for a country and never get further.
- Tracking: once a day, compare the purchases GA4 records in its BigQuery export with the orders in the shop. The article on reconciling analytics, ads and orders explains why they never match exactly. What matters for the alarm is a sudden change in the ratio.
Example: three failures caught by a time stamp or a ratio
Shannonside Home's stock sync reads the warehouse file every hour. Normally 1,274 of its 1,400 products are in stock, 91%. Suppose the warehouse sends a file with an empty quantity column one morning. After the sync, 84 products are in stock, 6%. The rule "in stock share down more than 20 points since the last run" fires at once. Without it, the first sign would be an evening of almost no orders that the volume alarm would only catch hours later, while every visitor saw "out of stock".
For the UK, about 2.5 orders a day, counting orders is far too slow: even three days without a UK order has a chance of , which only crosses the threshold on the third day. The stuck checkout rule is quicker. If at least five checkouts with a UK address reach the delivery step within 24 hours and none reaches payment, the rate table is broken. Normally about half of them go on to pay.
For tracking, GA4 usually records about 85% of the shop's purchases, because some customers decline consent and some block scripts. After an update to the consent banner, the ratio for one day comes in at 41%: 27 purchases in GA4 against 66 orders. The rule "below 70%" fires the next morning, when the daily export lands. Before anyone touches the banner, the question is whether customers decline more often, which is their right and not a fault, or whether consenting customers are no longer measured. The article on event tracking and consent mode explains how to tell the two apart.
Building it on Rails: one schedule, a few checks, one message
Rails 8 introduced Solid Queue, a background job queue that lives in the database and replaces the need for Redis and a separate job framework15. It can run recurring tasks from a file, config/recurring.yml, with schedules written like cron16. That is all a shop needs to run its alarms.
# config/recurring.yml
production:
order_volume_alarm:
class: OrderVolumeAlarmJob
schedule: "0 * * * *" # every hour, on the hour
payment_alarms:
class: PaymentAlarmJob
schedule: "*/15 * * * *" # every 15 minutes
The maths fits in one small module. It uses no library, so a test can pin every number from this chapter.
# app/models/alarm_math.rb
module AlarmMath
module_function
# Chance of k or fewer events when mean events are expected (Poisson)
def poisson_at_most(k, mean)
term = Math.exp(-mean)
total = term
(1..k).each do |i|
term *= mean / i
total += term
end
total
end
# Chance of k or more failures among n tries when the usual share is p (binomial)
def binomial_at_least(k, n, p)
(k..n).sum { |i| choose(n, i) * p**i * (1 - p)**(n - i) }
end
def choose(n, k)
(1..k).reduce(1) { |acc, i| acc * (n - k + i) / i }
end
end
Because Callum works test first, the tests came before the module, and they are the worked examples from this chapter.
# spec/models/alarm_math_spec.rb
RSpec.describe AlarmMath do
it "flags five orders on a Tuesday evening that expects 17.5" do
expect(AlarmMath.poisson_at_most(5, 17.5)).to be_within(0.00001).of(0.00047)
end
it "does not flag six" do
expect(AlarmMath.poisson_at_most(6, 17.5)).to be > 0.001
end
it "flags four failed Apple Pay orders out of four" do
expect(AlarmMath.binomial_at_least(4, 4, 0.04)).to be_within(1e-9).of(0.00000256)
end
end
The volume job then joins the baseline, the maths and the message.
# app/jobs/order_volume_alarm_job.rb
class OrderVolumeAlarmJob < ApplicationJob
THRESHOLD = 0.001
MIN_EXPECTED = 8
def perform(now: Time.zone.now)
window_end = now.beginning_of_hour
expected = OrderBaseline.expected(window_end: window_end, hours: 3,
skip_dates: AlarmExclusion.dates)
return if expected.nil? || expected < MIN_EXPECTED
actual = Spree::Order.complete.where(completed_at: (window_end - 3.hours)...window_end).count
chance = AlarmMath.poisson_at_most(actual, expected)
return if chance >= THRESHOLD
OwnerAlarm.raise!(
key: "order_volume",
text: "Orders #{(window_end - 3.hours).strftime('%-l%P')} to #{window_end.strftime('%-l%P')}: " \
"#{actual}, usually #{expected.round(1)}. Chance of this by luck: #{(chance * 100).round(3)}%."
)
end
end
AlarmExclusion is a small table of dates to leave out of the baseline. The message goes through one class, so every alarm reaches the same people the same way, and the same alarm is not repeated for two hours. That pause is the reset time from the alerting guide: long enough not to nag during the fix, short enough to remind if nothing happens.
# app/models/owner_alarm.rb
require "net/http"
class OwnerAlarm
QUIET_FOR = 2.hours
def self.raise!(key:, text:)
cache_key = "owner_alarm/#{key}"
return if Rails.cache.exist?(cache_key)
Rails.cache.write(cache_key, true, expires_in: QUIET_FOR)
AlarmMailer.with(text: text).alarm.deliver_later
url = ENV["ALARM_WEBHOOK_URL"]
return if url.blank?
Net::HTTP.post(URI(url), { text: text }.to_json, "Content-Type" => "application/json")
end
end
The webhook address comes from an environment variable, never from the code. A chat tool such as Slack accepts exactly this shape of message, a JSON body with a text field, posted to an incoming webhook address17. Any service that turns a webhook into a push notification on a mobile works the same way.
Three more pieces make the setup trustworthy.
- Watch the watcher. If the scheduler stops, every alarm stops with it, silently. A heartbeat closes the gap: the job pings an external cron monitoring service at the end of each run, and that service alerts when the ping does not arrive.
- Mark every release. An alarm that fires an hour after a release almost always points at the release. A release register, as described in the article on evidencing compliance with release registers, gives the time of every deploy, and the alarm message can include "last release: 6.10pm, 1 hour 35 minutes ago".
- Test the paths in more than one browser before release. Playwright runs the same test in Chromium, Firefox and WebKit, the engine behind Safari18. It cannot complete a real Apple Pay payment, which needs a real device and wallet, so it does not replace the alarm. But it catches the larger family of checkouts that break in one browser engine. The guide to TDD and BDD in Ruby on Rails shows how such tests fit into the work.
Example: the message Niamh would have received
On 27 October at 7.45pm, both mobiles would have shown this, from the payment alarm:
Apple Pay: 4 of 4 orders failed in the last 2 hours, usually 4 in 100. Chance of this by luck: 0.000256%. Last release: 6.10pm, 1 hour 35 minutes ago.
Every part of it answers a question before it is asked. Which method. How bad. How unusual. What changed. Nothing in it names a customer.
When the alarm fires: what to check first
An alarm is only worth its detection time if the first minutes after it are calm and practised. The order of checks below works for almost every silent failure, because it starts with the most likely cause.
Rolling back first and investigating second is the right order when the alarm follows a release. Every hour of investigation on a live fault costs the full rate. A rollback costs a few minutes, and the cause can be found calmly afterwards.
Example: Tuesday 27 October, replayed with the alarm
At 7.45pm the alarm arrives. Callum opens the shop on his iPhone, adds a mug to the basket and taps Apple Pay. It fails. The alarm message says the last release was at 6.10pm, so he rolls it back at 7.58pm. At 8.06pm he tests again and Apple Pay works. The next real Apple Pay order arrives at 8.12pm. The note for the incident log reads: Apple Pay failing after the 6.10pm release, found after 1 hour 35 minutes, fixed after 1 hour 48 minutes, about two orders lost. At the average rate of 0.806 orders an hour that is about €36 instead of €1,302.
Keep the alarm data lean
Alarms work on counts, shares and time stamps. They do not need names, email addresses or full browser strings, and they should not carry them. The General Data Protection Regulation (GDPR) says personal data must be "adequate, relevant and limited to what is necessary" for the purpose, the principle of data minimisation19. In Ireland the GDPR applies directly, alongside the Data Protection Act 201820. A message on a mobile is a copy of data that leaves the shop's systems, so the less it contains, the less can go wrong. Solidus already records the last IP address on each order; the alarms do not need it and do not use it.
This is general information and not legal advice. If you are unsure what your shop may record, the Data Protection Commission (DPC) publishes guidance for Irish businesses.
Example: what goes into Shannonside Home's alarm data
The browser_family column holds one of six words, never the full browser string. The alarm messages hold counts, shares and times. The incident log holds order numbers only where Callum needs them to repair a payment, and those stay in the shop's admin, not in the chat tool. Niamh can show any message to anyone without a second thought, which is the test Callum uses.
A check to repeat every quarter
Alarms decay. Baselines drift, new payment methods arrive, a release changes what a failed attempt looks like in the database. A short routine every quarter keeps them honest.
| Step | What to do | What good looks like |
|---|---|---|
| 1 | Read the incident log: every alarm, real or false, with its detection time | Real incidents found within two hours, false alarms at most one a month |
| 2 | Rerun the backtest over the last 12 weeks | Every real problem caught, no rule firing more than a few times |
| 3 | Fire drill: switch a test payment method off on staging and check the message arrives | The message reaches both mobiles within 15 minutes |
| 4 | Check the heartbeat service and who receives its alert | An alert arrives when the scheduler is stopped on purpose |
| 5 | Review the list of active payment methods, countries and feeds the alarms check | The list matches what the shop sells today |
| 6 | Update the exclusion dates (promotions, incidents) | The baseline only learns normal weeks |
| 7 | Count late found incidents for the quarter | Zero, against four a year before the alarms |
Example: Niamh's first quarterly check
The first check falls in February 2027. Suppose the log shows two real alarms, both found within an hour: a payment method a provider had paused pending a document, and a stock file with a broken column. There was one false alarm, on the evening of an autumn rugby international, and Callum added that date to the exclusions. The fire drill reached both mobiles in nine minutes. Under step 5 Niamh notices that a new delivery country added in January is missing from the stuck checkout alarm, and Callum adds it. Total time: 50 minutes. Late found incidents: none.
My view
My view: for most small shops, a handful of business alarms is worth more than the next marketing test. A typical conversion experiment chases a small lift on traffic that may or may not hold. A silent failure takes a large share of one group's orders, all of them, until someone notices. In the example the alarms protect about €5,061 a year of contribution with a few hundred lines of code that run on data the shop already has, and they keep protecting it every quarter without a new campaign. I put every release through a test gate and a release register, and still I would not run a shop without these alarms, because tests check what you thought of, and silent failures are usually what nobody thought of.
Example: the comparison in Niamh's numbers
A conversion test that lifts the whole shop by 2% would add about orders a month, roughly €10,700 a year of contribution at €22.44, if the lift is real and lasts. That is worth having. But it needs traffic, weeks of testing and a result that might be zero. The alarms protect €5,061 a year from the first day, cannot be wrong in the direction of losing money, and make every later test safer, because a test that runs during a silent failure measures the failure, not the idea. Building them took Callum about three days. At €750 a day, an assumed market rate for the example, not my price, that is euro, paid back in about five months by the €5,061 a year they protect. My own prices are published on my pricing transparency page.
Conclusion
Silent failures cost a shop in proportion to the hours they run, and technical monitoring does not see them because nothing technical is broken. Business alarms close the gap. Watch volume against a baseline for each hour of the week, counted in local time. Watch the mix by payment method, browser and country, with shares counted per order, because a broken segment hides in the total. Watch whether payments, checkouts and webhooks complete. Check settings and time stamps directly instead of with statistics. Set thresholds with the Poisson and binomial models, then backtest them on your own history so they do not cry wolf.
In the example, the Apple Pay failure cost €1,302 found after three days, and would have cost about €36 found after one hour and 35 minutes. Over four such incidents a year that is €5,206 against €145. The next chapter in this series turns to a risk of a different shape: what happens when the one person who holds the passwords is gone.