getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.15k stars 435 forks source link

Sentry drops transactions with large number of DB queries #2980

Open adinauer opened 1 year ago

adinauer commented 1 year ago

We use Sentry for identifying slow APIs for performance optimization. The slower APIs tend to have a larger number of DB queries which leads to the associated Sentry event being dropped for exceeding the envelope limit. Because of this we can no longer rely on Sentry to identify the slow APIs as they are never recorded on Sentry.

When the size is limit can Sentry create an event truncated to the limit or at the minimum record the top level span so that we can at least identify the slow APIs.

Originally posted by @ksmalik1 in https://github.com/getsentry/sentry-java/issues/2789#issuecomment-1756693787

adinauer commented 1 year ago

@ksmalik1 can you please give some more insights into the transactions being dropped? When you look at the serialized JSON (by enabling the debug setting), is there simply a very large number of spans or is there some fields in particular that are causing this?

adinauer commented 1 year ago

@ksmalik1 we've had a short discussion about this internally and there's no quick fix for this that would work for most users.

As a workaround please take a look at beforeSendTransaction (docs) which allows you to modify a transaction. This allows you to tailor what you drop to your own needs. I understand this is frustrating and it's something Sentry should get right out of the box. We do have some plans around changing how we ingest transactions/spans which would help here but that's not a short term change we want to rush.

Please let us know if you need help figuring out the logic for beforeSendTransaction.