React

React monitoring from the browser to the backend

by Obseria · Frontend, mobile and e-commerce
  • OpenTelemetry
  • Digital Experience
  • Frontend, mobile and e-commerce
Category
Frontend, mobile and e-commerce
Key metrics
8
Ready-made
5 dashboards & alerts
Setup
3 steps
Standard
OTLP

Add the OpenTelemetry web SDK to your React app and Obseria shows page loads, fetch calls, user interactions and Core Web Vitals per page, each request connected to the backend trace that served it.

Standard SDK, no proprietary agent

The OpenTelemetry web SDK and its auto-instrumentations capture document load, fetch, XHR and user interactions with a single tracing.ts file.

Core Web Vitals per page

LCP, INP, CLS, FCP and TTFB are reported from real browsers and scored at the 75th percentile, the same percentile Google uses.

Frontend and backend in one trace

W3C trace context travels with every fetch call, so a slow React view leads straight to the API span and query behind it.

Obseria interface

Obseria apps and capabilities: observability, APM, infrastructure and integrations
Obseria home dashboard with service health, open problems, SLO compliance and ingestion
Obseria trace explorer with span list and span attributes

Ready the moment data arrives

  • Core Web Vitals per route at p75
  • Slowest fetch calls by endpoint and status code
  • Alert on p75 LCP above 2.5 s on key pages
  • Alert on rising JavaScript error rate after a release
  • Page loads and interactions by browser and timezone

What Obseria captures from a React app

Initial page load

The document-load instrumentation records documentLoad, documentFetch and resourceFetch spans with the browser's navigation and resource timing.

fetch and XMLHttpRequest

Every API call from your components becomes a client span with URL, method, status code and duration, and carries a traceparent header.

User interactions

Clicks and other configured events become spans, so you see which interaction triggered which requests.

Core Web Vitals

The web-vitals library reports LCP, INP, CLS, FCP and TTFB, which the snippet records as OTLP gauges per page.

Client-side routing

With React Router or a similar library, the page attribute follows the current route, so vitals and spans group by view.

JavaScript errors

Exceptions recorded on spans appear with stack trace and release in the Errors Inbox.

The React signals that matter

Obseria collects these values automatically and shows them in ready-made dashboards and alerts.

MetricUnitWhat it tells you
web_vitals.lcpsLargest Contentful Paint per page: when the main content became visible. Good is 2.5 s or less at p75.
web_vitals.inpmsInteraction to Next Paint: delay between a click or key press and the next frame. Good is 200 ms or less.
web_vitals.cls1Cumulative Layout Shift: how much the layout moved unexpectedly. Good is 0.1 or less.
web_vitals.fcpsFirst Contentful Paint: when the first text or image appeared.
web_vitals.ttfbmsTime to First Byte: how long the server and network took before the first byte arrived.
documentLoadmsSpan, not a metric: the full page load, with child spans documentFetch and resourceFetch for each script, style and image.
HTTP GET / HTTP POSTmsSpan, not a metric: one client span per fetch or XHR call with http.url and http.status_code.
clickmsSpan, not a metric: a user interaction from the user-interaction instrumentation, parent of the requests it triggers.

Set up React monitoring in minutes

  1. 1

    Install the web SDK

    npm install the OpenTelemetry web tracer, the web auto-instrumentations, the OTLP HTTP exporter, and web-vitals with the metrics SDK.

  2. 2

    Create tracing.ts and vitals.ts

    Register a WebTracerProvider with the OTLP exporter and the auto-instrumentations, and record each Web Vital as a gauge named web_vitals.*.

  3. 3

    Import first and verify

    Import both files at the top of src/main.tsx, load a page in a real browser and click around; INP needs an interaction before it reports.

Example configuration · TYPESCRIPT
// npm install @opentelemetry/sdk-trace-web @opentelemetry/auto-instrumentations-web \
//   @opentelemetry/instrumentation @opentelemetry/resources \
//   @opentelemetry/exporter-trace-otlp-http web-vitals \
//   @opentelemetry/sdk-metrics @opentelemetry/exporter-metrics-otlp-http

// src/tracing.ts — import it as the first line of src/main.tsx
import { WebTracerProvider, BatchSpanProcessor } from "@opentelemetry/sdk-trace-web";
import { getWebAutoInstrumentations } from "@opentelemetry/auto-instrumentations-web";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { resourceFromAttributes } from "@opentelemetry/resources";

const provider = new WebTracerProvider({
  resource: resourceFromAttributes({
    "service.name": "web",
    "browser.timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
  }),
  spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter({
    url: "${OBSERIA_OTLP_ENDPOINT}/v1/traces",
    headers: { Authorization: "Bearer ${OBSERIA_TOKEN}" }, // ingest-only token
  }))],
});
provider.register();

// document load, fetch, XHR and user interactions
registerInstrumentations({ instrumentations: [getWebAutoInstrumentations()] });

