> ## Documentation Index
> Fetch the complete documentation index at: https://docs.traceback.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Distributed Tracing

> End-to-end request tracing across frontend clients, API gateways, microservices, and databases.

Traceback supports distributed request tracing compliant with the **W3C TraceContext** and **OpenTelemetry** standards.

## Propagation Flow

When a user initiates an action in the browser, Traceback attaches `traceparent` headers to outgoing HTTP/fetch requests, linking client transactions directly to backend database queries and external service calls.

```text theme={null}
[ Browser Click ] --> traceparent: 00-4bf92f3577b34da6-00f067aa0ba902b7-01
        |
        v
[ Next.js Edge Gateway ] (Span duration: 120ms)
        |
        v
[ Go Billing Service ] (Span duration: 85ms)
        |
        v
[ Postgres Query: SELECT * FROM billing ] (Span duration: 14ms)
```

***

## Custom Spans & Transactions

To measure custom business logic:

```typescript theme={null}
import * as Traceback from "@traceback/node";

await Traceback.startSpan(
  {
    name: "invoice.generate_pdf",
    op: "task",
    attributes: { invoiceId: "inv_9841" },
  },
  async (span) => {
    const pdf = await renderPdfTemplate();
    span.setTag("file_size_bytes", pdf.byteLength);
    return pdf;
  }
);
```
