Monitor Custom Attributes

In Firebase Performance Monitoring, you can use attributes to segment performance data and focus on your app's performance in different real-world scenarios. A variety of attributes are available out-of-the-box, including operating system information, country, carrier, device, and app version. In addition, you can also create custom attributes, to segment data by categories specific to your app. For example, in a game, you can segment data by game level.

Create custom attributes

You can use custom attributes on specific traces. You're limited to 5 custom attributes per trace.

To use custom attributes, add code to your app defining the attribute and applying it to a specific trace, like the following examples:

Trace myTrace = FirebasePerformance.getInstance().newTrace("test_trace");

// Update scenario.
trace.putAttribute("experiment", "A");

// Reading scenario.
String experimentValue = trace.getAttribute("experiment");

// Delete scenario.

// Read attributes.
Map traceAttributes = trace.getAttributes();
var trace = Performance.sharedInstance().trace(name:"myTrace")
trace.setValue("A", forAttribute: "experiment")

// Update scenario.
trace.setValue("B", forAttribute: "experiment")

// Reading scenario.
let experimentValue:String? = trace.valueForAttribute("experiment")

// Delete scenario.

// Read attributes.
let attributes:[String, String] = trace.attributes;
FIRTrace *trace = [[FIRPerformance sharedInstance] traceWithName:@"myTrace"];
[trace setValue:@"A" forAttribute:@"experiment"];

// Update scenario.
[trace setValue:@"B" forAttribute:@"experiment"];

// Reading scenario.
NSString *experimentValue = [trace valueForAttribute:@"experiment"];

// Delete scenario.
[trace removeAttribute:@"experiment"];

// Read attributes.
NSDictionary  *attributes = [trace attributes];

Monitor custom attributes

In the Firebase console, go to the Traces tab in the Performance section. Each of your custom attributes has a card showing performance data for that segment. You can also filter by custom attributes.

Send feedback about...

Need help? Visit our support page.