// src/vitals.ts — Core Web Vitals as OTLP metrics (web_vitals.lcp, .inp, .cls, .fcp, .ttfb)
import { onLCP, onINP, onCLS } from "web-vitals";
// ... MeterProvider with OTLPMetricExporter, one gauge per vital,
// recorded with { page: location.pathname } and flushed on visibilitychange

Why React monitoring matters

A React application moves much of the work into the browser. Rendering, routing, data fetching and state updates all happen on the user's device, on hardware and networks you do not control. Server dashboards stay green while a large bundle, a slow API call or a layout shift from a late-loading component makes the page feel broken. React monitoring closes that gap: it measures what real users experience and connects it to the services that answer their requests.

Obseria does this with the standard OpenTelemetry web SDK instead of a proprietary script. The @opentelemetry/auto-instrumentations-web package bundles the document-load, fetch, XMLHttpRequest and user-interaction instrumentations. Core Web Vitals come from Google's web-vitals library and are sent as OTLP metrics. Because both are open source, your instrumentation stays portable.

Signals that matter for React performance monitoring

  • Loading: web_vitals.lcp and web_vitals.fcp show when content appears. The documentLoad span and its resourceFetch children show which script, font or image held it back.
  • Responsiveness: web_vitals.inp captures how quickly the page reacts to input. In React, high INP usually points to expensive re-renders or long tasks on the main thread.
  • Visual stability: web_vitals.cls rises when components render without reserved space, for example images, ads or data that arrives after the first paint.
  • API calls: fetch and XHR spans show the latency and status of every request your components make, and the trace continues into the backend.
  • Errors: exceptions recorded on spans land in the Errors Inbox with release and page, so a regression after a frontend deploy is visible quickly.

Obseria scores each page at the 75th percentile, the same percentile Google uses for Core Web Vitals. Looking at percentiles instead of averages keeps slow devices and distant regions from disappearing behind a fast majority.

Common React performance problems and how to detect them

Slow first render

A single large bundle delays the moment React can render anything. High LCP together with long resourceFetch spans for JavaScript files points to code splitting and lazy loading as the fix.

Request waterfalls

Components that fetch data only after their parent has rendered create sequential requests. In the trace view, fetch spans line up one after another instead of running in parallel, and the backend spans show that each call was fast on its own.

Expensive re-renders

A state update high in the tree can re-render large parts of the page. Users feel it as sluggish clicks; you see it as a high web_vitals.inp on specific pages, often next to click spans that take long before any request starts.

Layout shifts from late content

Banners, images without dimensions and skeletons that do not match the final layout push content around. A CLS that jumps after a release tells you which page to inspect.

Slow or failing APIs

When a view hangs, the fetch span shows whether the browser waited on the network or on the server. Because the trace continues into the backend, you see the slow service, query or downstream call directly.

Best practices for React app monitoring

  1. Import tracing.ts before anything else in your entry point so the full page load and early requests are captured.
  2. Record the current route as the page attribute, using route templates instead of raw URLs to keep cardinality low.
  3. Export Web Vitals on a short interval and flush on visibilitychange; CLS and INP keep changing until the tab is hidden.
  4. Use a token scoped to ingest only. Everything shipped to the browser is readable by anyone who opens the page.
  5. Allow the traceparent header on your API's CORS configuration so frontend and backend spans join one trace.
  6. Set SLOs on user experience, such as p75 LCP on your most important pages, not only on backend latency.

How Obseria helps with React monitoring

Obseria receives traces and Web Vitals from the browser over OTLP and shows them on the Browser page next to sessions and page views. Each fetch span links to the backend trace, so you can move from a slow React view to the API endpoint, database query or downstream service in one click. Obseria Pipeline masks personal data at ingest, JavaScript errors appear in the Errors Inbox, and dashboards, alerts and SLOs work on frontend data the same way they do on backend data.

Learn more

React monitoring FAQ

No. React runs in the browser, so the OpenTelemetry web SDK covers it. One tracing.ts file imported at the top of your entry point instruments page loads, fetch, XHR and user interactions for the whole app.

The web-vitals library reports LCP, INP, CLS, FCP and TTFB. The snippet records them as OTLP gauges named web_vitals.lcp, web_vitals.inp and so on, with the page as attribute. Obseria reads exactly these names and scores each page at the 75th percentile.

INP needs at least one interaction. Load a page in a real browser and click or type something; the value is reported when the page is hidden or closed.

Anything in a browser bundle is public. Use a token that is limited to ingest and rotate it separately from server tokens. Obseria Pipeline can additionally mask personal data before storage.

Yes. The web SDK is independent of the build tool. For Next.js, which also renders on the server, use the dedicated Next.js setup with instrumentation.ts.

Start monitoring React today

Connect React in minutes with OpenTelemetry or the Obseria Agent. Free for 14 days.