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

SentryFlutter Performance Monitoring not working #720

Closed
thertzelle opened this issue Jan 26, 2022 Discussed in #719 · 17 comments
Closed

SentryFlutter Performance Monitoring not working #720

thertzelle opened this issue Jan 26, 2022 Discussed in #719 · 17 comments

Comments

@thertzelle
Copy link

Discussed in #719

Originally posted by thertzelle January 26, 2022
Here is my configuration in main: (I removed my DSN)

await SentryFlutter.init(
      (options) => {
        options.debug = true,
        options.dsn =
            '',
        options.tracesSampleRate = 1.0,
        options.tracesSampler = (samplingContext) {
          return 1;
        }
      },
      appRunner: () => runApp(App()),
    );

But when I run my app, I get the following message:

Sentry - debug:: No tracesSampleRate and tracesSampler set. Will not start SentryPerformanceTrackingIntegration.

I tried to look everywhere to see if I needed something else enabled, but the documentation doesnt say anything additional...

If I run the project in XCode and add some debugging lines inside of the - (void)setTracesSampleRate:(NSNumber *)tracesSampleRate function, tracesSampleRate is being set as null. So either I'm setting it wrong, or something is overring it.

Using sentry_flutter: ^6.2.2 in my pubspec, I'll keep tracing it down to see if I can find whats happening, but seems like a bug?

@ueman
Copy link
Collaborator

ueman commented Jan 26, 2022

It should be enough to just set the tracesSampleRate to 1. Maybe setting both is not supported, as they're two different ways to archive the same goal.

@thertzelle
Copy link
Author

I've tried setting them both separately and at the same time with no positive results. The are set in my example because the error message says "No tracesSampleRate and tracesSampler set", so that was my last effort before i came here.

@kuhnroyal
Copy link
Contributor

Do you have a DSN set in your actual code? I ran across some odd messages when I configured sampling but no DSN.

@thertzelle
Copy link
Author

Yes of course, I'm getting error reports, but unable to enable tracing.

@kuhnroyal
Copy link
Contributor

Hmm, the sampling is currently just on the Dart side I believe. I don't think it is being set into the native SDK, maybe the log is from there as well. We probably need a new integration for that.

@thertzelle
Copy link
Author

If I put a break point at static Future<void> _init(SentryOptions options, AppRunner? appRunner) async {
I can see the option is set to 1.0 ... But in the sentry admin portal, i'm not seeing any transactions come through.

@thertzelle
Copy link
Author

Hmm, the sampling is currently just on the Dart side I believe. I don't think it is being set into the native SDK, maybe the log is from there as well. We probably need a new integration for that.

Thats how I found the log item, i checked the Native SDK, and found that the value isnt getting set and throwing that error.

@thertzelle
Copy link
Author

Well I've traced down that the sample rate is getting set inside of flutter (tracesSampleRate), but there are no transactions coming through, even though I've added both manual and automatic instruments. Still seems like within Objective-C code, the value doesnt get set which results in tracing now getting enabled.

@kuhnroyal
Copy link
Contributor

That is what I said earlier, there is no support currently to set the sampling from Dart -> Native.
Maybe rename the issue and make it a feature request.

@thertzelle
Copy link
Author

So then the Flutter SDK doesnt actually support Performance tracking? I'm not saying that getting it into Native is important, i'm just trying to debug why it isnt working from Dart/Flutter. Does it not work at all from Flutter? It's documented to work in Flutter, so there is some confusion.

@kuhnroyal
Copy link
Contributor

It works fine for transactions in Dart, I am using it for database access/HTTP requests - but it does not enable native (Java/Swift) transactions to be tracked.

@ueman
Copy link
Collaborator

ueman commented Jan 27, 2022

Do you want add performance tracing only in Dart/Flutter or also on the native side?
If you want both, do you want to do performance tracing across the Dart-native-code border?

@marandaneto
Copy link
Contributor

Sentry Dart/Flutter performance only works on the Sentry/Flutter side via Dart code.
We don't enable the Performance on the Native SDKs (Android/iOS).

Users will be able to do it manually once #265 is done.

@thertzelle
Copy link
Author

Do you want add performance tracing only in Dart/Flutter or also on the native side? If you want both, do you want to do performance tracing across the Dart-native-code border?

I'm just following the SDK setup guide for Flutter. I put in my configuration as seen above, added the HTTP client for automatic collection, added some manual transactions and it doesn't work. Nothing ever appears on the admin side and I see the warning in the debug console about :

Sentry - debug:: No tracesSampleRate and tracesSampler set. Will not track slow and frozen frames.
Sentry - debug:: No tracesSampleRate and tracesSampler set. Will not track app start up time.
Sentry - debug:: No tracesSampleRate and tracesSampler set. Will not start SentryPerformanceTrackingIntegration.

But yet I have it configured to do so, which is why there is an issue:

await SentryFlutter.init(
      (options) => {
        options.debug = true,
        options.dsn =
            'https://a7d2a588f23149f89a53b30a876c45e2@o178824.ingest.sentry.io/5677471',
        options.sampleRate = 1.0,
        options.tracesSampleRate = 1.0,
      },
      appRunner: () => runApp(Skyn()),
    );

Using sentry_flutter: ^6.1.0 and podspec.lock is:

  - Sentry (7.5.4):
    - Sentry/Core (= 7.5.4)
  - Sentry/Core (7.5.4)
  - sentry_flutter (0.0.1):
    - Flutter
    - FlutterMacOS
    - Sentry (~> 7.5.1)

I've just been trying to be helpful to try to track the failure down into the native SDK ( but apparently thats not how events are tracked ), so there is some confusion on how to get this to work out of the box.

@ueman
Copy link
Collaborator

ueman commented Jan 27, 2022

The http doesn't actually do anything if you don't have a transaction which wraps it.
So you have to write code like

  final transaction = Sentry.getSpan() ??
      Sentry.startTransaction(
        'web-request',
        'request',
        bindToScope: true,
      );
  try {
    final response = await sentryHttpClient.get('url'); // probably not the correct code, but you get the idea
    transaction.spanStatus = SpanStatus.ok();
  } catch (exception, stackTrace) {
    transaction.throwable = exception;
    transaction.spanStatus = SpanStatus.internalError();
    Sentry.captureException(exception, stacktrace);
  } finally {
    await transaction.finish();
  }

@thertzelle
Copy link
Author

Yup, I also have added SentryNavigatorObserver and some manual transactions and none of them are appearing in the transactions log on sentry.

@marandaneto
Copy link
Contributor

Yup, I also have added SentryNavigatorObserver and some manual transactions and none of them are appearing in the transactions log on sentry.

Automatic instrumentation is only on https://github.com/getsentry/sentry-dart/releases 6.3.0 beta versions.
Feel free to submit a minimal reproducible example on Github with what's working and what's not working.
Also, please read the docs https://docs.sentry.io/platforms/flutter/performance/instrumentation/automatic-instrumentation/#routing-instumentation
In case you need to start your own transactions/spans, please read the custom instrumentation docs https://docs.sentry.io/platforms/flutter/performance/instrumentation/custom-instrumentation/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants