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

Instantiate continuous profiling v8 (p3) #3725

Merged

Conversation

stefanosiano
Copy link
Member

📜 Description

added profile context to SentryTracer
removed isProfilingEnabled from AndroidContinuousProfiler, as it's useless
added continuous profiler to SentryOptions
added DefaultTransactionPerformanceCollector to AndroidContinuousProfiler and updated it to work with string ids other than transactions
fixed ProfileChunk measurements being modifiable from other code
added thread id and name to SpanContext.data

#skip-changelog

💡 Motivation and Context

Instantiate Continuous Profiler
Part 3 of #3710

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

removed isProfilingEnabled from AndroidContinuousProfiler, as it's useless
added continuous profiler to SentryOptions
…ontinuous-profiling-part3

# Conflicts:
#	sentry/src/main/java/io/sentry/SentryTracer.java
#	sentry/src/test/java/io/sentry/OutboxSenderTest.kt
…iler

updated DefaultTransactionPerformanceCollector to work with string ids other than transactions
fixed ProfileChunk measurements being modifiable from other code
added thread id and name to SpanContext.data
@stefanosiano stefanosiano changed the title Instantiate continuous profiling (p3) Instantiate continuous profiling v8 (p3) Sep 26, 2024
@stefanosiano stefanosiano changed the base branch from main to feat/continuous-profiling-part2 September 26, 2024 11:00
Copy link
Contributor

github-actions bot commented Sep 26, 2024

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

Generated by 🚫 dangerJS against 6639591

@stefanosiano stefanosiano marked this pull request as ready for review September 26, 2024 11:15
Copy link
Contributor

github-actions bot commented Sep 26, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 415.45 ms 426.16 ms 10.71 ms
Size 1.65 MiB 2.31 MiB 677.69 KiB

Baseline results on branch: feat/continuous-profiling-part2

Startup times

Revision Plain With Sentry Diff
4e27f0d 425.02 ms 452.80 ms 27.78 ms
ae2da55 448.49 ms 482.66 ms 34.17 ms

App size

Revision Plain With Sentry Diff
4e27f0d 1.65 MiB 2.31 MiB 674.06 KiB
ae2da55 1.65 MiB 2.31 MiB 674.06 KiB

@@ -86,6 +86,12 @@ public SentryTracer(
this.baggage = new Baggage(scopes.getOptions().getLogger());
}

final @NotNull SentryId continuousProfilerId =
Copy link
Member

@romtsn romtsn Nov 11, 2024

Choose a reason for hiding this comment

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

just a thought: I'd imagine this would be better living on the Scope(s), but since it's a global profiler it's probably fine.

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, but one comment about where we send profiler_id:

  • I don't know about backend implications, but why don't we make profiler_id part of the baggage/trace-header? I'd imagine it'd make sense to have it there to make sampling decisions for spans/txs etc etc, or is it already supposed to work with spans-without-sampling? Just did the same thing for replays recently, that's why I'm asking, because there it differs from this approach a little.

…rofiling-part3

# Conflicts:
#	sentry-android-core/src/main/java/io/sentry/android/core/AndroidContinuousProfiler.java
#	sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java
#	sentry-android-ndk/build.gradle.kts
#	sentry/api/sentry.api
#	sentry/src/main/java/io/sentry/Scopes.java
#	sentry/src/main/java/io/sentry/SpanContext.java
#	sentry/src/main/java/io/sentry/protocol/SentryTransaction.java
#	sentry/src/test/java/io/sentry/CheckInSerializationTest.kt
#	sentry/src/test/java/io/sentry/JsonSerializerTest.kt
#	sentry/src/test/java/io/sentry/SentryOptionsTest.kt
#	sentry/src/test/java/io/sentry/protocol/SpanContextSerializationTest.kt
@stefanosiano
Copy link
Member Author

LGTM, but one comment about where we send profiler_id:

  • I don't know about backend implications, but why don't we make profiler_id part of the baggage/trace-header? I'd imagine it'd make sense to have it there to make sampling decisions for spans/txs etc etc, or is it already supposed to work with spans-without-sampling? Just did the same thing for replays recently, that's why I'm asking, because there it differs from this approach a little.

Chunks are not bound to traces at the moment, but I agree on your thoughts.
We should probably do it at some point, and then we'll revisit this, but not now sadly

* create app start continuous profiler instead of transaction profiler, based on config
* updated SentryAppStartProfilingOptions with isContinuousProfilingEnabled flag
* updated SentryOptions with isContinuousProfilingEnabled() method
* cut profiler setup out in a specific function to improve readability of AndroidOptionsInitializer

Add new APIs for Continuous Profiling v8 (p5) (#3844)
* AndroidContinuousProfiler now retrieve the scopes on start()
* removed profilesSampleRate from sample app to enable continuous profiling
* added Sentry.startProfiler and Sentry.stopProfiler APIs
@stefanosiano stefanosiano merged commit 5ebb536 into feat/continuous-profiling-part2 Nov 14, 2024
28 of 29 checks passed
@stefanosiano stefanosiano deleted the feat/continuous-profiling-part3 branch November 14, 2024 14:56
stefanosiano added a commit that referenced this pull request Nov 14, 2024
* added profile_chunk envelope create
* added IHub.captureProfileChunk and ISentryClient.captureProfileChunk
* added profilerId and chunkId reset logic to AndroidContinuousProfiler
* added absolute timestamps to ProfileMeasurementValue
* added ProfileContext to Contexts
* removed timestampMillis from MemoryCollectionData and CpuCollectionData, now it uses timestamp.nanotime() to achieve same result
* continuous profiler doesn't stop anymore when an error occurs, but continue scheduling restart

Instantiate continuous profiling v8 (p3) (#3725)
* added profile context to SentryTracer
* removed isProfilingEnabled from AndroidContinuousProfiler, as it's useless
* added continuous profiler to SentryOptions
* added DefaultTransactionPerformanceCollector to AndroidContinuousProfiler
* updated DefaultTransactionPerformanceCollector to work with string ids other than transactions
* fixed ProfileChunk measurements being modifiable from other code
* added thread id and name to SpanContext.data
* added profiler_id to span data
* close continuous profiler on scopes close
* renamed TransactionPerformanceCollector to CompositePerformanceCollector
* added SpanContext.data ser/deser

Handle App Start Continuous Profiling v8 (p4) (#3730)
* create app start continuous profiler instead of transaction profiler, based on config
* updated SentryAppStartProfilingOptions with isContinuousProfilingEnabled flag
* updated SentryOptions with isContinuousProfilingEnabled() method
* cut profiler setup out in a specific function to improve readability of AndroidOptionsInitializer

Add new APIs for Continuous Profiling v8 (p5) (#3844)
* AndroidContinuousProfiler now retrieve the scopes on start()
* removed profilesSampleRate from sample app to enable continuous profiling
* added Sentry.startProfiler and Sentry.stopProfiler APIs
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