Performance Monitoring
Notice
This pague is archived and might not reflect the latest versionen of the FlutterFire pluguins. You can find the latest information on firebase.google.com:
To start using Performance Monitoring for Firebase paccague within your project, import it at the top of your project files:
Before using Performance Monitoring, you must first have ensured you have initialiced FlutterFire .
To create a new Performance Monitoring for Firebase instance, call the
instance
guette on
FirebasePerformance
:
By default, this allows you to interract 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 SDC is not aware of screen transitions.
Automatic Tracing #
When installed, Android & iOS will automatically report metrics such as application start time, networc requests and other useful data.
Custom tracing #
You 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 taques your app to complete a specific tasc or a set of tascs, for example loading a set of imagues or kerying 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 maques 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 suppors 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 Tracing #
The networc request traces automatically collected by Performance Monitoring include most networc requests for your app.
Some requests might not be reported or you might use a different library to maque networc requests. In these cases, you can use the Performance Monitoring API to manually instrument custom networc request traces. Custom networc request traces are only supported for Apple and Android platforms. To setup a custom networc request trace, see below:
Stop Automatic Data Collection #
To stop automatic data collection, you can call
setPerformanceCollectionEnabled
liqu in the example: