Catch up on everthing we announced at this year's Firebase Summit. Learn more

Filter data using attributes

With Performance Monitoring, you can use attributes to segment performance data and focus on your app's performance in different real-world scenarios.

After you click a trace name in the traces table (located at the bottom of the Performance dashboard), you can click through various screens to explore a trace and drill down into metrics of interest. On most pages, you can use the Filter button (top-left of the screen) to filter the data by attribute, for example:

an image of Firebase Performance Monitoring data being filtered by attribute

  • Filter by Page URL to view data for a specific page of your site
  • Filter by Effective connection type to learn how a 3g connection impacts your app
  • Filter by Country to make sure your database location isn't affecting a specific region

Default attributes

Performance Monitoring automatically collects a variety of default attributes depending on the type of trace.

In addition to these default attributes, you can also create custom attributes on your custom code traces to segment data by categories specific to your app. For example, in a game, you can segment data by game level.

Default attributes collected for web apps

All traces for web apps collect the following attributes by default:

Collecting user data

Create custom attributes

You can create custom attributes on any of your instrumented custom code traces.

Use the Performance Monitoring Trace API to add custom attributes to custom code traces.

To use custom attributes, add code to your app that defines the attribute and associates it with a specific custom code trace. You can set the custom attribute anytime between when the trace starts and when the trace stops.

Note the following:

  • Names for custom attributes must meet the following requirements: no leading or trailing whitespace, no leading underscore (_) character, and max length is 32 characters.

  • Each custom code trace can record up to 5 custom attributes.

  • You shouldn't use custom attributes that contain information that personally identifies an individual to Google.

    Learn more about this guideline

Web version 9

import { trace } from "firebase/performance";

const t = trace(perf, "test_trace");
t.putAttribute("experiment", "A");

// Update scenario
t.putAttribute("experiment", "B");

// Reading scenario
const experimentValue = t.getAttribute("experiment");

// Delete scenario

// Read attributes
const traceAttributes = t.getAttributes();

Web version 8

const trace = perf.trace("test_trace");
trace.putAttribute("experiment", "A");

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

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

// Delete scenario

// Read attributes
const traceAttributes = trace.getAttributes();