Trace allows you to set beginning and end of a certain action in your app.
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 |
Inherited Constant Summary
Field Summary
public static final Creator<Trace> | CREATOR | A public static CREATOR field that implements
Parcelable.Creator and generates instances of your Parcelable class from
a Parcel. |
Public Method Summary
int |
describeContents()
Describes the kinds of special objects contained in this Parcelable's
marshalled representation.
|
String | |
Map<String, String> |
getAttributes()
Returns the map of all the attributes added to this trace.
|
long |
getLongMetric(String metricName)
Gets the value of the metric with the given name in the current trace.
|
void |
incrementMetric(String metricName,
long incrementBy)
Atomically increments the metric with the given name in this trace by the
incrementBy value.
|
void | |
void | |
void | |
void |
start()
Starts this trace.
|
void |
stop()
Stops this trace.
|
void |
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
Fields
Public Methods
public int describeContents ()
Describes the kinds of special objects contained in this Parcelable's marshalled representation.
Returns
- always returns 0.
public String getAttribute (String attribute)
Returns the value of an attribute.
Parameters
attribute | name of the attribute to fetch the value for |
---|
Returns
- the value of the attribute if it exists or null otherwise.
public Map<String, String> getAttributes ()
Returns the map of all the attributes added to this trace.
Returns
- map of attributes and its values currently added to this Trace
public long getLongMetric (String metricName)
Gets the value of the metric with the given name in the current trace. If a metric with the given name doesn't exist, it is NOT created and a 0 is returned. This method is atomic.
Parameters
metricName | Name of the metric to get. Requires no leading or trailing whitespace, no leading underscore '_' character, max length is 100 characters. |
---|
Returns
- Value of the metric or 0 if it hasn't yet been set.
public void incrementMetric (String metricName, long incrementBy)
Atomically increments the metric with the given name in this trace by the incrementBy value. If the metric does not exist, a new one will be created. If the trace has not been started or has already been stopped, returns immediately without taking action.
Parameters
metricName | Name of the metric to be incremented. Requires no leading or trailing whitespace, no leading underscore [_] character, max length of 100 characters. |
---|---|
incrementBy | Amount by which the metric has to be incremented. |
public void putAttribute (String attribute, String value)
Sets a String value for the specified attribute. Updates the value of the attribute
if the attribute already exists. If the trace has been stopped, this method returns
without adding the attribute. The maximum number of attributes that can be added to a
Trace are
MAX_TRACE_CUSTOM_ATTRIBUTES
.
Parameters
attribute | Name of the attribute |
---|---|
value | Value of the attribute |
public void putMetric (String metricName, long value)
Sets the value of the metric with the given name in this trace to the value provided. If a metric with the given name doesn't exist, a new one will be created. If the trace has not been started or has already been stopped, returns immediately without taking action. This method is atomic.
Parameters
metricName | Name of the metric to set. Requires no leading or trailing whitespace, no leading underscore '_' character, max length is 100 characters. |
---|---|
value | The value to which the metric should be set to. |
public void removeAttribute (String attribute)
Removes an already added attribute from the Traces. If the trace has been stopped, this method returns without removing the attribute.
Parameters
attribute | Name of the attribute to be removed from the running Traces. |
---|
public void start ()
Starts this trace.
public void stop ()
Stops this trace.
public void writeToParcel (Parcel out, int flags)
Flatten this object into a Parcel. Please refer to //developer.android.com/reference/android/os/Parcelable.html
Parameters
out | the Parcel in which the object should be written. |
---|---|
flags | Additional flags about how the object should be written. |