getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.14k stars 432 forks source link

Add Profiles to Custom Transactions #3643

Closed thinkocapo closed 2 weeks ago

thinkocapo commented 3 weeks ago

Integration

sentry-android

Build System

Gradle

AGP Version

4.11.0

Proguard

Enabled

Version

7.14.0

Steps to Reproduce

Hi I have profiling enabled and created a Custom Transaction but there's no associated profile. demo app creates a custom transaction here and I don't see a Profile appear with it (trace) by default, and we have Profiling enabled.

Documentation mentions how to add spans, connect errors and do other things with Custom Instrumentation but no mention on profiling. Is it possible?

https://docs.sentry.io/platforms/android/tracing/instrumentation/custom-instrumentation/ Image

Customer I'm working with is going to do this for their iOS app too.

Documentation Request https://github.com/getsentry/sentry-docs

Solution Idea

A good solution would not involve having to do something like profile.start() and then set it on scope of the transaction/span object. It'd be nice to have it recording...as soon as you start the new transaction/span.

  1. start a custom transaction [docs say transaction, not span]
  2. profile starts being recorded (assuming they have SDK Profiling enabled)
  3. end the custom transaction and this ends the profile

Expected Result

Custom Transaction with a Profile

Actual Result

Custom Transaction with no Profile

kahest commented 3 weeks ago

Just noting that this should work ootb and we're analysing if/why this might not work as expected in these cases.

markushi commented 2 weeks ago

Let's give this a quick test, but by using a profiler callback this should work fine.

markushi commented 2 weeks ago

As discussed internally: You can use profilesSampler to control which transactions get profiled and which not, more details are on our docs page.

Closing this for now, @thinkocapo please let us know if there's still an issue and we'll re-open!