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,152 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 £4,608; found within two hours, about £128.

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: Priya finds a hole at month end

The example for the whole series is Wrenfield Home, an online homeware shop in Leeds (wrenfieldhome.example). Priya 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 £72, and keeps a contribution of £19.86 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 fine. On Friday 30 October, while Priya 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 £19.86 each, that is £1,151.88 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 Wrenfield Home's monitoring reported between Tuesday 6.10pm and Friday 6.10pm, set against what was really happening.

ToolWhat it watchedWhat it reported
Uptime checkHome page and checkout page answer100% up
Error trackerUnhandled exceptions in the codeNo new errors, because the checkout handled the provider's rejection on purpose
Server metricsMemory, processor, response timeNormal, slightly quieter than usual
The order tablePaid orders140 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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. A consent banner update cuts tracking. Orders keep coming, but analytics and the ad platforms stop seeing them, and the bidding goes astray.
  6. 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.
  7. 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 Wrenfield Home's numbers

To see which signal catches which failure, Callum wrote down what each one would look like in Wrenfield 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 Ireland, 91% of products in stock, and GA4 seeing about 85% of the shop's purchases because of consent and blockers.

FailureWhat the customer seesNormal valueDuring the failureSignal that catches it
Apple Pay broken after a release"Please try another way to pay"4 in 100 Apple Pay attempts failAll failFailure share per payment method
PayPal switched offPayPal missing at checkoutPayPal activeInactiveA settings check, every 15 minutes
Webhook endpoint failingNothing, until the parcel does not comeNearly every order paid within minutesOrders pile up as unpaidUnpaid orders older than 30 minutes
No delivery rates for Ireland"Unable to calculate shipping rates"Irish checkouts reach paymentIrish checkouts stop at deliveryCheckouts stuck at delivery, per country
Consent banner updateNothingGA4 sees about 85% of ordersGA4 sees 41%Daily ratio of GA4 purchases to shop orders
Feed upload failingOld prices in adverts, then no advertsFeed file under 26 hours oldDays oldAge of the last successful upload
Stock sync failure"Out of stock" everywhere91% of products in stock6%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.

L=r×t×cL = r \times t \times c

Here LL is the contribution lost in one incident, rr is the rate at which the failure loses orders (orders per hour), tt is the number of hours from the moment it starts until it is fixed, and cc is the contribution per order. Over a year, with nn incidents of this kind, the expected loss is n×Ln \times L, 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:

r=5872=0.806 orders per hourr = \frac{58}{72} = 0.806 \text{ orders per hour}

Over the full t=72t = 72 hours at c=19.86c = 19.86 pounds per order, using the unrounded rate:

L=5872×72×19.86=1,151.88L = \frac{58}{72} \times 72 \times 19.86 = 1{,}151.88

So L=1,151.88L = 1{,}151.88, or £1,151.88 for one incident. Priya 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:

4×58×19.86=4,607.524 \times 58 \times 19.86 = 4{,}607.52

So about £4,608 a year. Now the same incidents found within two hours. With t=2t = 2 the loss per incident is 0.806×2=1.60.806 \times 2 = 1.6 orders, so about 6.4 orders over four incidents, or £128 a year. The alarm is worth the difference, about £4,480 a year in this one category of leak, before counting the customers who never came back after a failed checkout.

Example figures for Wrenfield Home, losing 0.806 orders an hour at £19.86 contribution per order. Found after 2 hours the incident costs about £32, after 12 hours £192, after one day £384, after three days £1,152, after one week £2,688 and after two weeks £5,375. Tap or click to open full screen and move around

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: Wrenfield Home's first alarm list

After the October incident, Callum built seven alarms. Priya gets every message on her phone. Callum gets the same message and owns the first look.

