Bird
0
0

Which is the correct way to configure traces_sample_rate in sentry_sdk.init()?

hard📝 Best Practice Q15 of 15
Django - Deployment and Production
You want to monitor both errors and performance in your Django app using Sentry, but only want to sample 20% of transactions to reduce data volume. Which is the correct way to configure traces_sample_rate in sentry_sdk.init()?
Atraces_sample_rate=0.2
Btraces_sample_rate=20
Ctraces_sample_rate='20%'
Dtraces_sample_rate=True
Step-by-Step Solution
Solution:
  1. Step 1: Understand traces_sample_rate meaning

    It expects a float between 0.0 and 1.0 representing the fraction of transactions to sample.
  2. Step 2: Match options to correct format

    0.2 means 20%, 20 or '20%' are invalid types, True is boolean not a fraction.
  3. Final Answer:

    traces_sample_rate=0.2 -> Option A
  4. Quick Check:

    Fraction 0.2 = 20% sampling [OK]
Quick Trick: Use decimal fraction for sampling rate [OK]
Common Mistakes:
MISTAKES
  • Using integer or string instead of float
  • Setting traces_sample_rate > 1
  • Using boolean True instead of number

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes