ElementTiming

Collect Element Timing API data as Sentry metrics.

Import name: Sentry.elementTimingIntegration

The elementTimingIntegration collects render and load timing data from the browser's Element Timing API and emits it as Sentry distribution metrics. This lets you track how long key elements (hero images, text blocks, etc.) take to appear on screen.

This integration requires Sentry Metrics to be available in your Sentry organization.

Copied
Sentry.init({
  integrations: [Sentry.elementTimingIntegration()],
});

Add the elementtiming HTML attribute to any element you want to track. The attribute value is used as the element's identifier in the emitted metrics.

Copied
<img src="hero.jpg" elementtiming="hero-image" />
<p elementtiming="hero-text">Welcome to our site!</p>

Only elements with a non-empty elementtiming attribute will be tracked.

The integration emits two distribution metrics (in milliseconds):

MetricDescription
ui.element.render_timeTime until the element was rendered. Emitted for both text and image elements.
ui.element.load_timeTime until the element's resource was loaded. Only emitted for image elements.

Both metrics include the following attributes:

AttributeDescription
ui.element.identifierThe value of the elementtiming HTML attribute.
ui.element.paint_typeThe type of paint event: image-paint or text-paint.
ui.element.idThe DOM element's id attribute, if set.
ui.element.typeThe tag name (e.g., img, p).
ui.element.urlThe image resource URL, if available.
ui.element.widthNatural width of the image, if available.
ui.element.heightNatural height of the image, if available.

The enableElementTiming option on browserTracingIntegration is deprecated and no longer has any effect. If you were using it, remove it and add the standalone elementTimingIntegration instead:

Copied
// Before
Sentry.init({
  integrations: [
    Sentry.browserTracingIntegration({
      enableElementTiming: true, // deprecated, no longer works
    }),
  ],
});

// After
Sentry.init({
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.elementTimingIntegration(),
  ],
});
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").