# Trace One Failed User Action From Browser to Backend

> Propagate trace context through frontend, APIs, jobs, and logs while respecting trust, sampling, and privacy boundaries.

Canonical URL: https://www.devobs.io/articles/browser-to-backend-correlation/
By: Sofia Reyes
Published: 2023-03-24T02:10:09.359Z
Updated: 2026-09-06T10:18:15.722Z
Section: Architecture

## Propagate context from the user action

Start a browser span for the user action, propagate valid trace context to the API, and continue it through downstream calls. For queued work, store trace context or create a linked span when processing occurs later. [W3C Trace Context](https://www.w3.org/TR/trace-context/) defines the trace context propagated between services.

## Connect a checkout to its API and jobs

A checkout click records route and deploy version, not card or email data. The API returns a short support reference mapped server-side to trace ID. Jobs include message ID and attempt. Sampling decisions should keep errors without letting attackers force unlimited tracing. [OpenTelemetry Trace specification](https://opentelemetry.io/docs/specs/otel/trace/) describes spans and their relationships.

## Keep the chain trustworthy

Validate traceparent at the public edge and create a fresh trace when its format or trust level is unacceptable. Preserve an incoming trace ID only as correlation, never as proof of identity. Limit baggage to reviewed keys because it crosses process boundaries and can multiply sensitive data across telemetry stores. A public support code should map to a trace server-side; exposing the raw trace ID makes enumeration and data access harder to control.

Record route templates, release version, region, queue message ID, and retry attempt. Avoid URLs with identifiers, request bodies, email addresses, and tokens. Logs still need a request ID when head sampling drops the trace.

## Reproduce a broken journey

Test a checkout whose browser request succeeds, API call times out, and queued payment confirmation completes later. Confirm the UI span, API span, and worker span are connected or explicitly linked, and that the support code finds the chain. Repeat with malformed context, an unsampled trace, a duplicate message, and a collector outage.

The release decision is practical: a responder should locate the failed backend operation from one user-visible reference without searching personal data. Run that exercise against a staging failure and keep the trace and lookup steps with the incident runbook.

## Source references

- <https://www.w3.org/TR/trace-context/>
- <https://opentelemetry.io/docs/specs/otel/trace/>
