Why Sampling
Some of the main reasons to sample data include:- Reduce total data volume. A representative sample of your data will be much smaller than the entire volume of data produced.
- Ensure you sample interesting traces. The question of representativeness can be nuanced if you have a wide variety of traffic, especially if it is irregular.
- Filter out noise. A small sample can capture the behavior of services with predictable traffic patterns.
When to Sample
You should consider sampling if:- Your services generate 1000 or more traces per second
- A lot of your trace data represents healthy traffic and is fairly uniform
- You have conditions you can use to identify data that is relevant to you
When to Use Head Sampling
Head sampling is a blunt instrument. It is simple to configure and requires no additional infrastructure or operational overhead. But what head sampling offers in simplicity, it loses in flexibility:- You cannot sample traces based on errors they contain or their overall latency
- You cannot sample traces based on attributes on different spans in a trace
- You cannot dynamically adjust your sampling rate based on traffic to a service
When to Use Tail Sampling
Tail sampling with Refinery lets you sample traces in just about any way you can imagine. How you configure tail sampling depends on your needs and the complexity of your system. Most people tend to follow some common patterns:- Configure several rules to use a high or low sampling rate for well-known conditions, like keeping all errors in traces and dropping most health checks
- Configure a dynamic sampler based on a low-cardinality key like
http.status_codeto sample traces proportionally across all values of that key