Trace

public class Trace extends Object
implements Parcelable

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
getAttribute(String attribute)
Returns the value of an attribute.
Map<StringString>
getAttributes()
Returns the map of all the attributes added to this trace.
void
incrementCounter(String counterName, long incrementBy)
Increments the counter in this trace with the given name by given value.
void
incrementCounter(String counterName)
Increments the counter in this trace with the given name by one.
void
putAttribute(String attribute, String value)
Sets a String value for the specified attribute.
void
removeAttribute(String attribute)
Removes an already added attribute from the Traces.
void
start()
Starts this trace.
void
stop()
Stops this trace.
void
writeToParcel(Parcel out, int flags)
Flatten this object into a Parcel.

Inherited Method Summary

Constants

public static final int MAX_ATTRIBUTE_KEY_LENGTH

Maximum allowed length of the Key of the Trace attribute

Constant Value: 40

public static final int MAX_ATTRIBUTE_VALUE_LENGTH

Maximum allowed length of the Value of the Trace attribute

Constant Value: 100

public static final int MAX_TRACE_CUSTOM_ATTRIBUTES

Maximum allowed number of attributes allowed in a trace.

Constant Value: 5

public static final int MAX_TRACE_NAME_LENGTH

Maximum allowed length of the name of the Trace

Constant Value: 100

Fields

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 Methods

public int describeContents ()

Describes the kinds of special objects contained in this Parcelable's marshalled representation. Please refer to //developer.android.com/reference/android/os/Parcelable.html

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<StringString> 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 void incrementCounter (String counterName, long incrementBy)

Increments the counter in this trace with the given name by given value. If a counter does not already 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
counterName Name of the counter to be incremented. Requires no leading or trailing whitespace, no leading underscore [_] character, max length of 32 characters.
incrementBy Amount by which the counter has to be incremented.

public void incrementCounter (String counterName)

Increments the counter in this trace with the given name by one. If a counter does not already 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
counterName Name of the counter to be incremented. Requires no leading or trailing whitespace, no leading underscore '_' character, max length is 32 characters.

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
Returns
  • true if the attribute was added, false otherwise.

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.