Triagebellfor Sentry
Guide

Sentry tracing and distributed tracing, explained

By the Triagebell team · Updated · 4 min read · How we check guides

Short answer

Sentry tracing records spans, timed units of work such as a page load, an HTTP call or a database query, and groups every span that shares a trace_id into one trace. You turn it on by setting tracesSampleRate or tracesSampler in Sentry.init. Distributed tracing then links services by sending the sentry-trace and baggage headers to the URLs in tracePropagationTargets. As of November 2026 every plan includes 5M spans a month; on Team, extra spans cost $2.00 per million pay-as-you-go.

Steps

  1. Set a sample rateAdd tracesSampleRate (or traces_sample_rate in Python) to Sentry.init, starting low such as 0.1 in production.
  2. Add browser tracingIn frontend apps, add browserTracingIntegration so page loads, navigations and requests become spans.
  3. Propagate to your APIList your API's URL in tracePropagationTargets and allow the sentry-trace and baggage headers in its CORS configuration.
  4. Check one traceLoad a page and open its trace in Sentry; the backend's spans should sit under the browser's request span.
  5. Query and alertIn Explore > Traces, chart p95(span.duration) grouped by transaction and save it as a monitor.

Traces, spans and transactions

TermWhat it is
SpanOne unit of work with a start, a duration, an op (such as http.client or db), a description, a status and a parent span
TraceAll spans that share a trace_id: one user action followed through every service it touched
TransactionThe legacy name for the top span of one service in a trace. Sentry's current tools call these service spans; search them with is_transaction:true

When a span in one service causes work in another, the first span becomes the parent of the second service's root span. That parent link is what turns a browser trace and an API trace into one waterfall, and it is what Sentry's performance issues, such as the N+1 query detector, read.

Turn on tracing in the SDK

Tracing is on when you set tracesSampleRate (a number from 0 to 1) or tracesSampler. In the browser, add browserTracingIntegration to get page loads, navigations and requests automatically:

import * as Sentry from "@sentry/browser";

Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 0.2, // 20% of traces
  // Which outgoing requests get trace headers
  tracePropagationTargets: ["localhost", /^https:\/\/api\.example\.com/],
});

// A custom span; it ends when the callback (or its promise) finishes
await Sentry.startSpan(
  { name: "Charge payment provider", op: "payment.charge",
    attributes: { "payment.provider": provider.name } },
  async () => provider.charge(order),
);

In Python, sentry_sdk.init(traces_sample_rate=0.2) is enough for Django, FastAPI, Flask, Starlette and the other framework integrations to create spans and continue incoming traces.

One trap: tracesSampleRate: 0 doesn't turn tracing off. Tracing stays on and sends nothing. To disable it, leave both options out.

Distributed tracing: sentry-trace and baggage headers

Sentry links services by adding two headers to outgoing requests and reading them on the way in:

  • sentry-trace: <trace_id>-<span_id>-<sampled>, for example 12345678901234567890123456789012-1234567890123456-1
  • baggage: sentry-trace_id=…,sentry-sample_rate=0.2,sentry-sampled=true,…

Which requests get them is set by tracePropagationTargets. Strings match when the URL contains them, regular expressions are tested against the URL, and [] turns propagation off. The defaults differ, and that is the most common reason a trace stops at the browser:

SDKDefault targets
Browser JavaScriptSame-origin requests only
Python (trace_propagation_targets)['.*'], every request

So a frontend on app.example.com calling api.example.com sends no headers until you add the API to the list. Once you do, the API's CORS allowlist must accept sentry-trace and baggage, or the browser blocks the request. Proxies and gateways must not strip them, and if your API uses a port, include the port in the target.

For server-rendered pages, the server writes <meta name="sentry-trace"> and <meta name="baggage"> tags into the HTML so the page load joins the server's trace. To interoperate with OpenTelemetry services, propagateTraceparent: true (JavaScript SDK 10.10.0 and later) also sends the W3C traceparent header. In Python, strict_trace_continuation=True only continues incoming traces whose org_id matches yours, which stops a third party's headers from joining your traces.

Sampling: tracesSampleRate vs tracesSampler

Sentry samples at the head: the first service decides and every downstream service follows that decision, so a trace is complete or absent, never half there. tracesSampler takes precedence over tracesSampleRate, and a parent's decision comes before the rate. Use the sampler to spend your quota on the traffic that matters:

tracesSampler: ({ name, inheritOrSampleWith }) => {
  if (name.includes("healthcheck")) return 0;   // never
  if (name.includes("checkout")) return 1;      // always
  return inheritOrSampleWith(0.1);              // follow upstream, else 10%
},

inheritOrSampleWith arrived in version 9 of the JavaScript SDK; older versions read parentSampled. Returning a hard number for a span that has a parent overrides the upstream decision and breaks distributed traces, which is the mistake people make right after writing their first sampler.

Explore weights each span by the inverse of its sample rate, so a span kept at 10% counts as 10. Counts and percentiles are extrapolated, and Sentry shows a warning when the rate is too low for the numbers to be reliable.

Query spans in Explore

Explore > Traces searches every span, not only top-level ones. Filter, choose an aggregate under Visualize, and group:

QuestionFilterVisualize / group by
Slow page loadsspan.op:pageloadp90(span.duration) by transaction
Slow third-party callsspan.op:http.clientavg(span.duration) by span.description
Database hotspotsspan.op:dbp95(span.duration) by db.table
JavaScript blocking the UIspan.op:ui.long-animation-framemax(span.duration), sorted by duration

Triagebell Explore aggregates: p95 span duration and count grouped by transaction, with a chart per endpoint

The Aggregates tab lists the groups, and each row links to sample traces and the waterfall. Save as stores the query (saved queries are shared across Explore), adds it to a dashboard or creates a monitor. A monitor on p95(span.duration) > 2s for span.op:http.client catches a slow dependency. Use p75, p90 or p95 rather than averages, which hide outliers.

What tracing costs (as of November 2026)

Tracing is billed in spans. Developer, Team and Business each include 5M spans a month. Beyond that:

Spans per monthTeam PAYGTeam reservedBusiness PAYGBusiness reserved
5M to 100M$2.00 per million$1.60 per million$4.00 per million$3.20 per million
over 100M$1.80 per million$1.40 per million$3.60 per million$2.90 per million

Worked example: a Team org sending 25M spans a month pays for 20M extra, which is $40 on PAYG. A page load with 60 resource and request spans uses quota 60 times faster than a backend request with one span, so lower the rate for chatty frontends with tracesSampler before you cut backend traces. See Sentry pricing for the rest of the plan.

Questions

What is the difference between Sentry tracing and Sentry performance monitoring?

Performance monitoring is Sentry's older name for the same data. Current plans bill tracing in spans, and you query it in Explore > Traces.

Why are my frontend and backend in separate traces?

The browser only sends trace headers to same-origin URLs by default. Add your API to tracePropagationTargets and allow sentry-trace and baggage in its CORS allowlist.

Does Sentry support OpenTelemetry trace headers?

The JavaScript SDK can also send the W3C traceparent header with propagateTraceparent: true, from version 10.10.0. Your backend's CORS rules must allow it.

Sources

  1. Set Up Tracingdocs.sentry.io
  2. Set Up Distributed Tracingdocs.sentry.io
  3. Trace Explorerdocs.sentry.io
  4. Pricing & Billingdocs.sentry.io