Error Sampling
By default, the SDK captures 100% of errors. You can control this withsampleRate:
Performance Sampling
Traces Sample Rate
Control the percentage of transactions sent to Sentry:- Development:
1.0(100%) - Staging:
0.5(50%) - Production (low traffic):
0.25(25%) - Production (high traffic):
0.05-0.1(5-10%)
Dynamic Sampling with tracesSampler
Implement custom sampling logic based on transaction context:
Sampling Context
ThesamplingContext object contains information about the transaction:
Session Replay Sampling
Session-Based Sampling
Capture a percentage of all sessions:Error-Based Sampling
Capture replays when errors occur:Profiling Sampling
Control profiling data capture:Dynamic Profile Sampling
Environment-Based Sampling
Adjust sampling based on your environment:Advanced Sampling Strategies
User-Based Sampling
Sample based on user attributes:Route-Based Sampling
Time-Based Sampling
Adjust sampling during peak hours:Random Sampling with Consistency
Ensure consistent sampling for the same user/session:Node.js Sampling
For Node.js applications, sampling works the same way:Verifying Sampling
Check if a transaction was sampled:Best Practices
Start with high rates, then reduce
Start with high rates, then reduce
Begin with
tracesSampleRate: 1.0 in development and staging to understand your application’s behavior. Gradually reduce rates in production based on volume.Never sample security-critical events
Never sample security-critical events
Always capture authentication failures, payment errors, and other critical events:
Use dynamic sampling for flexibility
Use dynamic sampling for flexibility
Prefer
tracesSampler over tracesSampleRate for production applications to handle different routes and scenarios differently.Monitor your quota usage
Monitor your quota usage
Check Sentry’s quota usage regularly and adjust sampling rates if you’re approaching limits.
Consider distributed tracing
Consider distributed tracing
When using distributed tracing, respect parent sampling decisions:
Common Patterns
Production-Ready Configuration
Next Steps
Filtering Events
Filter events before sending to Sentry
Performance Best Practices
Optimize performance monitoring