The Sampling Layer - Or, "We Measured It" Is Not the Same as "We Measured All of It"
A team enables tracing at one percent to keep the bill down. The dashboard is green. Then a customer reports that checkout takes eleven seconds, and the traces show forty milliseconds, because the slowest requests are the ones least likely to be in the sample - not through malice, but through arithmetic.
The sampler decides at the front door, before anyone knows how long the request will take, so the requests that become slow after the decision are the ones that get dropped. The measurement was real. It was also a sample, drawn at a point where the outcome did not exist yet, and reported as if it described the whole population.
That is the sampling layer: the part of the system your numbers structurally cannot see.
Every Number Has a Frame
"We measured it" is shorthand for "we measured a sample of it, drawn in a particular way, at a particular moment, from a particular population." The result usually survives; the frame does not.
A p99 latency, a 94% eval pass rate, a 4.6 satisfaction score, a "zero incidents this quarter" - each is a statement about a sample, and the sentence around it drops the frame because the frame is boring and the number is not.
This is not a statistics problem. Statistics has vocabulary for all of it: sampling bias, selection effects, censoring, coverage. The problem is that the vocabulary lives in a different room from the dashboard, and the dashboard is what gets read in the meeting.
The practical consequence: a number without a frame is a rumor with decimal places. It is not false. It is just answering a narrower question than the one being asked, and nobody wrote down which question that was.
Four Frames Teams Use Without Naming Them
- Time. "We sample one minute every ten." If the failure is a nightly batch that runs at 02:00, the sample may contain it four times a week or never, depending on where the minute lands. The frame is a clock, and the clock is uncorrelated with the failure until it is.
- Identity. "We only instrument the new clients." The customers on the old SDK - the ones who have been around longest, pay the most, and hit the weirdest paths - are outside the frame. Their experience is not low-scoring. It is absent, and absence reads as zero.
- Path. "We log what reaches the service." Requests that die at the CDN, the load balancer, the auth proxy, or the client never reach the logger. The failures that never arrive are exactly the ones a logger cannot count, and they are a large share of "the site is down" reports.
- Survival. "We survey customers after the renewal." The people who churned cannot answer. The score is computed over survivors, which is a real population and not the one you meant. This is the oldest bias in the book and it still ships in every NPS dashboard.
None of these frames is wrong to choose. All of them are wrong to forget.
The Decision Point Is the Bias
There are two ways to sample a request, and they produce different lies.
Head-based sampling decides at the start: keep one in a hundred, flip the coin at the front door, propagate the decision. It is cheap, it is consistent across services, and it is blind to the outcome - which is the problem. The request that will time out in nine seconds looks identical to the healthy one at the moment of the decision. You get an unbiased sample of arrivals and a biased sample of latency, and latency is usually why you turned tracing on.
Tail-based sampling buffers the whole trace and decides at the end: keep every error, keep every request over two seconds, sample the boring rest at one percent. It sees the outcome, which is exactly what you want, and it costs memory and a collector that can hold the trace long enough to judge it.
Most teams that complain "our traces don't show the slow requests" have head-based sampling and have never said the words out loud.
The general rule: sample after the thing you are trying to measure has happened, or accept that your sample is of the input, not the output. A sample taken before the outcome cannot be used to estimate the outcome's tail. It can be used to estimate arrival mix, which is a different question with a different dashboard.
In Evals, the Sample Is the Spec
An eval set is a sample of tasks, drawn by whoever wrote it, from an imagined distribution of use. The pass rate is a property of that set. It is not a property of the product, and the gap between the two is the entire field of evaluation.
Three ways the frame hides:
- The set contains what the team thought of. Failure modes nobody imagined are not in the sample, so they cannot lower the score. A model that scores 94% has passed 94% of the questions someone already knew to ask.
- The set drifts away from production. Real traffic grows new intents - a new customer segment, a new language, a new integration - while the eval set stays frozen at the shape of last year. The score stays high and becomes less relevant every month, with no event that marks the change.
- The set leaks into training. Public benchmarks are scraped, remembered, and optimized against. The score stops being a measurement of capability and becomes a measurement of exposure. This is the same failure as a test that passes because it was written after the fix: the number is real, the inference is not.
The honest artifact is not a higher score. It is a line under the score that says what the set contains, how it was drawn, when it was last refreshed against production traffic, and what fraction of real requests it resembles. A pass rate with a frame is a decision aid. Without one it is a mood.
The Sample Floor
There is a second, simpler trap: the sample is too small for the claim, and the claim is stated anyway. If you have 200 sampled events and the error rate is 0.5%, you have one error. One error is not an error rate. It is a coin flip that landed heads, and next month it will land differently and someone will write a slide about improvement.
The same arithmetic applies to a 30-person survey, a 12-incident review corpus, and a five-customer churn interview series.
The fix is not more statistics. It is a sentence: "this number is based on N events; at this rate, the uncertainty is wider than the change we are discussing." That sentence kills more bad decisions than any confidence interval, because it is short enough to say in a meeting.
What Absence Looks Like in a Dataset
The hardest part of sampling is that the excluded population does not appear as a gap. It appears as nothing, and nothing renders as zero, which renders as fine.
The customer who never got the survey is not a low score. The request that died at the CDN is not a slow trace. The failure mode nobody wrote a test for is not a failing test. The incident nobody reported is not a near-miss in the review.
In every case, the dataset is complete with respect to itself and silent about the frame, and the silence is indistinguishable from health.
This is why "we have no data on that" is a more useful sentence than most dashboards. It names the frame. It says the population exists and the sample does not cover it, which is a different and much more actionable statement than a zero.
Two Practices That Cost Almost Nothing
Oversample the tail on purpose. Keep every error, keep every request over the threshold, sample the healthy rest. The storage cost is bounded by the failure rate, and the sample becomes useful precisely where you need it. If the failure rate is high enough to blow the budget, that is the finding.
Write the frame under the number. One line: denominator, how the sample was drawn, what is structurally excluded, when it was last checked against the full population. Not in a methodology appendix - under the number, where the person reading the dashboard will see it. If the line cannot be written, the number is not ready to be a decision.
The Uncomfortable Part
Sampling is not a compromise you make because you are cheap. It is a permanent condition. Every measurement is a sample of something, and the population you care about - all requests, all customers, all failures, all futures - is never fully observed.
The question is not whether you sampled. It is whether you know what you left out and whether the conclusion respects that boundary.
A conclusion is only as wide as its sample. Everything beyond the frame is not "probably fine." It is unknown, and unknown is a legitimate answer that most dashboards are not built to display.
Friday Exercise
Take one number your team reports weekly - a latency percentile, a pass rate, a satisfaction score, an incident count. Write four lines under it:
- Denominator. What population is this a fraction of?
- Draw. How was the sample chosen, and at what point in the process?
- Absent. Who or what cannot appear in this sample, by construction?
- Floor. How many events is this based on, and is the change we are discussing larger than the noise at that N?
Then change one sampling decision - keep all errors for a week, survey the churned customers, add the twenty tasks nobody wrote - and see whether the number moves. If it moves, the old number was a frame masquerading as a fact. If it does not move, you have learned something rarer: the conclusion survives a wider sample. Either result is worth more than another green tile.
If a number your team reports weekly is really a sample - a 1% trace rate, a survey that only the survivors answered, an eval set that only contains failures you already imagined - say so in the comments. We keep a one-page frame card that records the denominator, the draw, who is structurally absent, and the sample floor (events behind the number), and I will send it over. No form, no email list.
Comments
No comments yet. Start the discussion.