RousselTMLEARNING

Article · Grafana Faro: front-end observability and RUM

Traces from the browser to the back end

1. The principle #

The browser starts the trace.

Propagation #

End-to-end trace
The same trace_id links the browser span and the back-end spans.

TracingInstrumentation creates a span for each fetch or XMLHttpRequest request and adds the W3C traceparent header. If the back end is instrumented with OpenTelemetry (SDK or Beyla), it continues the same trace.

2. Configuring #

SDK, CORS and back end.

Browser side #

new TracingInstrumentation({
  instrumentationOptions: {
    // En-tête ajouté aussi pour ces domaines (sinon seulement pour l'origine de la page)
    propagateTraceHeaderCorsUrls: [/https:\/\/api\.example\.org\/.*/],
  },
})

API side #

For an API on another domain, the browser sends a CORS preflight request: the API must allow the traceparent header.

# nginx devant l'API
add_header Access-Control-Allow-Origin "https://boutique.example.org" always;
add_header Access-Control-Allow-Headers "content-type, traceparent, tracestate" always;
Common mistake: If the header is not allowed, the browser blocks the request: deploy the CORS configuration on the API side before enabling propagation on the front end.

3. Navigating in Grafana #

From perceived slowness to the SQL query.

Journey #

  1. A degraded LCP on the cart page (Loki query on measurements).
  2. The slow fetch requests of that page (Tempo traces with the front end's service.name).
  3. The full trace: the browser span, the API, then a 1.8 s SQL query.
  4. The API service's CPU profile during that span (see the Pyroscope course).
{ resource.service.name = "boutique" && span.http.url =~ ".*/api/panier.*" && duration > 1s }

📄 From click to database: front-end to back-end traces with Faro →

My progress

  • ⏱ Estimated time : ≈ 4 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Course Glossary

Core Web Vitals

Set of three metrics defined by Google to measure the real experience of a web page: loading (LCP (Largest Contentful Paint)), responsiveness (INP (In...

LCP (Largest Contentful Paint)

Time until the largest visible element of the page (image, video or text block) is rendered: it shows when the main content appears. Loading metric of...

INP (Interaction to Next Paint)

Latency of interactions (click, tap, key press) observed over the whole visit: the delay between the user's action and the next paint. The reported va...

CLS (Cumulative Layout Shift)

Measure of visual stability: the sum of unexpected layout shifts (a button moving just as you click, text pushed down by an ad). Unitless, computed ov...

FCP (First Contentful Paint)

Time until the first content (text, image, SVG) is rendered: the moment the user sees the page start loading. It is not a Core Web Vital, but it helps...

TTFB (Time to First Byte)

Time between the start of navigation and the arrival of the first byte of the response: it adds up redirects, DNS, TCP/TLS connection and server proce...

FID (First Input Delay)

Former responsiveness metric of the Core Web Vitals: the delay before the browser starts handling the first interaction (good ≤ 100 ms). It ignored la...

TBT (Total Blocking Time)

Lab metric (Lighthouse): the sum, between FCP (First Contentful Paint) and the end of loading, of the blocking part of each long task (over 50 ms) on ...

CrUX (Chrome UX Report)

Google's public dataset aggregating the Core Web Vitals measured from real Chrome users (at the 75th percentile, per origin and URL, over a rolling 28...

Lighthouse

Google's free audit tool, built into Chrome DevTools and PageSpeed Insights: it loads the page in a simulated environment and scores performance, acce...

Apdex

Application Performance Index: a satisfaction score between 0 and 1 based on a time threshold T. Requests under T are “satisfied”, between T and 4T “t...

Recommended Articles

Front-end observability best practices with Faro

Checklist for useful, respectful RUM: SDK configuration, versions, source maps, correlation with ...

Faro and Alloy: receiving front-end RUM with faro.receiver

Configure faro.receiver: CORS, API key, rate limiting, source maps, then send browser errors, Web...

Distributed tracing with Jaeger: concepts and architecture

The concepts of distributed tracing (trace, span, context, propagation) and Jaeger: its history, ...

Using Faro data: queries, dashboards, alerts and GDPR

Query Faro data in Loki (Web Vitals, errors, events), build dashboards and alerts, and comply wit...

Traefik: distributed tracing with OpenTelemetry

Enable Traefik v3 tracing with OpenTelemetry (OTLP), propagate the W3C context to applications, s...

Frontend Observability in Grafana Cloud

Frontend Observability in Grafana Cloud: RUM built on Grafana Faro. Web Vitals, JavaScript errors...

Grafana Tempo: the distributed tracing backend at scale

Understand distributed tracing and Grafana Tempo: traces, spans, TraceID, architecture (distribut...

Real User Monitoring (RUM) and Core Web Vitals: measuring what users experience

Why observe the front end, what RUM measures, Core Web Vitals (LCP, INP, CLS) and their threshold...

Grafana Faro: architecture and installation

Install Grafana Faro: the web SDK (npm or CDN), Alloy's faro.receiver, sending to Loki and Tempo,...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!