AlarmDataWindowFires whenRuns
Orders below expectedspree_orders3 hoursFewer orders than a 0.1% chance allows, if at least 8 were expectedHourly
Payment failures by methodspree_payments2 hoursFailure share far above normal, at least 4 orders triedEvery 15 minutes
Browser mixspree_orders, browser columnSince the last releaseSafari share far below 48%Hourly
Unpaid ordersspree_ordersRolling3 or more orders complete for 30 minutes and still not paidEvery 15 minutes
Stuck at deliveryIncomplete orders by country24 hoursAt least 5 checkouts reached delivery, none reached paymentHourly
Payment methods activespree_payment_methodsNowA method on the list is inactiveEvery 15 minutes
FreshnessFeed and stock sync time stamps, GA4 ratioDaily and hourlyFeed older than 26 hours, in stock share down 20 points, GA4 below 70% of ordersHourly, 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. Wrenfield 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:

λw=1K∑k=1Kxw,k\lambda_{w} = \frac{1}{K} \sum_{k=1}^{K} x_{w,k}

Here λw\lambda_{w} is the expected number of orders in window ww (for example, Tuesday 7pm to 10pm), KK is the number of past weeks used, and xw,kx_{w,k} is the number of orders in the same window kk 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 the UK the clocks went back one hour at 2am on Sunday 25 October 20265. 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 Wrenfield Home's orders between 7pm and 10pm, UK time, on the eight Tuesdays before 27 October: 16, 19, 18, 15, 20, 17, 18 and 17.

λ=16+19+18+15+20+17+18+178=1408=17.5\lambda = \frac{16 + 19 + 18 + 15 + 20 + 17 + 18 + 17}{8} = \frac{140}{8} = 17.5

So λ=17.5\lambda = 17.5: Wrenfield 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.

