Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically downsample transaction when system is under load (backpressure) #3072

Merged
merged 70 commits into from
Dec 15, 2023

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Dec 1, 2023

📜 Description

Automatically downsample transaction when system is under load by checking:

  • if any events have been dropped due to queue being full recently (2s)
  • if any rate limit is in effect (regardless of category)

This check is performed every 10 seconds. With each negative health check we halve tracesSampleRate up to 10 times, meaning the original tracesSampleRate is multiplied by 1, 1/2, 1/4, ... up to 1/1024 (~ 0.001%). Any positive health check resets to the original tracesSampleRate set in SentryOptions.

Also see python PRs for reference.

💡 Motivation and Context

Closes #2829

💚 How did you test it?

Unit tests, manually using Spring Boot sample.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

markushi and others added 30 commits June 29, 2023 14:14
Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
* reduced timeout of AsyncHttpTransport close to flushTimeoutMillis (default 4s in Android and 15s in Java) to avoid ANRs in Android
* Add deadline timeout for automatic transactions

* Update Changelog

* Address PR comments

* Fix formatting

* Add missing test, improve naming

* Ensure deadline timeout is only set once
* updated minimum Android SDK version to 19
* removed few workarounds for version < 19
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
Copy link
Contributor

github-actions bot commented Dec 1, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 393.41 ms 418.63 ms 25.22 ms
Size 1.72 MiB 2.27 MiB 558.11 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d6d2b2e 392.55 ms 467.50 ms 74.95 ms
99a51e2 405.11 ms 479.65 ms 74.54 ms
0bd723b 375.20 ms 452.41 ms 77.20 ms
c7e2fbc 377.85 ms 426.35 ms 48.50 ms
b172d4e 412.60 ms 492.68 ms 80.08 ms
4e29063 364.08 ms 445.51 ms 81.43 ms
bc4be3b 360.40 ms 435.04 ms 74.64 ms
93a76ca 397.30 ms 455.16 ms 57.87 ms
8fd337b 349.16 ms 459.22 ms 110.06 ms
93a76ca 377.41 ms 448.22 ms 70.81 ms

App size

Revision Plain With Sentry Diff
d6d2b2e 1.72 MiB 2.27 MiB 555.05 KiB
99a51e2 1.72 MiB 2.29 MiB 576.34 KiB
0bd723b 1.72 MiB 2.29 MiB 578.09 KiB
c7e2fbc 1.72 MiB 2.29 MiB 576.40 KiB
b172d4e 1.72 MiB 2.29 MiB 578.09 KiB
4e29063 1.72 MiB 2.29 MiB 578.38 KiB
bc4be3b 1.72 MiB 2.29 MiB 576.53 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB
8fd337b 1.72 MiB 2.27 MiB 555.00 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB

Previous results on branch: feat/backpressure

Startup times

Revision Plain With Sentry Diff
8d081e4 446.34 ms 535.84 ms 89.50 ms
9f06b6e 361.10 ms 430.00 ms 68.90 ms
95f8fd0 415.82 ms 470.54 ms 54.72 ms
3b8dee7 436.04 ms 526.52 ms 90.48 ms

App size

Revision Plain With Sentry Diff
8d081e4 1.72 MiB 2.27 MiB 556.60 KiB
9f06b6e 1.72 MiB 2.27 MiB 556.27 KiB
95f8fd0 1.72 MiB 2.27 MiB 556.38 KiB
3b8dee7 1.72 MiB 2.27 MiB 556.30 KiB

@sl0thentr0py
Copy link
Member

one thing you're missing - a new client report (DiscardReason) called backpressure and use that here

options
.getClientReportRecorder()
.recordLostEvent(DiscardReason.SAMPLE_RATE, DataCategory.Transaction);

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments on some minor things. Looks good otherwise 👍

Do we want to add the configuration also to the ExternalOptions to make this available to other integrations too?
As far as I can see, enabling backpressureHandling is currently only possible via Spring and the SentryProperties or by supplying SentryOptions in code, correct?

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor nitpick :)

@adinauer adinauer merged commit 8ff8fd0 into main Dec 15, 2023
19 checks passed
@adinauer adinauer deleted the feat/backpressure branch December 15, 2023 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Backpressure Management
8 participants