Otel tail sampling is a really powerful feature that allow us to configure what tracses, log and metrics that we're going to be pushing to Application insights or other monitoring tools.
I had a go with filtering where I tried to send traces only for transactions greater than 2 secs. Soon I realized that is quite limiting and not usable because we need those for performance analysis. All we ever see is slowness in our system.
Tail sampling is a more customizable feature that allow us to configure stuff like
1. send error traces always
2. send request that has high latency times
3. high value transactions to ensure we are able to trace it
4. we can also impose sampling percentage to send over like 10% or 50%
These are the configuration that we keep on the otel collector.
processors:
tail_sampling:
decision_wait: 10s # Time to wait for all spans of a trace to arrive
num_traces: 100000 # Max number of active traces kept in memory
expected_new_traces_per_sec: 1000
policies:
# 1. Always keep traces that contain errors
- name: error-policy
type: status_code
status_code:
status_codes: [ERROR]
# 2. Always keep slow requests (e.g., latency > 500ms)
- name: latency-policy
type: latency
latency:
threshold_ms: 500
# 3. Keep traces matching custom business attributes (e.g., high-value checkouts)
- name: high-value-transactions
type: numeric_attribute
numeric_attribute:
key: transaction.amount
min_value: 10000
# 4. Fallback: Keep a small probabilistic percentage (e.g., 5%) of normal traffic
- name: probabilistic-fallback
type: probabilistic
probabilistic:
sampling_percentage: 5.0
# Sample 2% of everything else (normal, healthy traffic)
- name: healthy-traffic-fallback
type: probabilistic
probabilistic:
sampling_percentage: 2.0
Comments