Skip to main content
Sampling allows you to control how much data is sent to Sentry, helping manage costs while maintaining visibility into your application’s health.

Error Sampling

By default, the SDK captures 100% of errors. You can control this with sampleRate:
Lowering sampleRate means you’ll miss some errors. Use this carefully and prefer filtering instead for most use cases.

Performance Sampling

Traces Sample Rate

Control the percentage of transactions sent to Sentry:
Common sample rates:
  • 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

The samplingContext 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:
Use high replaysOnErrorSampleRate (like 1.0) to ensure you always have replay context for errors, while keeping replaysSessionSampleRate low to control costs.

Profiling Sampling

Control profiling data capture:

Dynamic Profile Sampling

profilesSampleRate is relative to tracesSampleRate. If a transaction is not sampled, it won’t be profiled.

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

Begin with tracesSampleRate: 1.0 in development and staging to understand your application’s behavior. Gradually reduce rates in production based on volume.
Always capture authentication failures, payment errors, and other critical events:
Prefer tracesSampler over tracesSampleRate for production applications to handle different routes and scenarios differently.
Check Sentry’s quota usage regularly and adjust sampling rates if you’re approaching limits.
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