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

Add profiling activity to Android sample app #2192

Merged
merged 3 commits into from
Aug 5, 2022

Conversation

stefanosiano
Copy link
Member

@stefanosiano stefanosiano commented Aug 1, 2022

📜 Description

Few additions to the Android sample app:

  • Added profiling activity with size printed on screen
  • Enabled profiling
  • auto user interaction instrumentation should be disabled when testing the manual profile (creates concurrent transactions not currently supported by profiling)

💡 Motivation and Context

There was no clear way to answer the "How big is a profile?" question.
Now we can have a way to know, depending on length and number of working threads, how big is the profiling trace file, how big is the created envelope item, and how big is the actual data sent to Sentry (the item compressed with gzip).
Also, we can now feed different profiles by running the sample app and editing the dsn.
#skip-changelog

💚 How did you test it?

No way 😄

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

…background threads to get an idea of size of: profiling trace file, envelope item and compressed envelope item

enabled profiling
disabled auto user interaction instrumentation (creates concurrent transactions not currently supported by profiling)
…background threads to get an idea of size of: profiling trace file, envelope item and compressed envelope item

enabled profiling
disabled auto user interaction instrumentation (creates concurrent transactions not currently supported by profiling)
@stefanosiano stefanosiano marked this pull request as ready for review August 1, 2022 11:23
@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2022

Codecov Report

Merging #2192 (645779e) into feat/profiling-sample-rate (9e92a55) will increase coverage by 0.02%.
The diff coverage is n/a.

@@                       Coverage Diff                        @@
##             feat/profiling-sample-rate    #2192      +/-   ##
================================================================
+ Coverage                         80.88%   80.91%   +0.02%     
+ Complexity                         3347     3343       -4     
================================================================
  Files                               236      236              
  Lines                             12207    12199       -8     
  Branches                           1626     1623       -3     
================================================================
- Hits                               9874     9871       -3     
+ Misses                             1732     1729       -3     
+ Partials                            601      599       -2     
Impacted Files Coverage Δ
...y/src/main/java/io/sentry/util/SampleRateUtil.java 90.90% <0.00%> (-1.40%) ⬇️
sentry/src/main/java/io/sentry/SentryTracer.java 91.70% <0.00%> (-0.23%) ⬇️
...a/io/sentry/clientreport/ClientReportRecorder.java 74.32% <0.00%> (+6.75%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -109,7 +113,7 @@
<meta-data android:name="io.sentry.traces.activity.auto-finish.enable" android:value="false" />

<!-- how to enable the UI auto instrumentation for tracing -->
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
<!-- <meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />-->
Copy link
Contributor

@marandaneto marandaneto Aug 4, 2022

Choose a reason for hiding this comment

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

Can you elaborate on:

Disabled auto user interaction instrumentation (creates concurrent transactions not currently supported by profiling)

I don't follow, there should be a single transaction in the scope, this is like this by design, so I'm not sure what you mean by concurrent transactions.
Also, disabling another feature isn't the best idea, either when testing this feature, we manually disable and enable it again (not comiting the changes).
We can also create a new flavor that enables and disables certain features.
We can also create a new sample app for profiling as suggested before as well if needed.

Copy link
Member Author

@stefanosiano stefanosiano Aug 4, 2022

Choose a reason for hiding this comment

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

The thing is that i added an activity where i click on a button and it manually starts a transaction to be profiled.
But when i click on the button an automatic transaction is started first, so that one is profiled. When the manual transaction is started, the automatic one hasn't finished, yet, so the profiler ignores the manual transaction, since it doesn't have the notion of scope.
We're currently working on allowing profiling to work in these cases.
We can reenable the user-interaction option, disabling it when testing the profiler.
I'm not sure a new sample app just for profiling is worth it, as we can find some edge cases we didn't consider when using other options of the sdk, too.

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible this uncovered a scenario we need to address? Should the old transaction be completed (and so profiling ended) when the new starts? Or should the new transaction not start because we already have one on going. We only create ui event transactions if none exists?

Copy link
Member Author

Choose a reason for hiding this comment

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

We create it only if none exists, but by default it's automatically stopped after 3 seconds. This case is a transaction manually started in those 3 seconds.
we discussed this scenario, and we decided to make profiling work with multiple transactions here.
We should support it anyway, as this has less attrition for the user, and it's more important in the backend clients, where it's easy to have multiple concurrent transactions, possibly spawn over multiple threads.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say let's move ahead with this then and we can track this on an issue? Would you please open an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, we already created a doc
Anyway, i just created this issue and i'll track it in the new pr i'll do

@stefanosiano stefanosiano merged commit e9ceb30 into feat/profiling-sample-rate Aug 5, 2022
@stefanosiano stefanosiano deleted the samples/android-profiling branch August 5, 2022 14:09
bitsandfoxes pushed a commit that referenced this pull request Aug 31, 2022
* added profilesSampleRate and profilesSampler options
* deprecated SentryOptions.setProfilingEnabled()
* updated internal code and unit tests to change from SentryOptions.setProfilingEnabled() to SentryOptions.setProfilesSampleRate()
* Add profiling activity to Android sample app (#2192)
* added profiling activity to the sample app, with possibility to set time and number of background threads to get an idea of size of: profiling trace file, envelope item and compressed envelope item
* enabled profiling in the sample app

Co-authored-by: Bruno Garcia <[email protected]>
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.

4 participants