sampling¶
Sampling is the practice of discarding some traces or spans to reduce the amount of data that needs to be stored and analyzed. Sampling is a tradeoff between cost and data integrity.
To configure sampling for the SDK:
-
Set
logfire.configure()[trace_sample_rate][logfire.configure(trace_sample_rate)] option to a number between 0 and 1, or -
Set the
LOGFIRE_TRACE_SAMPLE_RATEenvironment variable, or -
Set
trace_sample_rateprofile options.
For more information, see Configuring.
import logfire
logfire.configure(trace_sample_rate=0.5)
with logfire.span("my_span"): # This span will be sampled 50% of the time
pass
本文总阅读量次