-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Startup Profiling 2 - Add options and sampling logic #3121
Startup Profiling 2 - Add options and sampling logic #3121
Conversation
added SentryOptions.enableStartupProfiling
added startupProfilingConfigFile deletion and creation on init added sampling decision on SDK init with isForNextStartup flag set to true added SentryOptions.getCacheDirPathWithoutDsn for startupProfiling config file
…to feat/startup-profiling2-add-options # Conflicts: # sentry/src/main/java/io/sentry/SentryOptions.java # sentry/src/test/java/io/sentry/SentryOptionsTest.kt # sentry/src/test/java/io/sentry/SentryTest.kt
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e42754c | 382.06 ms | 465.49 ms | 83.43 ms |
604628a | 389.84 ms | 456.78 ms | 66.94 ms |
1da0e4d | 375.46 ms | 448.53 ms | 73.07 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e42754c | 1.72 MiB | 2.27 MiB | 557.10 KiB |
604628a | 1.72 MiB | 2.27 MiB | 558.57 KiB |
1da0e4d | 1.72 MiB | 2.27 MiB | 558.36 KiB |
|
||
final class SentryStartupProfilingOptions implements JsonUnknown, JsonSerializable { | ||
|
||
boolean profileSampled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these be final?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, as these are read and deserialized from json (L100)
sampleStartupProfiling(options); | ||
final @NotNull SentryStartupProfilingOptions startupProfilingOptions = | ||
new SentryStartupProfilingOptions(options, startupSamplingDecision); | ||
try (Writer fileWriter = new SentryFileWriter(startupProfilingConfigFile)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try (Writer fileWriter = new SentryFileWriter(startupProfilingConfigFile)) { | |
try (Writer fileWriter = new FileWriter(startupProfilingConfigFile)) { |
SentryFileWriter is specific for performance instrumentation, I guess we don't want to create spans for our own file operations :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, let's use FileOutputStream maybe, to align with all other places where we write to a file?
CHANGELOG.md
Outdated
@@ -6,6 +6,7 @@ | |||
|
|||
- Handle `monitor`/`check_in` in client reports and rate limiter ([#3096](https://github.com/getsentry/sentry-java/pull/3096)) | |||
- Startup profiling 1 - Decouple Profiler from Transaction ([#3101](https://github.com/getsentry/sentry-java/pull/3101)) | |||
- Startup profiling 2 - Add options and sampling logic ([#3121](https://github.com/getsentry/sentry-java/pull/3121)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the other PR, maybe let's squash these changelogs into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few points, but LGTM otherwise
used FileOutputStream instead for FileWriter
* first activity transaction now inherits startup sampling decision, if available * if a startup profiler was instantiated, it will be reused in AndroidOptionsInitializer, instead of creating a new one * added ITransactionProfiler.isRunning * startup profiler and sampling decision is stored in AppStartMetrics * startup profile is bound to the startup transaction * added io.sentry.profiling.enable-startup manifest option * moved profilingTracesHz from SentryAndroidOptions to SentryOptions * added startup profiling launch in SentryPerformanceProvider * added isStartupTransaction to TransactionOptions
02f6aa7
into
feat/early-profiling1-decouple-profiler-transaction
* Startup Profiling 1 - Decouple Profiler from Transaction (#3101) * removed the need of a transaction to start a profile in AndroidTransactionProfiler, allowing to bind one later * added a constructor to AndroidTransactionProfiler without options * added options as param to AndroidTransactionProfiler.onTransactionFinish * Startup Profiling 2 - Add options and sampling logic (#3121) * added TransactionContext.isForNextStartup * added SentryOptions.enableStartupProfiling * added SentryStartupProfilingOptions class with Json ser/deser * added startupProfilingConfigFile deletion and creation on init * added sampling decision on SDK init with isForNextStartup flag set to true * added SentryOptions.getCacheDirPathWithoutDsn for startupProfiling config file * Startup Profiling 3 - Add ContentProvider and start profile (#3128) * first activity transaction now inherits startup sampling decision, if available * if a startup profiler was instantiated, it will be reused in AndroidOptionsInitializer, instead of creating a new one * added ITransactionProfiler.isRunning * startup profiler and sampling decision is stored in AppStartMetrics * startup profile is bound to the startup transaction * added io.sentry.profiling.enable-startup manifest option * moved profilingTracesHz from SentryAndroidOptions to SentryOptions * added startup profiling launch in SentryPerformanceProvider * added isStartupTransaction to TransactionOptions
📜 Description
followup of #3101
added SentryStartupProfilingOptions class with Json ser/deser
added startupProfilingConfigFile deletion and creation on init
added sampling decision on SDK init with isForNextStartup flag set to true
added SentryOptions.getCacheDirPathWithoutDsn for startupProfiling config file
Here is the decision tree.
The only missing part is actually starting the profiler and bind it to the first transaction, which will come in the next PR.
Note: the auto instrumentation flag is available on
SentryAndroidOptions
, so it will be evaluated (in the next PR) before starting the startup profiler💡 Motivation and Context
For the startup profiling feature, we need to add an option to enable it and we also need to respect the sampling decisions of the user.
Then, we need to save this info to disk, as the startup profiler will not have access to the
SentryOptions
object, as it will start before the SDK is initialized.💚 How did you test it?
Unit tests
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps