OpenTelemetry in the browser (real user monitoring)
A script that packages page timings, network calls and clicks into the OpenTelemetry format and sends them to the site's collector.
OpenTelemetry is not a browser feature. It is an open standard and a set of libraries that a site loads. In the browser it reads the timing APIs the page already has (navigation, resource, paint and user timing), wraps fetch and XHR, and records clicks, then ships it all as traces and metrics. It can also stamp a trace id on requests to the site's own servers, so one visit can be followed from the click to the database.
What it can and can't do
What the user does: Nothing. It runs as the page loads and as you use it
It can
- Time every page load, request and click
- Tie your browser activity to the site's server logs with a shared trace id
- Send device, browser and language details with each batch
- Show the site exactly where a slow visit lost time
It cannot
- Read other sites' requests or timings
- Ask permission first
- Get finer timers than the browser allows
- Keep working if a blocker stops the collector address
How it differs between platforms: The data is only as identifying as what the site attaches: some add a user or session id, which turns it into a per person activity log.
Browser support
How a site asks for it
| API | @opentelemetry/sdk-trace-web with document-load, fetch, xml-http-request and user-interaction instrumentations; OTLP/HTTP exporter (POST /v1/traces, /v1/metrics, /v1/logs) |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | Per page; buffered spans are sent with fetch or sendBeacon and nothing is stored in the browser by default |
| How to take it back | Nothing to revoke; content blockers that block the collector address stop the export |
| Inside an iframe | Per frame; it only sees what that frame's own timing APIs and network calls expose |
Typical flow
- Page loads the OpenTelemetry web SDK and its instrumentations
- SDK reads navigation and resource timing for the page load
- Fetch and XHR are wrapped so each request becomes a span, and a traceparent header is added for allowed origins
- Clicks and other events become spans or span events
- Batches are POSTed as OTLP to the site's collector
Data you get
What comes back: Spans, metrics and logs with nanosecond timestamps (browser timers are coarsened to about 0.1 ms or more)
Shape: list
How often: Batched, usually every few seconds and on page hide
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
traceId | string | None | 32 hex characters | random per trace |
span duration | float | ms | 0 and up | timer resolution |
http.url / url.full | string | None | Not listed | full request URL |
user_agent.original | string | None | Not listed | Not listed |
browser.platform / browser.mobile / browser.language | string | None | Not listed | from User Agent Client Hints where available |
Technical limits
- It is a library, not a browser API: support is whatever the underlying APIs (Performance, PerformanceObserver, fetch) have
- The browser client is still marked experimental by the OpenTelemetry project
- The traceparent header goes to cross origin servers only when the site lists them, and those servers must allow it in CORS
- Export needs the collector to allow CORS from the page origin; OTLP over HTTP usually listens on port 4318
- Timings are limited by the browser's coarsened timers
The story
What it is
An open standard that bundles a page's timings, network calls and clicks into traces and sends them to the site.
For you
You never see it. When a site uses it, every load, request and click on that site can be timed and sent home, often with your browser and device details.
For makers
One format for front end and back end telemetry. The browser span and the server span share a trace id, so a slow checkout can be followed end to end. Any OTLP backend can receive it, so there is no lock in to one monitoring vendor.
Where you see it
| Type | Example | Apps |
|---|---|---|
| shopping | A shop follows one slow checkout from the button click through every API call to the payment service. | None named |
| productivity | A web app compares page load and request times by browser after each release. | None named |
Risks
- Silent and always on where used
- Can carry full URLs and ids
- Links browser activity to server logs
What the platform says
- OpenTelemetry: OpenTelemetry for JavaScript. Vendor neutral APIs and SDKs to collect traces, metrics and logs, including from the browser.
Good uses and abuse
Legitimate uses
- Real user monitoring
- End to end tracing from click to database
- Release and performance regression checks
Known abuse
- Detailed per visit activity logs
- Joining browser behavior to server side identity
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 2 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 2 | Rough identifying entropy, when known |
History
- 2019-05, all: OpenTracing and OpenCensus announce their merger into OpenTelemetry
- 2021-02, all: OpenTelemetry tracing specification reaches 1.0
Related capabilities
Related
- Navigation and Resource Timing. Can see how fast the page and each file loaded for you
- User Timing marks and measures. Can mark points in time and measure gaps between them inside the page
- Server-Timing header. Can pass timing numbers from the server to page scripts
- Event Timing and INP. Can time how fast the page responds to your taps, clicks and key presses
- Reporting API (crash, CSP and deprecation reports). Can get the browser's crash and error reports sent to the site
Sources
- OpenTelemetry specification
- OTLP protocol
- OpenTelemetry JS in the browser
- W3C Trace Context
- Browser semantic conventions
How well checked: Based on official documentation.