-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Enable tracing in the Android/iOS SDKs by default #4032
Comments
Thanks @Qonstrukt - I think I see what's going on here. It's not affecting all transactions/spans. I can do something like this in C#, for example, and the traces come through: private void OnCounterClicked(object sender, EventArgs e)
{
var transaction = SentrySdk.StartTransaction("Counter", "transaction");
Task.Delay(TimeSpan.FromMilliseconds(100)).Wait();
transaction.Finish();
} However in your case there are some traces that should be created by the Cocoa/Java SDK on ios/android, which are not being created. I'm not actually sure how you got the Cocoa/Java SDK to do that with the options that you showed above... I'd expect something like this would be required to get this to happen: #if ANDROID
options.Native.EnableUserInteractionTracing = true;
options.Native.EnableAutoActivityLifecycleTracing = true;
options.Native.EnableActivityLifecycleTracingAutoFinish = true;
#elif IOS
options.Native.EnableUserInteractionTracing = true;
options.Native.EnableAutoPerformanceTracing = true;
options.Native.EnableCoreDataTracing = true;
options.Native.EnableFileIOTracing = true;
options.Native.EnableUIViewControllerTracing = true;
#endif With those options enabled, I think the native SDKs might try to instrument spans for various events and it might fail with the error message you described. The solution is to enable tracing in the native SDKs as well: #if ANDROID || IOS
options.Native.EnableTracing = true;
#endif Explanation / Follow up actionWe removed the Until this has been removed from the Cocoa and Java SDKs, however, we should probably still set EnableTracing in these SDKs explicitly based on whatever the implicit value is in the .NET SDK. That way you wouldn't have to set this explicitly yourself (as I've suggested above). We'll put that change in place but you should be able to set it explicitly on the native options as a workaround, in the meantime. |
@bruno-garcia / @vaind it looks like maybe this was done intentionally? sentry-dotnet/src/Sentry/Platforms/Cocoa/SentrySdk.cs Lines 70 to 72 in b330e67
Do we want instrumentation that gets added by the Native SDKs to be disabled unless people enable this explicitly (and separately from enabling tracing in the managed SDK)? |
Thanks for looking into it @jamescrosswell! These options should be enabled by default right?
This actually solves my issue:
Following the documentation, this shouldn't of course be necessary, but good that I have a solution for now. 😊 |
Sorry @jamescrosswell I actually don't know much about this part. I show up in git blame just because of auto-format while saving the file https://github.com/getsentry/sentry-dotnet/pull/2930/files#diff-ae79de5791c2ea5b937c18e2af1a8af1e131f8762578c0996937795300c22445R76 Maybe consider checking how native implementations handle this config? |
Some of them are and some of them aren't: sentry-dotnet/src/Sentry/Platforms/Cocoa/SentryOptions.cs Lines 172 to 189 in b330e67
Where did you see this in the docs? Whatever we decide should be happening functionally, the docs need to match what the software is doing. |
OK thanks. I see originally the logic was added here: It guess it was just a design decision Matt made. I'll check to see what they're doing in the Flutter SDK, since they have a similar wrapper around native mobile SDKs. |
This iOS docs mention this example where only The .NET docs mention something similar: The options section explains it a bit more explicitly:
|
@Qonstrukt this topic is a bit nuanced. The setting you cite from the docs is a very high level setting that determines, from all transactions (those created by you manually or those automatically created by one of the Sentry SDKs or some third party library), what percentage should be captured and sent to Sentry. Independently of that, there are various ways to enable (or disable) automatic trace creation either by Sentry or by third party libraries. I checked how other SDKs are doing this and this was the reply:
For MAUI apps in particular, the .NET SDK doesn't yet automatically create any traces (yet - this is on the radar). So presently we could probably default to enabling tracing for the iOS SDK. Once the .NET SDK starts to collect traces itself though, we might run the same risk of double instrumentation. We can cross that bridge when we come to it though, I think. |
Package
Sentry
.NET Flavor
.NET
.NET Version
9.0.2
OS
iOS
SDK Version
5.3.0
Self-Hosted Sentry Version
No response
Steps to Reproduce
TracesSampleRate
set:Expected Result
I expect traces to be collected.
Actual Result
Traces aren't enabled,
because isTracingEnabled is disabled
apparently as the logs say:This is happening for both Android and iOS. I initialise Sentry from a shared Application class that gets called from
FinishedLaunching
on iOS and from the Application'sOnCreate
on Android.The text was updated successfully, but these errors were encountered: