Sampling¶
Sampling is the practice of discarding some traces or spans in order to reduce the amount of data that needs to be stored and analyzed. Sampling is a trade-off between cost and completeness of data.
To configure sampling for the SDK:
- Set the
trace_sample_rate
option oflogfire.configure()
to a number between 0 and 1, or - Set the
LOGFIRE_TRACE_SAMPLE_RATE
environment variable, or - Set the
trace_sample_rate
config file option.
See Configuration for more information.
import logfire
logfire.configure(trace_sample_rate=0.5)
with logfire.span("my_span"): # This span will be sampled 50% of the time
pass