The first version of our pipeline sampled in the client. The SDK rolled a die, and one in N datapoints was sent. It was simple, it was cheap, and for about eighteen months it was fine.
Then a customer asked a question we could not answer: “Our p99 latency chart looks wrong during incidents — can you explain it?” We could not, because during an incident their error paths fired more often, those paths were instrumented with the same sample rate as everything else, and the tail we most needed to see was the tail we had thrown away at the source.
That is the core problem with client-side sampling: the client decides what to drop before anyone knows what matters. A sample rate chosen at deploy time cannot know that, right now, the checkout service is the interesting one.
What “at the edge” buys you
When sampling happens at the POP instead, three things change.
Decisions use context the client never has. The edge sees the whole stream for a tenant, not one process’s slice of it. It can keep 100% of a metric while it is anomalous and sample it hard when it is boring. It can keep every datapoint carrying an error label and sample the success path. The client cannot do any of this without shipping it the global picture first — which defeats the point.
One place to change the rules. Changing a client-side sample rate means a redeploy of every service, or at least a config push the SDK has to pick up. We had customers running six-month-old sample rates because nobody wanted to touch a stable binary. At the edge, a sampling rule is a config change that takes effect at the next datapoint, fleet-wide.
Cardinality is controllable. The thing that actually blows up observability bills is not raw volume, it is unique series — cardinality. A label like user_id turns one series into a million. The edge can enforce a budget per metric name: when a label explodes, aggregate or drop the offending dimension and flag it. A client cannot, because it only sees its own handful of series and has no idea it is one of ten thousand processes all adding to the same name.
The cost we took on
None of this is free. Sampling at the edge means we have to accept the full stream before we reduce it, so we pay for ingress and for the compute to make the decision. That is real money, and it is money the client-side approach avoids by never sending the data at all.
We decided it was worth it, because the alternative is lying to people about their own systems. A datapoint dropped at the edge was at least considered. A datapoint dropped in the client was gone before any decision worth the name could be made.
# a pipeline rule: keep all errors, sample the happy path to 10%
sampling:
- match: { label: "status", op: "ne", value: "2xx" }
keep: 1.0
- match: { metric: "http_request_duration_seconds" }
keep: 0.1
There is a tidy general lesson here, and we keep relearning it: reduce data as late as you responsibly can, where you have the most context, not as early as you cheaply can. The edge is the latest point that is still cheap enough. So that is where we sample.