-
-
Notifications
You must be signed in to change notification settings - Fork 239
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: Pass the enableProfiling configuration through to the native SDK #851
base: main
Are you sure you want to change the base?
Changes from all commits
99983b2
6f67276
66c80ee
ca04e80
45797fd
32af409
f1af6d6
9f0b06c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,16 @@ package io.sentry.samples.flutter | |
import io.flutter.embedding.android.FlutterActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.sentry.ITransaction | ||
import io.sentry.Sentry | ||
import io.sentry.SpanStatus | ||
import kotlin.concurrent.thread | ||
|
||
class MainActivity : FlutterActivity() { | ||
private val _channel = "example.flutter.sentry.io" | ||
|
||
private var transaction: ITransaction? = null | ||
|
||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
super.configureFlutterEngine(flutterEngine) | ||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, _channel).setMethodCallHandler { | ||
|
@@ -39,6 +43,12 @@ class MainActivity : FlutterActivity() { | |
"platform_exception" -> { | ||
throw RuntimeException("Catch this platform exception!") | ||
} | ||
"startProfiling" -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also exist under |
||
transaction = Sentry.startTransaction("myTransactionWithProfiling", "task") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't test this because of getsentry/sentry-java#2009 |
||
} | ||
"stopProfiling" -> { | ||
transaction?.finish(SpanStatus.OK) | ||
} | ||
else -> { | ||
result.notImplemented() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ Future<void> main() async { | |
options.reportPackages = false; | ||
options.addInAppInclude('sentry_flutter_example'); | ||
options.considerInAppFramesByDefault = false; | ||
options.enableProfiling = true; | ||
}, | ||
// Init your App. | ||
appRunner: () => runApp( | ||
|
@@ -375,6 +376,18 @@ class AndroidExample extends StatelessWidget { | |
}, | ||
child: const Text('Platform exception'), | ||
), | ||
ElevatedButton( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move under the Main widget instead of AndroidExample only |
||
onPressed: () async { | ||
await execute('startProfiling'); | ||
}, | ||
child: const Text('Start native profiling'), | ||
), | ||
ElevatedButton( | ||
onPressed: () async { | ||
await execute('stopProfiling'); | ||
}, | ||
child: const Text('Stop native profiling'), | ||
), | ||
]); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,10 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin { | |
options.enableOutOfMemoryTracking = enableOutOfMemoryTracking | ||
} | ||
|
||
if let enableProfiling = arguments["enableProfiling"] as? Bool { | ||
options.enableProfiling = enableProfiling | ||
} | ||
Comment on lines
+265
to
+267
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
if let sendClientReports = arguments["sendClientReports"] as? Bool { | ||
options.sendClientReports = sendClientReports | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,6 +171,11 @@ class SentryFlutterOptions extends SentryOptions { | |
/// [SentryFlutter.setAppStartEnd]. | ||
bool autoAppStart = true; | ||
|
||
/// Enable capturing CPU profiles alongside transactions. | ||
/// Only available on iOS and Android. This is currently a beta feature that is | ||
/// not available to all Sentry customers. | ||
Comment on lines
+174
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also write that transactions started on the Dart layer won't have profile data, but only transactions started on the Native layer (Android/iOS). |
||
bool enableProfiling = false; | ||
|
||
/// By using this, you are disabling native [Breadcrumb] tracking and instead | ||
/// you are just tracking [Breadcrumb]s which result from events available | ||
/// in the current Flutter environment. | ||
|
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.
Workaround for https://github.com/getsentry/sentry-dart/pull/851/files#r860567670