## TL;DR

Disable the SDK in one canary instance (empty DSN) and compare p99 latency and throughput against an identical instance with it on. JSON parsing, regex scans, or network calls in beforeSend/before\_send add latency to the request that errored. Lower the trace sample rate, or switch to traces\_sampler and return 0 for hot low-value routes (health checks, static assets). Make beforeSend cheap: simple field deletes, no parsing, no I/O.

## When to use

You are seeing this: Every sampled transaction builds spans in memory and ships them. Use this skill when you run into "Diagnose: Sentry SDK slowing the app down".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Where the overhead comes from

1. **Trace volume.** Every sampled transaction builds spans in memory and ships them. At high sample rates on a hot path, this is the dominant cost.
2. **beforeSend work.** Your callback runs synchronously on every event. JSON parsing, regex scans, or network calls in `beforeSend`/`before_send` add latency to the request that errored.
3. **Breadcrumb capture.** The logging integration records breadcrumbs per log call. At `max_breadcrumbs = 50` default this is cheap; with verbose framework logging it adds up.

## Measure before tuning

Disable the SDK in one canary instance (empty DSN) and compare p99 latency and throughput against an identical instance with it on. If there is no measurable difference, the SDK is not your problem; do not tune blindly.

## The knobs, in impact order

1. Lower the trace sample rate, or switch to `traces_sampler` and return 0 for hot low-value routes (health checks, static assets).
2. Make `beforeSend` cheap: simple field deletes, no parsing, no I/O. Move heavy redaction to server-side scrubbing.
3. Reduce `max_breadcrumbs` or raise noisy loggers' levels instead of capturing everything.
4. For short-lived processes, check `shutdown_timeout`: too high blocks shutdown on network trouble, too low drops events.

## Verify

Re-run the canary comparison after tuning: the gap should close to noise. Also confirm the Usage stats show the expected drop in the tuned category, so the performance fix and the quota fix arrive together.