Example figures for Wrenfield Home, the average orders in each hour of a weekday, UK time. Nights are close to zero, from 0.2 to 1.0 orders an hour. Daytime runs from 2.5 to 3.9 orders an hour. The evening peak is 5.8 at 7pm, 6.2 at 8pm and 5.6 at 9pm. The hours add up to 66 orders a day. Tap or click to open full screen and move around

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 (UK 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 = "London" 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 kk or fewer orders when λ\lambda are expected is:

P(X≤k)=∑i=0ke−λλii!P(X \le k) = \sum_{i=0}^{k} \frac{e^{-\lambda} \lambda^{i}}{i!}

Here XX is the number of orders that actually arrive in the window, kk is the number you observed, λ\lambda is the expected number from the baseline, ee is Euler's number (about 2.718) and i!i! is the factorial of ii (3!=3×2×13! = 3 \times 2 \times 1). The sum adds up the chances of exactly 0, 1, 2 and so on up to kk 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 λ=17.5\lambda = 17.5 for Tuesday 7pm to 10pm, Callum works out the chance of each low count. The first term, for zero orders, is e−17.5=0.000000025e^{-17.5} = 0.000000025, and each further term is the one before multiplied by λ/i\lambda / i. Adding them up:

Orders observed (k)Chance of k or fewer, P(X ≤ k)
40.012%
50.047%
60.147%
70.397%
103.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 λ=5.8\lambda = 5.8, the chance of zero orders is e−5.8=0.30%e^{-5.8} = 0.30\%, already close to the threshold. For 3am to 4am, with λ=0.2\lambda = 0.2, the chance of zero orders is e−0.2=81.9%e^{-0.2} = 81.9\%. Zero orders at 3am is the normal state of affairs and must never ring a phone.

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 NN times and each check has a probability pp of firing by chance, the expected number of false alarms is:

F=N×pF = N \times p

Here FF is the expected number of false alarms in a period, NN is the number of checks in that period and pp is the chance that one check fires although nothing is wrong (Foundations: expected value). Three habits keep FF small: only judge windows where enough orders are expected, set pp 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 N×pN \times p 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:

N=14×84=1,176N = 14 \times 84 = 1{,}176

With each check firing at most 0.1% of the time by chance, at most 1,176×0.001=1.21{,}176 \times 0.001 = 1.2 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.

RuleAlarms in 12 weeksReal problems caught
Any hour with zero orders4371 of 2
Fewer than half the usual orders for the hour5981 of 2
Three hours, at least 8 expected, below 0.1%, counted in UTC31 of 2
The same, counted in UK local time11 of 2
Payment failure share by method, counted per order11 of 2
The last two together22 of 2

The first two rules would have sent hundreds of messages for two real problems. Within a week Priya would have muted them. 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 kk or more failures among nn attempts, when the usual failure share is pp, is:

P(X≥k)=∑i=kn(ni)pi(1−p)n−iP(X \ge k) = \sum_{i=k}^{n} \binom{n}{i} p^{i} (1-p)^{n-i}

Here XX is the number of failures, nn is the number of orders where the method was tried, kk is the number that failed, pp is the normal failure share from history, and (ni)\binom{n}{i} is the number of ways to choose ii of the nn 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 Wrenfield Home saw the attempt fail, for ordinary reasons such as a cancelled payment sheet or a declined card. So p=0.04p = 0.04. 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 n=4n = 4 and k=4k = 4 the sum has a single term:

P(X≥4)=(44)×0.044×0.960=0.00000256P(X \ge 4) = \binom{4}{4} \times 0.04^{4} \times 0.96^{0} = 0.00000256

That is 0.000002560.00000256, 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:

P(X≥2)=1−0.964−4×0.04×0.963=0.0091P(X \ge 2) = 1 - 0.96^{4} - 4 \times 0.04 \times 0.96^{3} = 0.0091

That is 0.00910.0091, 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.

Example figures for Wrenfield Home from Tuesday 27 October 6pm to Friday 30 October 6pm, in three hour blocks. The expected Safari orders run from 0.3 at night to 7.8 in the evening, 95 in total. Actual Safari orders ran from 0 to 3 per block, 37 in total. The 98% range is wide, from 0 to 2 at the bottom, so no single block falls clearly outside it, which is why counting Safari orders alone would not have raised an alarm quickly. Tap or click to open full screen and move around

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:

nameorders_triedorders_failed
Apple Pay44
Card50
PayPal20

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 £4.50 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. Wrenfield 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 active and available to customers in spree_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

Wrenfield 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 Ireland, about 2.5 orders a day, counting orders is far too slow: even three days without an Irish order has a chance of e−7.5=0.055%e^{-7.5} = 0.055\%, which only crosses the threshold on the third day. The stuck checkout rule is quicker. If at least five checkouts with an Irish 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 phone 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 Priya would have received

On 27 October at 7.45pm, both phones 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.

Tap or click to open full screen and move around

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 £32 instead of £1,152.

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 data protection principle of data minimisation says personal data must be "adequate, relevant and limited to what is necessary" for the purpose19. A message on a phone 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 Information Commission (formerly the Information Commissioner's Office, ICO) publishes guidance for UK businesses.

Example: what goes into Wrenfield 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. Priya 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.

StepWhat to doWhat good looks like
1Read the incident log: every alarm, real or false, with its detection timeReal incidents found within two hours, false alarms at most one a month
2Rerun the backtest over the last 12 weeksEvery real problem caught, no rule firing more than a few times
3Fire drill: switch a test payment method off on staging and check the message arrivesThe message reaches both phones within 15 minutes
4Check the heartbeat service and who receives its alertAn alert arrives when the scheduler is stopped on purpose
5Review the list of active payment methods, countries and feeds the alarms checkThe list matches what the shop sells today
6Update the exclusion dates (promotions, incidents)The baseline only learns normal weeks
7Count late found incidents for the quarterZero, against four a year before the alarms

Example: Priya'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 an evening with a big football match, and Callum added that date to the exclusions. The fire drill reached both phones in nine minutes. Under step 5 Priya 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 £4,480 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 Priya's numbers

A conversion test that lifts the whole shop by 2% would add about 1,980×0.02=39.61{,}980 \times 0.02 = 39.6 orders a month, roughly £9,400 a year of contribution at £19.86, 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 £4,480 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 £650 a day, an assumed market rate for the example, not my price, that is 3×650=1,9503 \times 650 = 1{,}950 pounds, paid back in about five months by the £4,480 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,152 found after three days, and would have cost about £32 found after one hour and 35 minutes. Over four such incidents a year that is £4,608 against £128. 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.

Want to know which silent failures your shop would not notice today? Book the free workshop and we will map the alarms your shop needs together, and the first two weeks of work are on me.

Sources

  1. 1.

    Rob Ewaschuk, edited by Betsy Beyer, "Monitoring Distributed Systems", in Site Reliability Engineering, Google and O'Reilly Media, 2016, https://sre.google/sre-book/monitoring-distributed-systems/

  2. 2.

    Solidus, core/app/models/spree/order.rb (the complete scope and ensure_available_shipping_rates) and core/config/locales/en.yml (the message items_cannot_be_shipped), release v4.8.1, 5 November 2026, https://github.com/solidusio/solidus/blob/v4.8.1/core/app/models/spree/order.rb

  3. 3.

    Google Merchant Center Help, "Expiry date [expiration_date]", Google, https://support.google.com/merchants/answer/6324499?hl=en-GB

  4. 4.

    Ruby on Rails Guides, "Configuring Rails Applications", section config.active_record.default_timezone, https://guides.rubyonrails.org/configuring.html

  5. 5.

    GOV.UK, "When do the clocks change?", https://www.gov.uk/when-do-the-clocks-change

  6. 6.

    Ruby on Rails API, ActiveSupport::Duration ("accurate date and time measurements using Date#advance and Time#advance"), https://api.rubyonrails.org/classes/ActiveSupport/Duration.html

  7. 7.

    NIST/SEMATECH Engineering Statistics Handbook, section 1.3.6.6.19, "Poisson Distribution", National Institute of Standards and Technology, https://www.itl.nist.gov/div898/handbook/eda/section3/eda366j.htm

  8. 8.

    Steven Thurgood and others, "Alerting on SLOs", in The Site Reliability Workbook, Google and O'Reilly Media, 2018, sections on precision, recall, detection time and reset time, and on low traffic services, https://sre.google/workbook/alerting-on-slos/

  9. 9.

    NIST/SEMATECH Engineering Statistics Handbook, section 1.3.6.6.18, "Binomial Distribution", National Institute of Standards and Technology, https://www.itl.nist.gov/div898/handbook/eda/section3/eda366i.htm

  10. 10.

    Solidus, core/app/models/spree/order_updater.rb (payment states paid, balance_due, failed) and core/app/models/spree/core/state_machines/payment.rb (payment state failed), release v4.8.1, 5 November 2026, https://github.com/solidusio/solidus/blob/v4.8.1/core/app/models/spree/order_updater.rb

  11. 11.

    Stripe Documentation, "Receive Stripe events in your webhook endpoint", section Automatic retries and Manual retries, Stripe, https://docs.stripe.com/webhooks

  12. 12.

    PayPal Developer, "Webhooks", PayPal, https://developer.paypal.com/api/rest/webhooks/

  13. 13.

    Solidus, core/app/models/spree/payment_method.rb (scopes active and available_to_users), release v4.8.1, 5 November 2026, https://github.com/solidusio/solidus/blob/v4.8.1/core/app/models/spree/payment_method.rb

  14. 14.

    Solidus, core/app/models/spree/stock_item.rb (in_stock? and available?), release v4.8.1, 5 November 2026, https://github.com/solidusio/solidus/blob/v4.8.1/core/app/models/spree/stock_item.rb

  15. 15.

    David Heinemeier Hansson, "Rails 8.0: No PaaS Required", Ruby on Rails blog, 7 November 2024, https://rubyonrails.org/2024/11/7/rails-8-no-paas-required

  16. 16.

    Rails, Solid Queue README, section Recurring tasks, GitHub, https://github.com/rails/solid_queue

  17. 17.

    Slack Developer Docs, "Sending messages using incoming webhooks", Slack, https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks

  18. 18.

    Playwright Documentation, "Browsers", Microsoft, https://playwright.dev/docs/browsers

  19. 19.

    UK GDPR, Article 5(1)(c), legislation.gov.uk, https://www.legislation.gov.uk/eur/2016/679/article/5