-
Notifications
You must be signed in to change notification settings - Fork 16
N.2 Init Performance
You can initialize the Performance ANE by calling Perf.init();
As soon as you initialized the firebasePerformance.ane in your project, you will be able to create custom traces for monitoring your app's performance
Notice: Before initializing Performance, you must have already successfuly initialized the FirebaseCore.
You can monitor if the Performance ANE is monitoring your app or not by seting the Perf.collectionEnabled property to true or false.
- After initializing the Performance ANE and making sure that Performance collection is enabled, build your app.
- Test your app using either:
- An Android emulator with a recent image and Google Play services 15.0.0 or later
- A test device with Google Play services 15.0.0 or later.
- Confirm that Performance Monitoring results display in the Firebase console.
A custom trace is a report of performance data associated with some of the code in your app. To learn more about custom traces, see the Performance Monitoring overview.
You can have multiple custom traces in your app, and it's possible to have more than one custom trace running at a time. Each custom trace can have one or more metrics to count performance-related events in your app, and those metrics are associated with the traces that create them.
Note that names for custom traces and metrics must meet the following requirements: no leading or trailing whitespace, no leading underscore (_
) character, and max length is 32 characters.
To start and stop a custom trace, wrap the code that you want to trace with lines of code similar to the following (this example uses a custom trace name of test_trace
):
import com.myflashlab.air.extensions.firebase.performance.*;
var myTrace:PerfTrace = Perf.newTrace("test_trace");
myTrace.start();
// code that you want to trace
myTrace.stop();
To add a custom metric, add lines of code similar to the following each time that the event occurs. For example, this custom metric counts performance-related events that occur in your app, such as cache hits and misses (using example event names of item_cache_hit
and item_cache_miss
and an increment of 1
).
var myTrace:PerfTrace = Perf.newTrace("test_trace");
myTrace.start();
// code that you want to trace (and log custom metrics)
var item:Item = cache.fetch("item");
if (item != null)
{
myTrace.incrementMetric("item_cache_hit", 1);
}
else
{
myTrace.incrementMetric("item_cache_miss", 1);
}
myTrace.stop();
Performance Monitoring collects network requests automatically. Although this includes most network requests for your app, some might not be reported.
To include custom network requests in Performance Monitoring, add the following code to your app:
var httpMetric:HttpMetric = Perf.newHttpMetric("https://www.google.com", URLRequestMethod.GET);
httpMetric.start();
var request:URLRequest = new URLRequest();
request.url = "https://www.google.com";
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.addEventListener(IOErrorEvent.IO_ERROR, function (event:IOErrorEvent):void {
trace(event.toString());
});
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, function (event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
httpMetric.setHttpResponseCode(event.status);
httpMetric.stop();
});
loader.load(request);
The HTTP/S network requests that you specifically capture in this way appear in the Firebase console along with the network requests that Performance Monitoring captures automatically.
After you've validated Performance Monitoring using one or more test devices, you can deploy the updated version of your app to your users.
Note: Depending on the behavior of your code and networking libraries used by your code, Performance Monitoring might only report HTTP/S network requests that are completed. This means that HTTP/S connections that are left open might not be reported.
You can enable debug logging for Performance Monitoring at build time, by adding a <meta-data>
element to your app's manifest .xml file, like so:
<application>
<meta-data
android:name="firebase_performance_logcat_enabled"
android:value="true" />
</application>
You can view trace and HTTP/S network request logging using logcat filtering. Performance Monitoring log messages are tagged with FirebasePerformance, and you can filter them using following command:
$ adb logcat -s FirebasePerformance
DISCRIMINATION: Firebase SDKs are developed by Google and they own every copyright to the Firebase "native" projects. However, we have used their "compiled" native SDKs to develop the ActionScript API to be used in AdobeAIR mobile projects. Moreover, as far as the documentations, we have copied and when needed has modified the Google documents so it will fit the needs of AdobeAIR community. If you wish to see the original documentations in Android/iOS, visit here. But if you are interested to do things in AdobeAIR, then you are in the right place.
Enjoy building Air apps – With ♥ from MyFlashLabs Team
Introduction to Firebase ANEs collection for Adobe Air apps
Get Started with Firebase Core in AIR
- Prerequisites
- Add Firebase to your app
- Add the Firebase SDK
- Init Firebase Core
- Available ANEs
- Managing Firebase iid
Get Started with Authentication
- Add Authentication
- Init Authentication
- Manage Users
- Phone Number
- Custom Auth
- Anonymous Auth
- State in Email Actions
- Email Link Authentication
Get Started with FCM + OneSignal
- Add FCM ANE
- Init FCM ANE
- Send Your 1st Message
- Send Msg to Topics
- Understanding FCM Messages
- init OneSignal
- Add Firestore
- Init Firestore
- Add Data
- Transactions & Batches
- Delete Data
- Manage the Console
- Get Data
- Get Realtime Updates
- Simple and Compound
- Order and Limit Data
- Paginate Data
- Manage Indexes
- Secure Data
- Offline Data
- Where to Go From Here
Get Started with Realtime Database
- Add Realtime Database
- Init Realtime Database
- Structure Your Database
- Save Data
- Retrieve Data
- Enable Offline Capabilities
Get Started with Remote Config
- Add Storage ANE
- Init Storage ANE
- Upload Files to Storage
- Download Files to Air
- Use File Metadata
- Delete Files