-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Support the new MaterialApp.router
navigation
#827
Comments
@stx Please have a look at https://docs.sentry.io/platforms/flutter/performance/ |
Also look at https://docs.sentry.io/platforms/flutter/performance/instrumentation/automatic-instrumentation/#routing-instumentation |
@marandaneto Thanks for looking into this. Yes, I only added tracesSampler when the sampleRate also didn’t work. Correct, it’s attached to the navigatorObserver in the GoRouter package (the new Flutter Navigator has no navigatorObserver in MaterialApp.) Sentry appears to track changes correctly as routing breadcrumbs show up in error tracing. If this isn’t supported, do you know how to attach Sentry to the new Flutter navigation? You can see it at https://api.flutter.dev/flutter/material/MaterialApp/MaterialApp.router.html for reference. I’ll post the full log tomorrow. |
@stx I still see the property in there https://api.flutter.dev/flutter/material/MaterialApp/navigatorObservers.html |
I suspect that the SentryNavigatorObserver just works with GoRouter, after all it's basically a convenience layer around Flutters routing. |
@marandaneto Your link is for the old Flutter navigation - the new Flutter navigation is instantiated via https://api.flutter.dev/flutter/material/MaterialApp/MaterialApp.router.html which doesn't have navigatorObservers (they are delegated to other handlers, like GoRouter.) Here are the logs using the below configuration:
|
That looks like the logs from the native iOS Sentry SDK, which means native performance tracing isn't enabled. The Dart/Flutter performance tracing features should still work though. Have you verified that, by creating and capturing a manual performance trace? I can see how that could confuse people. I wonder if that can be improved somehow. |
@ueman Our Sentry performance views are literally empty - no transactions, no cold startup time, no warm startup time, no slow frames, no frozen frames. I assume something is supposed to show up here else I'm not sure exactly what performance monitoring is. According to these docs... https://docs.sentry.io/platforms/flutter/performance/instrumentation/automatic-instrumentation/#app-start-instrumentation I would expect at least these items to show up, since they are either enabled by default (app start/slow frames), or we've added the code as instructed in AssetBundle's case. Are we misunderstanding how this is supposed to work? We'll try a manual trace and see if that works. |
Manual performance traces work correctly via |
The integrations for AssetBundle, http and Dio just create child spans if there's a transaction bound to the scope. They don't create root transactions themselves. Just the SentryNavigatorObserver creates root transactions (transactions which are bound to the scope). As said, I assume that it works with GoRouter but haven't tried it myself. Please note, that only Routes with names are considered as there's no way to identify and differentiate between different routes if they have no name. It should be logged, though, if a route hase no name. The observer is also doing the app start and frame time thingies. Those metrics are contained within the repsective transactions initiated by the observer. The name limitation should probably be more highlighted in the docs. I'm not quite sure if that answers your question but nevertheless, I hope that it helped. |
@ueman That helps a ton! 100% of our routes have names. They use URL paths like "/settings". Seems like the root issue is that the SentryNavigatorObserver isn't recording app start/frames on GoRouter or possibly Flutter Navigation 2.0 (Router) - that explains the missing metrics and allows everything we're seeing to make perfect sense. Looking at GoRouter's code, it looks like it's passing observers directly to Navigator, so I presume the issue is not specific to this package: We also see that navigation traces are showing up in issues, so the non-performance measurements appear to be working. Is there anything else we can do to help identify the issue? |
MaterialApp.router
navigation
Ok so this is not really a bug then, it's likely the lack of support of the new API Slow and frozen frames won't work since it depends on the |
I've tested it out with the I only I've added the
SDK init as simple as:
Slow and frozen frames and App start worked out, @stx if that does not work for you, please provide a minimal reproducible example. |
@marandaneto Found the issue! Works - transaction submitted:
Doesn't work - no transaction submitted:
Fix: Change the route name to the full URL path:
After we changed this, everything started to show up! Closing as this seems to be an edge case. However, it could be super helpful to have an error/notice message in the logs if SentryNavigatorObserver() is enabled and the route is invalid (name is missing/invalid, etc.) Something like "Error: Route name invalid. Route names are required to log transactions." or something to that effect. Thanks very much for your help in narrowing this down. 🙏 |
How to put SentryNavigatorObserver() into MaterialApp.router? |
I have the same Issue, my project runs on Android and Web, I cant get to set up automated performance. Widget build(BuildContext context) => MaterialApp.router(
routeInformationProvider: _router.routeInformationProvider,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
title: title,
); final GoRouter _router = GoRouter(routes: <GoRoute>[
GoRoute(
path: '/',
pageBuilder: (BuildContext context, GoRouterState state) =>
MaterialPage<dynamic>(
name: state.fullPath,
key: state.pageKey,
child: Page1Screen())),
GoRoute(
path: '/page2',
pageBuilder: (BuildContext context, GoRouterState state) =>
MaterialPage<dynamic>(
name: state.fullPath,
key: state.pageKey,
child: Page2Screen())),
], observers: [
SentryNavigatorObserver()
]);
}
I have already tried yout previous example @marandaneto like this: @override
Widget build(BuildContext context) => MaterialApp.router(
routerConfig: _router,
title: title,
);
final GoRouter _router = GoRouter(routes: <GoRoute>[
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) =>
const Page1Screen(),
),
GoRoute(
path: '/page2',
builder: (BuildContext context, GoRouterState state) =>
const Page2Screen(),
),
], observers: [
SentryNavigatorObserver()
]);
}
Still no frozen frame, app start or any vitals, only erros and custom transactions, |
@humber-z I'll take a look and come back to you. |
@humber-z So I took a look and the latter example works as expected. Maybe there are no traces because there are no child spans or you are running on web?
|
We are using Flutter(mobile app) and also using the GoRoute package as our navigation package. await SentryFlutter.init(
(options) async {
options.dsn = !isZebraDevice && Environment.useCrashlytics
? 'https://dsn-url'
: '';
options.tracesSampleRate = 1;
options.profilesSampleRate = 0.2;
options.autoAppStart = true;
options.enableAutoSessionTracking = true;
options.enableAutoPerformanceTracing = true;
options.enableAppLifecycleBreadcrumbs = true;
options.enableAutoNativeBreadcrumbs = true;
options.enableBrightnessChangeBreadcrumbs = true;
options.enableNativeCrashHandling = true;
options.enableWatchdogTerminationTracking = true;
options.enablePrintBreadcrumbs = true;
options.attachStacktrace = true;
options.enableTracing = true;
options.environment = Environment.channel;
}, and also we set the SentryObserver like this: static final rootNode = ShellRoute(
navigatorKey: Constants.shellNavigatorKey,
builder: (context, state, child) => BaseScreen(child: child),
observers: [
SentryNavigatorObserver(),
],
routes: [
HomeRoutes.homeNode,
CategoryRoutes.categoryNode,
CartRoutes.cartNode,
ProfileRoutes.profileNode,
LoginRoutes.loginRouteNode,
],
);
} Now we expect to see at least some data in the Performance section at Sentry Dashboard, but we couldn't get any data until now. Is it possible in Sentry to just track the navigations or it is not possible? Or does SentryObserver works fine with GoRoute ? since we are already using GoogelAnalyticsObserver and it works fine with GoRoute. We are also using the last version of Sentry. |
Hi, the
Unfortunately no, if the navigation transaction has no child spans, it will be dropped. the reason is that there's no callback to identify when the screen has been loaded, so we rely on the child spans. So unless you attach child spans to the navigation transaction after the screen has been pushed Sentry won't send the transaction. This could happen manually or via auto instrumentation e.g manually: final activeSpan = Sentry.getSpan();
final childSpan = activeSpan?.startChild('complex operation',
description: 'running a complex operation');
// do work
childSpan?.finish(); If you still have an issue pls open up a separate issue for better visibility |
Also If I understand you correctly, I assume you are asking for a Time to Initial Display feature since you only want to track the navigation. |
did u get any solution? |
Platform:
IDE:
split-debug-info and obfuscate (Flutter Android or iOS) or CanvasKit (Flutter Web):
Platform installed with:
Output of the command
flutter doctor -v
below:The version of the SDK (See pubspec.lock):
6.5.0-beta.1
I have the following issue:
Performance monitoring never records any transactions for anything. Error tracking works great.
This is the exact same issue as #720.
Steps to reproduce:
In addition to the AssetBundle instrumentation installed above, and the expected automatic instrumentation like app start, we also have routing instrumentation installed via:
Actual result:
Sentry - debug:: No tracesSampleRate and tracesSampler set. Will not start SentryPerformanceTrackingIntegration.
No performance transaction is ever recorded on debug or in production.
Error tracking works great.
Expected result:
Performance tracking also works.
The text was updated successfully, but these errors were encountered: