The Firebase Performance Monitoring API.
It is automatically initialized by FirebaseApp.
This SDK uses FirebaseInstallations to identify the app instance and periodically sends
data to the Firebase backend. To stop sending performance events, call
FirebasePerformance.setPerformanceCollectionEnabled(false)
.
Nested Class Summary
@interface | FirebasePerformance.HttpMethod | Valid HttpMethods for manual network APIs |
Constant Summary
int | MAX_ATTRIBUTE_KEY_LENGTH | Maximum allowed length of the Key of the
Trace
attribute |
int | MAX_ATTRIBUTE_VALUE_LENGTH | Maximum allowed length of the Value of the
Trace
attribute |
int | MAX_TRACE_CUSTOM_ATTRIBUTES | Maximum allowed number of attributes allowed in a trace. |
int | MAX_TRACE_NAME_LENGTH | Maximum allowed length of the name of the
Trace |
Public Method Summary
static FirebasePerformance |
getInstance()
Returns a singleton of FirebasePerformance.
|
boolean |
isPerformanceCollectionEnabled()
Determines whether performance monitoring is enabled or disabled.
|
HttpMetric |
newHttpMetric(URL url, String httpMethod)
Creates a HttpMetric object for collecting network performance data for one
request/response
|
HttpMetric |
newHttpMetric(String url,
String
httpMethod)
Creates a HttpMetric object for collecting network performance data for one
request/response
|
Trace | |
void |
setPerformanceCollectionEnabled(boolean enable)
Enables or disables performance monitoring.
|
static Trace |
Inherited Method Summary
Constants
public static final int MAX_ATTRIBUTE_KEY_LENGTH
Maximum allowed length of the Key of the Trace
attribute
public static final int MAX_ATTRIBUTE_VALUE_LENGTH
Maximum allowed length of the Value of the Trace
attribute
public static final int MAX_TRACE_CUSTOM_ATTRIBUTES
Maximum allowed number of attributes allowed in a trace.
public static final int MAX_TRACE_NAME_LENGTH
Maximum allowed length of the name of the Trace
Public Methods
public static FirebasePerformance getInstance ()
Returns a singleton of FirebasePerformance.
Returns
- the singleton FirebasePerformance object.
public boolean isPerformanceCollectionEnabled ()
Determines whether performance monitoring is enabled or disabled. This respects the Firebase Performance specific values first, and if these aren't set, uses the Firebase wide data collection switch.
Returns
- true if performance monitoring is enabled and false if performance monitoring is disabled. This is for dynamic enable/disable state. This does not reflect whether instrumentation is enabled/disabled in Gradle properties.
public HttpMetric newHttpMetric (URL url, String httpMethod)
Creates a HttpMetric object for collecting network performance data for one request/response
Parameters
url | a valid URL object |
---|---|
httpMethod | One of the values GET, PUT, POST, DELETE, HEAD, PATCH, OPTIONS, TRACE, or CONNECT |
Returns
- the new HttpMetric object.
public HttpMetric newHttpMetric (String url, String httpMethod)
Creates a HttpMetric object for collecting network performance data for one request/response
Parameters
url | a valid url String, cannot be empty |
---|---|
httpMethod | One of the values GET, PUT, POST, DELETE, HEAD, PATCH, OPTIONS, TRACE, or CONNECT |
Returns
- the new HttpMetric object.
public Trace newTrace (String traceName)
Creates a Trace object with given name.
Parameters
traceName | name of the trace, requires no leading or trailing whitespace, no leading
underscore '_' character, max length is
MAX_TRACE_NAME_LENGTH characters. |
---|
Returns
- the new Trace object.
public void setPerformanceCollectionEnabled (boolean enable)
Enables or disables performance monitoring. This setting is persisted and applied on future invocations of your application. By default, performance monitoring is enabled. If you need to change the default (for example, because you want to prompt the user before collecting performance stats), add:
<meta-data android:name=firebase_performance_collection_enabled android:value=false />
to your application’s manifest. Changing the value during runtime will override the
manifest value.
If you want to permanently disable sending performance metrics, add
<meta-data android:name="firebase_performance_collection_deactivated" android:value="true" />
to your application's manifest. Changing the value during runtime will not override
the manifest value.
This is separate from enabling/disabling instrumentation in Gradle properties.
Parameters
enable | Should performance monitoring be enabled |
---|
public static Trace startTrace (String traceName)
Creates a Trace object with given name and start the trace.
Parameters
traceName | name of the trace. Requires no leading or trailing whitespace, no leading
underscore [_] character, max length of
MAX_TRACE_NAME_LENGTH characters. |
---|
Returns
- the new Trace object.