# View traces and transactions

Turn on tracing in the Sentry SDK, then see a request's transactions and spans on one time axis, and a project's transactions by name with their durations and failure rate.

Replace _project-id_ with the project's id and _trace-id_ with a trace id (32 hexadecimal
characters, as an event's **Trace** field shows it).

## Turn on tracing

Set `tracesSampleRate` above 0 in `Sentry.init` (0.1 sends one in ten). Every sampled page load,
navigation and server request then arrives as a transaction with its spans, and the browser's and
the server's transactions of one request share a trace.

Transactions have their own per-minute and per-month quotas, so a burst of traces is refused for
transactions only and errors keep flowing; they do count towards the organization's storage quota,
which covers every kind of data (see [Quotas](quotas.md)). Spans are metered (see
[What is Error Tracking?](what-is.md)).

## Prerequisites

- Permission for `errors:GetEvents` on the project. Without it, the **Transactions** tab says "You
  can see this project but not its transactions."; a trace shows only the parts in projects you
  may read, and is not found when that is none of it.
- To read a trace through the API or the CLI, `errors:GetEvents` on the service,
  `rn:ews:de1:<organization id>:errors:*`; without it the request is refused with `403`, even when
  you may read the project. The console's trace page needs it only on the projects.
- In the console, also `errors:ListProjects` on the project to open it (without it the project is
  not found).

## Open a trace

**Console**
1. Open an issue whose event has a **Trace**, and choose the trace id. Or, on the
   **Transactions** tab, open a transaction name and choose one of its **Slowest examples**.
2. The **Waterfall** shows every transaction of the trace with its spans on one time axis: the
   server's request under the browser's `fetch` that made it, and errors marked on the span they
   happened in. Open a row for its details.

The header shows the trace's duration, transactions, spans, errors and, for a page load, its web
vitals (LCP, FCP, CLS, TTFB, INP, FID) when the SDK measured them. A transaction whose own clock
puts it more than 50 ms outside its caller's span is drawn where that span starts, and its details
say how far its clock was off. **Errors in this trace** lists the trace's errors. When no
transaction of the trace was sampled, the page says "No transaction of this trace was sampled."
and shows only the errors.

**CLI**
```sh
dcloud errors traces get trace-id
```

**API**
```http
GET /errors/api/traces/trace-id
```

The answer has the trace's `transactions`, `errors`, the waterfall `rows`, `hidden` (rows in
projects you may not read) and `profiled` (transactions that have a profile).

## List a project's transactions

**Console**
1. Open the project, then the **Transactions** tab.
2. Choose **24 h** or **7 days**.
3. (Optional) Choose a transaction for its 10 slowest examples, each of which opens its trace.

**CLI**
```sh
dcloud errors transactions list project-id --range 7d
```

**API**
```http
GET /errors/api/projects/project-id/transactions?range=7d
```

Rows come most frequent first, up to `limit` (50 by default, at most 200).

Each row is one name and operation:

- **Count**: extrapolated from each trace's sample rate, with the sampled count beneath it when
  the two differ.
- **p50**, **p75**, **p95**: durations.
- **Failure rate**: the share of transactions whose status is set and is not `ok`, `cancelled` or
  `unknown`.

A name the SDK took from the raw URL (a Next.js App Router page load, for one) is listed by its
shape: a path segment that looks like an id (digits, a hex or UUID string with a digit in it, or 25
characters or more) shows as `*`, so `/orders/4810` and `/orders/4811` are the one row `/orders/*`.

## What is not stored

Request cookies, credential headers and query strings (in URLs and span data) of a transaction are
not stored. Standalone spans (span streaming, `traceLifecycle: "stream"`) are not supported yet:
the ingest answers them with a one-hour rate limit, and nothing shows.

## Related

- [Find slow database queries](find-slow-database-queries.md)
- [Profile your code](profile-your-code.md)
- `errors.traces.get` · `dcloud errors transactions list`
