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 cpu usage collection #2462

Merged
merged 20 commits into from
Jan 23, 2023
Merged

Add cpu usage collection #2462

merged 20 commits into from
Jan 23, 2023

Conversation

stefanosiano
Copy link
Member

@stefanosiano stefanosiano commented Jan 10, 2023

📜 Description

added ICpuCollector to collect cpu usage info while transactions are running
TransactionPerformanceCollector now returns PerformanceCollectionData, which contains both memory and cpu usage data

💡 Motivation and Context

We want to track a time series of cpu percentage usage while a transaction runs, to provide more info to the user.

💚 How did you test it?

Unit tests

📝 Checklist

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

🔮 Next steps

…running

TransactionPerformanceCollector now returns PerformanceCollectionData, which contains memory and cpu usage data
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2023

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 427809b

@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 314.65 ms 332.09 ms 17.43 ms
Size 1.73 MiB 2.33 MiB 622.36 KiB

Previous results on branch: feat/cpu-usage-collection

Startup times

Revision Plain With Sentry Diff
0ab0a9d 297.22 ms 316.27 ms 19.05 ms
cdfd579 291.23 ms 343.10 ms 51.87 ms
5d33fcf 338.68 ms 376.60 ms 37.92 ms
1c5e2af 294.08 ms 355.10 ms 61.02 ms
82b794b 334.81 ms 382.72 ms 47.91 ms
c3caa7d 407.24 ms 421.16 ms 13.92 ms
0ceda44 337.69 ms 355.46 ms 17.77 ms
20ea300 308.26 ms 366.81 ms 58.55 ms
cdc5f35 366.06 ms 404.48 ms 38.42 ms
0d15e40 346.22 ms 383.28 ms 37.06 ms

App size

Revision Plain With Sentry Diff
0ab0a9d 1.73 MiB 2.33 MiB 618.94 KiB
cdfd579 1.73 MiB 2.33 MiB 618.94 KiB
5d33fcf 1.73 MiB 2.33 MiB 621.01 KiB
1c5e2af 1.73 MiB 2.33 MiB 620.95 KiB
82b794b 1.73 MiB 2.33 MiB 621.15 KiB
c3caa7d 1.73 MiB 2.33 MiB 621.00 KiB
0ceda44 1.73 MiB 2.33 MiB 622.12 KiB
20ea300 1.73 MiB 2.33 MiB 618.94 KiB
cdc5f35 1.73 MiB 2.33 MiB 621.55 KiB
0d15e40 1.73 MiB 2.33 MiB 621.01 KiB

@stefanosiano stefanosiano marked this pull request as ready for review January 10, 2023 17:02
# Conflicts:
#	CHANGELOG.md
#	sentry/src/main/java/io/sentry/TransactionPerformanceCollector.java
@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 80.08% // Head: 80.12% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (427809b) compared to base (897ad85).
Patch coverage: 92.18% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2462      +/-   ##
============================================
+ Coverage     80.08%   80.12%   +0.03%     
- Complexity     3904     3913       +9     
============================================
  Files           320      321       +1     
  Lines         14751    14779      +28     
  Branches       1950     1950              
============================================
+ Hits          11813    11841      +28     
- Misses         2168     2170       +2     
+ Partials        770      768       -2     
Impacted Files Coverage Δ
...try/src/main/java/io/sentry/CpuCollectionData.java 66.66% <66.66%> (ø)
.../src/main/java/io/sentry/MemoryCollectionData.java 70.00% <75.00%> (ø)
...ava/io/sentry/TransactionPerformanceCollector.java 94.00% <90.47%> (+4.20%) ⬆️
...y/src/main/java/io/sentry/JavaMemoryCollector.java 100.00% <100.00%> (ø)
...main/java/io/sentry/PerformanceCollectionData.java 100.00% <100.00%> (ø)
sentry/src/main/java/io/sentry/Sentry.java 55.73% <100.00%> (ø)
sentry/src/main/java/io/sentry/SentryOptions.java 79.32% <100.00%> (-0.05%) ⬇️

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@stefanosiano stefanosiano marked this pull request as draft January 17, 2023 11:20
# Conflicts:
#	CHANGELOG.md
#	sentry/src/main/java/io/sentry/TransactionPerformanceCollector.java
@stefanosiano stefanosiano marked this pull request as ready for review January 18, 2023 12:44
@@ -162,7 +162,10 @@ static void initializeIntegrationsAndProcessors(
options.setGestureTargetLocators(gestureTargetLocators);
}
options.setMainThreadChecker(AndroidMainThreadChecker.getInstance());
options.setMemoryCollector(new AndroidMemoryCollector());
if (options.getCollectors().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

l: just a thought - since this a list, should we just add to it no matter what? Even if the users added their own collectors, we could still add ours?

Not applicable for JavaMemoryCollector though, since it'd be duplicating the values of AndroidMemoryCollector kinda

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, only the last added Collectors would work, so we'd overwrite user's defined collectors.
Maybe we could set them as first in the list, using something like collectors.add(0, collector)
However, at the moment the collector is marked @Internal.
Should we cover this case anyway?

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

# Conflicts:
#	sentry-android-core/api/sentry-android-core.api
#	sentry/src/main/java/io/sentry/SentryOptions.java
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