Prompt
I need tail-based sampling so I keep slow errors and rare paths
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
Yes — tail-based sampling is a good fit if you want to keep:
- slow requests
- errors
- rare/unusual code paths
- representative traces for debugging
Why tail-based sampling helps
Unlike head-based sampling, tail-based sampling decides after the trace finishes, so it can use the full trace context:
- latency
- status/error flags
- route/operation name
- span attributes
- whether the trace hit uncommon paths
That lets you keep traces that are most useful and drop the rest.
Common tail-sampling policy
A practical policy is:
- Always keep errors
- Always keep slow traces
- Keep a small percentage of everything else
- Optionally keep specific rare routes/attributes
Example policy logic:
- keep if
status = ERROR - keep if
duration > 500ms - keep if
http.route in ["/checkout", "/payment"] - otherwise sample 1–5%
If you’re using OpenTelemetry Collector
Tail sampling is typically done in the OpenTelemetry Collector with the tailsamplingprocessor.
A basic example:
processors:
tailsampling:
decision_wait: 10s
num_traces: 50000
expected_new_traces_per_sec: 1000
policies:
- name: errors
type: status_code
status_code:
status_codes: [ERROR]
- name: slow-traces
type: latency
latency:
threshold_ms: 500
- name: rare-routes
type: string_attribute
string_attribute:
key: http.route
values: ["/checkout", "/payment"]
enabled_regex_matching: false
- name: probabilistic-fallback
type: probabilistic
probabilistic:
sampling_percentage: 5
Important tradeoffs
Tail sampling is powerful, but it has costs:
- more memory and CPU in the collector
- added delay before traces are exported
- you need buffering for in-flight traces
- high traffic needs careful sizing
Best practice
For your goal, I’d recommend:
- tail sampling in the collector
- always keep errors
- keep latency outliers
- keep specific rare routes or attribute-based traces
- use a low probabilistic fallback for baseline coverage
If you want, I can give you:
- a full OpenTelemetry Collector config, or
- a policy design tailored to your services and traffic.
Brands