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

feat(profiling): Add support for Profiling #479

Merged
merged 12 commits into from
Jul 1, 2022

Conversation

viglia
Copy link
Contributor

@viglia viglia commented Jun 27, 2022

This PR adds support for the profiling feature.

For this first iteration we will stick to the design implementation of the mobile profilers (Android/iOS) with one profile being linked to one transaction.

  • adds enable_profiling option to enable/disable profiling
  • adds profiles_sample_rate option to further sample profiles with respect to the transactions. This is dependent on traces_sample_rate and the probability of a profile being collected is: traces_sample_rate * profiles_sample_rate
  • only one profile at a time can be collected. If the profiler is running, no other profiles will be collected when other transactions start

@viglia viglia self-assigned this Jun 27, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2022

Codecov Report

Merging #479 (112f6eb) into master (7062d8d) will decrease coverage by 1.72%.
The diff coverage is 12.27%.

❗ Current head 112f6eb differs from pull request most recent head b51befa. Consider uploading reports for the commit b51befa to get more accurate results

@@            Coverage Diff             @@
##           master     #479      +/-   ##
==========================================
- Coverage   81.23%   79.51%   -1.73%     
==========================================
  Files          74       76       +2     
  Lines        8846     9054     +208     
==========================================
+ Hits         7186     7199      +13     
- Misses       1660     1855     +195     

@viglia viglia marked this pull request as ready for review June 28, 2022 08:41
@viglia viglia requested review from Swatinem and jan-auer June 28, 2022 08:41
Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

This looks promising. I scattered some suggestions around. Essentially I would love this to move into its own module, and have a fn start_profiling() -> Option<ProfileGuard>, and maybe a fn stop_profiling(ProfileGuard) -> Profile (the envelope item) as the two functions that you call from the performance module.

sentry-types/src/protocol/profile.rs Outdated Show resolved Hide resolved
sentry-types/src/protocol/profile.rs Show resolved Hide resolved
sentry-types/src/protocol/profile.rs Outdated Show resolved Hide resolved
sentry-types/src/protocol/envelope.rs Outdated Show resolved Hide resolved
sentry-core/src/performance.rs Outdated Show resolved Hide resolved
sentry-core/src/performance.rs Outdated Show resolved Hide resolved
sentry-core/src/performance.rs Show resolved Hide resolved
sentry-core/Cargo.toml Outdated Show resolved Hide resolved
sentry-core/src/performance.rs Outdated Show resolved Hide resolved
sentry-core/Cargo.toml Outdated Show resolved Hide resolved
* refactor into a profiling.rs module
* remove lazy_Static and mut_static
* replace mutex with AtomicBool
* remove profiling feature from test
})
.collect();

samples.push(Sample {
Copy link
Member

Choose a reason for hiding this comment

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

You can also use a rep.data.keys().map(…).collect() instead of the Vec::new + push.

@viglia viglia merged commit 029c29f into master Jul 1, 2022
@viglia viglia deleted the viglia/feature/add-profiling-support branch July 1, 2022 06:31
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