Skip to content

Conversation

@stefanosiano
Copy link
Contributor

📜 Description

init the scopes at profile finish, too, so that it sends the chunk the first time

💡 Motivation and Context

When the startOnAppStart option is used, the first chunk is started when the SDK is not enabled, so it's stored in memory.
The SDK reevaluates the scopes when the next chunk is started, and in the meantime it keeps the chunks in memory until the second chunk finishes.
This is not an issue normally, as it affects only the very first chunk when using the startProfilerOnAppStart option.
But we do it in the UI tests of our demo app, which doesn't send any chunk unless another transaction is started one minute after the app start.

💚 How did you test it?

📝 Checklist

  • 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.
  • I updated the wizard 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

@stefanosiano stefanosiano marked this pull request as ready for review May 20, 2025 15:15
@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 435.47 ms 473.76 ms 38.29 ms
Size 1.58 MiB 2.08 MiB 510.91 KiB

Previous results on branch: fix/ui-profiling-send-first

Startup times

Revision Plain With Sentry Diff
91f3055 387.56 ms 397.07 ms 9.51 ms

App size

Revision Plain With Sentry Diff
91f3055 1.58 MiB 2.08 MiB 510.90 KiB

Sentry.getCurrentScopes().getOptions().getCompositePerformanceCollector();
final @Nullable RateLimiter rateLimiter = scopes.getRateLimiter();
if (rateLimiter != null) {
rateLimiter.addRateLimitObserver(this);
Copy link
Member

Choose a reason for hiding this comment

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

can this be potentially added multiple times now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it checks for scopes == null, so it should never occur more than once

@stefanosiano stefanosiano enabled auto-merge (squash) May 29, 2025 13:47
@stefanosiano stefanosiano merged commit 096c5c0 into main May 29, 2025
33 checks passed
@stefanosiano stefanosiano deleted the fix/ui-profiling-send-first branch May 29, 2025 13:52
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.

3 participants