npx skills add ...
npx skills add getsentry/sentry-for-cursor --skill sentry-setup-tracing
Setup Sentry Tracing (Performance Monitoring) in any project. Use this when asked to add performance monitoring, enable tracing, track transactions/spans, or instrument application performance. Supports JavaScript, TypeScript, Python, Ruby, React, Next.js, and Node.js.
npx skills add getsentry/sentry-for-cursor --skill sentry-setup-tracing
This skill helps configure Sentry's Tracing (Performance Monitoring) to track application performance, measure latency, and create distributed traces across services.
Invoke this skill when:
tracesSampleRate or custom spansBefore configuring, detect the project's platform:
Check package.json for:
@sentry/nextjs - Next.js@sentry/react - React@sentry/node - Node.js@sentry/browser - Browser/vanilla JS@sentry/vue - Vue@sentry/angular - Angular@sentry/sveltekit - SvelteKitCheck for sentry-sdk in requirements
Check for sentry-ruby in Gemfile
Explain these concepts to the user:
| Concept | Description |
|---|---|
| Trace | Complete journey of a request across services |
| Transaction | Single instance of a service being called (root span) |
| Span | Individual unit of work within a transaction |
| Sample Rate | Percentage of transactions to capture (0-1) |
Find the Sentry.init() call:
instrumentation-client.ts, sentry.server.config.ts, sentry.edge.config.tssrc/index.tsx or entry fileClient (instrumentation-client.ts):
Server (sentry.server.config.ts):
Edge (sentry.edge.config.ts):
Next.js 14+ App Router Requirement:
For distributed tracing in App Router, add trace data to root layout metadata:
Note: If both tracesSampleRate and tracesSampler are set, tracesSampler takes precedence.
The browserTracingIntegration() accepts many configuration options:
Sentry propagates trace context via HTTP headers:
sentry-trace: Contains trace ID, span ID, sampling decisionbaggage: Contains additional trace metadataOnly URLs matching these patterns receive trace headers:
For SSR apps, inject trace data in HTML:
The browser SDK automatically reads these and continues the trace.
For non-HTTP channels (WebSockets, message queues):
Use consistent op values for better organization:
| Operation | Use Case |
|---|---|
http.client | Outgoing HTTP requests |
http.server | Incoming HTTP requests |
db | Database operations |
db.query | Database queries |
cache | Cache operations |
task | Background tasks |
function | Function execution |
ui.render | UI rendering |
ui.action | User interactions |
serialize | Serialization |
middleware | Middleware execution |
Important: Setting tracesSampleRate: 0 does NOT disable tracing - it still processes traces but never sends them.
To fully disable tracing, omit both sampling options:
| Traffic Level | Recommended Rate |
|---|---|
| Development/Testing | 1.0 (100%) |
| Low traffic (<1K req/min) | 0.5 - 1.0 |
| Medium traffic (1K-10K req/min) | 0.1 - 0.5 |
| High traffic (>10K req/min) | 0.01 - 0.1 |
Use dynamic sampling to capture more of important transactions:
After setup, verify tracing is working:
Check in Sentry:
Solutions:
tracesSampleRate > 0 or tracesSampler returns > 0browserTracingIntegration() is addedSolutions:
tracePropagationTargets includes your API URLssentry-trace and baggage headersSolutions:
tracesSampleRatetracesSampler to filter by transaction nameshouldCreateSpanForRequest to skip health checksSolutions:
startSpan callback pattern (not manual)parentSpanIsAlwaysRootSpan: false| Platform | Enable Tracing | Custom Span |
|---|---|---|
| JS/Browser | tracesSampleRate + browserTracingIntegration() | Sentry.startSpan() |
| Next.js | tracesSampleRate (auto-integrated) | Sentry.startSpan() |
| Node.js | tracesSampleRate | Sentry.startSpan() |
| Python | traces_sample_rate | @sentry_sdk.trace or start_span() |
| Ruby | traces_sample_rate | start_span() |
| Sampling Option | Purpose |
|---|---|
tracesSampleRate | Uniform percentage (0-1) |
tracesSampler | Dynamic function (takes precedence) |