Uh oh!
There was an error while loading. Please reload this page.
Feature: Android profiling traces - #1897
Conversation
added a transaction listener (noOp on java sdk) that starts/stops android profiling when a transaction starts or is finished added an envelope generation method from android trace file added following SentryOptions: profilingTracesDirPath, profilingEnabled, maxTraceFileSize, profilingTracesIntervalMs, transactionListener
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AndroidTraceTransactionListener now takes Hub in the constructor (for testability)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…e schedule() method ITransactionListener.onTransactionFinish() now returns a ProfilingTraceData, used to add the item to the transaction's envelope added io.sentry.traces.profiling-enable to manifest options profiling is now enabled by default
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
moved profilingTracesDirPath and profilingTracesIntervalMillis to SentryAndroidOptions updated ProfilingTraceData to be the payload of the profiling envelope item
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| private final transient @NotNull File traceFile; | ||
| // Device metadata | ||
| private final int android_api_level; |
There was a problem hiding this comment.
hm, I feel like checkstyle/spotless would yell here, because we should use camelCase
There was a problem hiding this comment.
I ran it, but it didn't care at all. If we get rid of Gson then i can create a custom method that creates a json and use camelCase names for the variables
There was a problem hiding this comment.
We got rid of Gson on Java v6 https://github.com/getsentry/sentry-java/tree/6.x.x
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
stefanosiano
commented
Mar 7, 2022
For the serialization, should i rebase this branch to the 6.x.x branch and adapt to the ser/deser used there? |
Codecov Report
@@ Coverage Diff @@## feat/profiling/android #1897 +/- ##
============================================================
- Coverage 75.46% 74.70% -0.76% - Complexity 2248 2260 +12
============================================================
Files 225 228 +3 Lines 8036 8145 +109 Branches 851 867 +16 ============================================================
+ Hits 6064 6085 +21 - Misses 1562 1646 +84 - Partials 410 414 +4
Continue to review full report at Codecov.
|
marandaneto
commented
Mar 7, 2022
I'd rather merge to the feature branch you already have. |
bruno-garcia
commented
Mar 8, 2022
+1 on merging first. Wrt 6.0 perhaps we need a bigger discussion and commitment from folks and set a timeline (making sure it doesn't negatively affect tracing's goals). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| return null; | ||
| } | ||
| // The payload of the profiling item is a json that includes the trace file encoded with base64 |
There was a problem hiding this comment.
Usually, base64 is 1/3 bigger, is there a reason to do so? Envelopes are able to send binary format.
There was a problem hiding this comment.
We agreed with @phacops, our backend guy, that will expect a base64 string.
Also, the payload of the profile envelope is a json, so a string is a natural fit
There was a problem hiding this comment.
I see, since it's a file, I was expecting to be an attachment that could be sent in bytes.
Reading the code now I understand, the envelope type is profile, which is a JSON of the ProfilingTraceData class, that contains a stacktrace field, and this field has the profiling file content in base64.
Uh oh!
There was an error while loading. Please reload this page.
…, instead of deleting the whole dir and recreating it in the main thread AndroidTransactionProfiler now takes a buildInfoProvider in ctor profile envelope item now uses a CachedItem to read the trace file in the background
…, instead of deleting the whole dir and recreating it in the main thread AndroidTransactionProfiler now takes a buildInfoProvider in ctor profile envelope item now uses a CachedItem to read the trace file in the background
-device_is_emulator -device_cpu_frequencies -device_physical_memory_bytes -duration_ns added context to AndroidTransactionProfiler instead of packageInfo to retrieve memory info added isEmulator() to BuildInfoProvider
stefanosiano
commented
Mar 10, 2022
I had to add few fields for the profiling envelope, so i made a few changes, but these should be the last one! |
-stacktrace -> sampled_profile -stacktrace_id -> profile_id
-stacktrace -> sampled_profile -stacktrace_id -> profile_id
bruno-garcia
commented
Mar 14, 2022
🥳 |
Instructions and example for changelogPlease add an entry to Example: ## Unreleased- Android profiling traces ([#1897](https://github.com/getsentry/sentry-java/pull/1897))If none of the above apply, you can opt out of this check by adding |
* Added a transaction profiler (noOp on java sdk) that starts/stops android profiling when a transaction starts or is finished * Added a new envelope item type "profile", generated using android trace file. Its payload is a json represented by ProfilingTraceData * SentryExecutorService now uses a ScheduledExecutorService to allow the schedule() method * Added "profilingTracesDirPath" and "profilingTracesIntervalMillis" to SentryAndroidOptions * Added "profilingEnabled", "maxTraceFileSize" and "transactionProfiler" to SentryOptions * Added io.sentry.traces.profiling.enable to manifest options * Profiling is disabled by default * Profiling traces directory's content is deleted in the background when the options are initialized
* Added a transaction profiler (noOp on java sdk) that starts/stops android profiling when a transaction starts or is finished * Added a new envelope item type "profile", generated using android trace file. Its payload is a json represented by ProfilingTraceData * SentryExecutorService now uses a ScheduledExecutorService to allow the schedule() method * Added "profilingTracesDirPath" and "profilingTracesIntervalMillis" to SentryAndroidOptions * Added "profilingEnabled", "maxTraceFileSize" and "transactionProfiler" to SentryOptions * Added io.sentry.traces.profiling.enable to manifest options * Profiling is disabled by default * Profiling traces directory's content is deleted in the background when the options are initialized
* Added a transaction profiler (noOp on java sdk) that starts/stops android profiling when a transaction starts or is finished * Added a new envelope item type "profile", generated using android trace file. Its payload is a json represented by ProfilingTraceData * SentryExecutorService now uses a ScheduledExecutorService to allow the schedule() method * Added "profilingTracesDirPath" and "profilingTracesIntervalMillis" to SentryAndroidOptions * Added "profilingEnabled", "maxTraceFileSize" and "transactionProfiler" to SentryOptions * Added io.sentry.traces.profiling.enable to manifest options * Profiling is disabled by default * Profiling traces directory's content is deleted in the background when the options are initialized
📜 Description
adds Android profiling whenever a transaction starts
adds a new envelope generation method to send profiling data
Bind traces to transactions
Ignore profiling for other transactions when they run at the same time
💡 Motivation and Context
We are integrating the Specto features in the Sentry sdk. This pr adds support for profiling Android methods whenever a sentry transaction is started
📝 Checklist
🔮 Next steps
Add tests (will be added in another pr)