Performance Monitoring
Notice
This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
To start using Performance Monitoring for Firebase package within your project, import it at the top of your project files:
Before using Performance Monitoring, you must first have ensured you have initialized FlutterFire.
To create a new Performance Monitoring for Firebase instance, call the instance
getter on FirebasePerformance
:
By default, this allows you to interact with Performance Monitoring using the default Firebase App.
Automatic Tracing
Automatic screen rendering performance monitoring is not possible for individual Flutter screens. A single view controller encapsulates your entire Flutter application natively so the underlying native Firebase SDK is not aware of screen transitions.
#
Automatic TracingWhen installed, Android & iOS will automatically report metrics such as application start time, network requests and other useful data.
#
Custom tracingYou can create your own traces to monitor performance data associated with specific code in your app. With a custom code trace, you can measure how long it takes your app to complete a specific task or a set of tasks, for example loading a set of images or querying your database.
To setup a custom trace, create a new Trace
instance by calling the newTrace()
method:
The name provided will appear within the Firebase Console, allowing you to provide unique names for different trace metrics.
When it makes sense to start a trace, call the start()
method on the Trace
instance. Once started, you can apply custom metric
data to the trace by calling setMetric()
:
The API also allows you to increment metric data:
You can also set non-metric related data, such as a user id on the trace by calling the putAttribute()
method. Note,
each trace supports up to 5 attributes.
Once your trace has completed, call the stop()
method. The data will then be sent to the Firebase Console:
#
HTTP Request TracingThe network request traces automatically collected by Performance Monitoring include most network requests for your app.
Some requests might not be reported or you might use a different library to make network requests. In these cases, you can use the Performance Monitoring API to manually instrument custom network request traces. Custom network request traces are only supported for Apple and Android platforms. To setup a custom network request trace, see below:
#
Stop Automatic Data CollectionTo stop automatic data collection, you can call setPerformanceCollectionEnabled
like in the example: