### ASP.NET Core Setup with Sentry Tracing and Profiling
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/profiling.md
Complete setup example for an ASP.NET Core application using Sentry SDK. Configures DSN, environment, release, sampling rates for tracing and profiling, and integrates profiling with a timeout.
```csharp
// Program.cs — ASP.NET Core with tracing + profiling
using Sentry;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseSentry(options =>
{
options.Dsn = "https://examplePublicKey@o0.ingest.sentry.io/0";
options.Environment = builder.Environment.EnvironmentName;
options.Release = "my-app@1.2.3";
// Tracing: sample 10% of requests in production
options.TracesSampleRate = builder.Environment.IsProduction() ? 0.1 : 1.0;
// Profiling: profile 50% of sampled transactions
// Net result: 5% of all production requests are profiled
options.ProfilesSampleRate = 0.5;
// Block up to 500ms so early-startup transactions aren't missed
options.AddProfilingIntegration(TimeSpan.FromMilliseconds(500));
});
var app = builder.Build();
app.UseSentry();
app.MapControllers();
app.Run();
```
--------------------------------
### Source Maps Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/react-features.md
Guides on setting up source maps for various build tools and manual upload.
```APIDOC
## Source Maps Setup
### Automated Setup
Use the Sentry wizard for an automated setup process:
```bash
npx @sentry/wizard@latest -i sourcemaps
```
### Vite Configuration
Ensure `build.sourcemap` is set to `"hidden"` and include the `sentryVitePlugin()` in your `vite.config.js`.
```javascript
// vite.config.js
import sentryVitePlugin from '@sentry/vite-plugin';
export default {
// ...
build: {
sourcemap: 'hidden' // Enable source maps
},
plugins: [
// ...
sentryVitePlugin()
]
};
```
### Webpack Configuration
Set `devtool` to `"hidden-source-map"` and include `sentryWebpackPlugin()`.
```javascript
// webpack.config.js
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
module.exports = {
// ...
devtool: 'hidden-source-map',
plugins: [
// ...
new SentryWebpackPlugin({
// options
})
]
};
```
### Create React App (CRACO)
Use CRACO to configure `sentryWebpackPlugin()`.
### Manual Upload
Upload source maps manually using the Sentry CLI:
```bash
npx sentry-cli sourcemaps upload --auth-token $TOKEN ./dist
```
```
--------------------------------
### Install Sentry Wizard (macOS)
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/SKILL.md
Use Homebrew to install the Sentry Wizard for interactive setup. This is the recommended method for beginners.
```bash
brew install getsentry/tools/sentry-wizard && sentry-wizard -i ios
```
--------------------------------
### Session Replay Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/session-replay.md
Example of how to initialize the Sentry SDK with Session Replay integration in your client-side instrumentation file.
```APIDOC
## Setup
Session Replay is bundled in `@sentry/nextjs` — no separate package needed.
```typescript
// instrumentation-client.ts ← client-side only
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
// Sample rates live at init level, NOT inside replayIntegration()
replaysSessionSampleRate: 0.1, // record 10% of all sessions from start
replaysOnErrorSampleRate: 1.0, // record 100% of sessions that hit an error
integrations: [
Sentry.replayIntegration({
maskAllText: true, // default: true
blockAllMedia: true, // default: true
}),
],
});
```
> **Dev tip:** Set `replaysSessionSampleRate: 1.0` during development to capture every session.
### Where NOT to Add Replay
| Config file | Why |
|-------------|-----|
| `sentry.server.config.ts` | Server runtime — no DOM |
| `sentry.edge.config.ts` | Edge runtime — no DOM |
| `instrumentation.ts` (server section) | Server-side code |
| Any Route Handler or Server Action | Server-side code |
```
--------------------------------
### Asynchronous Profiling Integration Startup (Problematic)
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/profiling.md
This example demonstrates a potential issue where the profiler might not be ready when the first transaction starts due to asynchronous initialization. Use the synchronous startup method for critical early transactions.
```csharp
// ❌ Problem: profiler may not be ready when first transaction starts
SentrySdk.Init(options => {
options.AddProfilingIntegration(); // async startup
});
var tx = SentrySdk.StartTransaction("startup", "init"); // profiler might miss this
```
--------------------------------
### Full Example with Common Options
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/tracing.md
A comprehensive example demonstrating the integration of `browserTracingIntegration` with various common configuration options.
```APIDOC
```typescript
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
environment: import.meta.env.MODE,
integrations: [
Sentry.browserTracingIntegration({
// Lifecycle
idleTimeout: 1000,
finalTimeout: 30_000,
childSpanTimeout: 15_000,
markBackgroundSpan: true,
// HTTP spans
traceFetch: true,
traceXHR: true,
enableHTTPTimings: true,
shouldCreateSpanForRequest: (url) =>
!url.includes("/health") && !url.includes("/__webpack_hmr"),
onRequestSpanStart: (span, { headers }) => {
const rid = headers?.["x-request-id"];
if (rid) span.setAttribute("request.id", rid);
},
// Performance observations
enableLongTask: true,
enableLongAnimationFrame: true, // SDK ≥8.18.0
enableInp: true,
interactionsSampleRate: 1.0,
// Span naming
beforeStartSpan: (context) => ({
...context,
name: context.name.replace(/\/\d+/g, "/"),
}),
// Filtering
ignoreResourceSpans: ["resource.css"],
// Trace linking
linkPreviousTrace: "in-memory",
}),
],
tracesSampleRate: 1.0,
tracePropagationTargets: ["localhost", /^https:\/\/api\.myapp\.com/],
});
```
```
--------------------------------
### Prompt Template: Sentry SDK Setup & Configuration Research
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-sdk-skill-creator/references/research-playbook.md
Template for researching Sentry SDK setup and configuration, including installation, init function, options, environment variables, integrations, and debug mode.
```text
Research the Sentry SDK setup and configuration. Visit these pages
and extract ALL technical details:
1. https://docs.sentry.io/platforms// — main setup page
2. https://docs.sentry.io/platforms//configuration/ — configuration
3. https://docs.sentry.io/platforms//configuration/options/ — init options
Document:
- Installation command (package manager)
- Init function full configuration with ALL options
- Options struct/object fields with types and defaults
- Environment variables the SDK reads
- Framework integrations — how to detect and configure each
- Flush/shutdown patterns
- Debug mode
- Release/environment detection
Include exact code examples. Accuracy matters more than brevity.
```
--------------------------------
### Full Configuration Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/references/user-feedback.md
An example demonstrating the complete configuration of the Sentry SDK, including user feedback settings, theme customization, and event handlers.
```APIDOC
## Full Configuration Example
### Description
This example shows how to configure the Sentry SDK with various options, including user feedback settings, theme customization, and event callbacks.
### Code Example
```swift
import Sentry
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.configureUserFeedback { config in
config.showFormForScreenshots = true
config.useShakeGesture = false
config.animations = true
config.configureForm { form in
form.formTitle = "Report a Bug"
form.submitButtonLabel = "Send Bug Report"
form.isNameRequired = true
form.isEmailRequired = false
form.showBranding = false
form.useSentryUser = true
}
config.configureWidget { widget in
widget.labelText = "Report a Bug"
widget.location = [.bottom, .trailing]
widget.autoInject = true
}
config.theme { theme in
theme.submitBackground = .init(color: .systemBlue)
}
config.darkTheme { theme in
theme.background = .init(color: .black)
}
config.onFormOpen = { print("Feedback form opened") }
config.onFormClose = { print("Feedback form closed") }
config.onSubmitSuccess = { data in
print("✅ Feedback: \(data["message"] ?? "")
}
config.onSubmitError = { error in
print("❌ Submission failed: \(error)")
}
}
}
```
```
--------------------------------
### Node.js Runtime Configuration Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/tracing.md
Example of initializing the Sentry SDK in a Node.js environment with tracing enabled, including a custom tracesSampler.
```APIDOC
```typescript
// sentry.server.config.ts (Node.js)
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
tracesSampler: ({ name, inheritOrSampleWith }) => {
if (name.includes("healthcheck")) return 0;
return inheritOrSampleWith(0.1);
},
});
```
```
--------------------------------
### Edge Runtime Configuration Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/tracing.md
Example of initializing the Sentry SDK in an Edge runtime environment with basic tracing configuration.
```APIDOC
```typescript
// sentry.edge.config.ts (Edge)
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 0.1,
});
```
```
--------------------------------
### Install Sentry Go SDK for Gin
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package for integrating with the Gin web framework in Go.
```bash
go get github.com/getsentry/sentry-go/gin # Gin
```
--------------------------------
### Starting and Managing Transactions
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/tracing.md
Demonstrates how to start a root transaction, link errors to it, and finish transactions with different statuses.
```APIDOC
## Start a root transaction
```csharp
var tx = SentrySdk.StartTransaction("name", "operation");
SentrySdk.ConfigureScope(s => s.Transaction = tx); // link errors + enable auto-spans
```
## Finish variants
```csharp
tx.Finish(); // implicit Ok
tx.Finish(SpanStatus.InternalError); // explicit status
tx.Finish(exception); // auto-maps exception → SpanStatus
```
```
--------------------------------
### Install Sentry SvelteKit SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-svelte-sdk/SKILL.md
Install the Sentry SvelteKit SDK using npm.
```bash
npm install @sentry/sveltekit --save
```
--------------------------------
### Install Sentry.Extensions.Logging
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/logging.md
Install the `Sentry.Extensions.Logging` package using the .NET CLI to integrate Sentry with Microsoft.Extensions.Logging.
```shell
dotnet add package Sentry.Extensions.Logging
```
--------------------------------
### Install sentry-react SDK
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Install the Sentry SDK for React applications using npm.
```bash
npm install @sentry/react --save
```
--------------------------------
### Install Sentry SDK Core and Extras
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-python-sdk/SKILL.md
Install the core Sentry SDK for Python. Optional extras can be installed based on your detected framework to enable specific integrations.
```bash
# Core SDK (always required)
pip install sentry-sdk
# Optional extras (install only what matches detected framework):
pip install "sentry-sdk[django]"
pip install "sentry-sdk[flask]"
pip install "sentry-sdk[fastapi]"
pip install "sentry-sdk[celery]"
pip install "sentry-sdk[aiohttp]"
pip install "sentry-sdk[tornado]"
# Multiple extras:
pip install "sentry-sdk[django,celery]"
```
--------------------------------
### Install Sentry Go SDK for FastHTTP
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package for integrating with the FastHTTP framework in Go.
```bash
go get github.com/getsentry/sentry-go/fasthttp # FastHTTP
```
--------------------------------
### Install Sentry Go SDK for net/http
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package specifically for instrumenting the standard Go net/http package.
```bash
# Framework sub-package — install only what matches detected framework:
go get github.com/getsentry/sentry-go/http # net/http
```
--------------------------------
### Install Sentry Go SDK for Zerolog
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package for automatic log capture when using the Zerolog library.
```bash
go get github.com/getsentry/sentry-go/zerolog # Zerolog
```
--------------------------------
### Basic Metrics Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/references/metrics.md
A practical example demonstrating how to use the `Meter` API to record `Count`, `Gauge`, and `Distribution` metrics with associated attributes and units.
```APIDOC
## Basic Metrics Example
This example shows how to initialize the SDK, create a meter, and record different types of metrics with attributes and units.
```go
import (
"context"
"time"
"github.com/getsentry/sentry-go"
"github.com/getsentry/sentry-go/attribute"
)
func main() {
sentry.Init(sentry.ClientOptions{Dsn: os.Getenv("SENTRY_DSN")})
defer sentry.Flush(2 * time.Second)
meter := sentry.NewMeter(context.Background())
// Counter — integer increments
meter.Count("emails.sent", 3,
sentry.WithAttributes(
attribute.String("provider", "sendgrid"),
attribute.Bool("transactional", true),
),
)
// Gauge — current snapshot value
meter.Gauge("queue.depth", 142.0,
sentry.WithAttributes(
attribute.String("queue.name", "orders"),
),
)
// Distribution — histogram / percentile-friendly samples
meter.Distribution("api.response_time", 187.5,
sentry.WithUnit(sentry.UnitMillisecond),
sentry.WithAttributes(
attribute.String("endpoint", "/checkout"),
attribute.String("method", "POST"),
),
)
}
```
```
--------------------------------
### showDialog and dialogOptions Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/error-monitoring.md
Example of enabling and configuring the built-in user feedback dialog using `showDialog` and `dialogOptions` props.
```APIDOC
#### `showDialog` + `dialogOptions` — Crash-Report Modal on Error
```jsx
We've logged this issue and are working on a fix.
}>
```
```
--------------------------------
### Install Sentry Go SDK for Fiber
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package for integrating with the Fiber web framework in Go.
```bash
go get github.com/getsentry/sentry-go/fiber # Fiber
```
--------------------------------
### Core Setup with browserTracingIntegration
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/tracing.md
This snippet shows the basic setup for Sentry React SDK, including enabling `browserTracingIntegration` and configuring `tracesSampleRate` and `tracePropagationTargets`.
```APIDOC
## Core Setup
```typescript
// src/instrument.ts (imported FIRST in main.tsx / index.tsx)
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
environment: import.meta.env.MODE,
integrations: [
Sentry.browserTracingIntegration(),
],
// Tracing sample rates
tracesSampleRate: 1.0, // 100% in dev; lower to 0.1–0.2 in production
// Which outgoing requests get sentry-trace + baggage headers
tracePropagationTargets: [
"localhost",
/^https:\/\/api\.yourapp\.com/,
],
});
```
> **To disable tracing entirely:** omit both `tracesSampleRate` and `tracesSampler`. Setting `tracesSampleRate: 0` is **not** the same — the integration still runs, it just doesn't send data.
```
--------------------------------
### Install Sentry Next.js SDK
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Install the Sentry Next.js SDK using npm. This is the first step for integrating Sentry into your project.
```bash
npm install @sentry/nextjs --save
```
--------------------------------
### Install Core Sentry Go SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the fundamental sentry-go SDK package, which is always required for Sentry integration in Go applications.
```bash
# Core SDK (always required)
go get github.com/getsentry/sentry-go
```
--------------------------------
### onMount and onUnmount Lifecycle Hooks Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/error-monitoring.md
Example of using the `onMount` and `onUnmount` lifecycle hooks for tracking component lifecycle events.
```APIDOC
#### `onMount` / `onUnmount` — Lifecycle Hooks
```jsx
analytics.track("error_boundary_mounted", { section: "dashboard" })}
onUnmount={(error) => {
if (error) analytics.track("error_boundary_active_on_unmount");
}}
fallback={}>
```
```
--------------------------------
### Basic Sentry SDK Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/references/error-monitoring.md
Initializes the Sentry SDK with essential client options. Ensure the SENTRY_DSN and SENTRY_ENVIRONMENT variables are set. The `release` variable should be injected via linker flags. A deferred `sentry.Flush` call is crucial to ensure events are sent before the application exits.
```go
import (
"log"
"os"
"time"
"github.com/getsentry/sentry-go"
)
func main() {
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
Environment: os.Getenv("SENTRY_ENVIRONMENT"),
Release: release, // inject via -ldflags
AttachStacktrace: true,
SendDefaultPII: true,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
}
defer sentry.Flush(2 * time.Second)
}
```
--------------------------------
### Install zap integration for Sentry Go SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/references/logging.md
Use 'go get' to install the zap integration package for the Sentry Go SDK. This package allows you to send logs from zap to Sentry.
```bash
go get github.com/getsentry/sentry-go/zap
```
--------------------------------
### Manual lifecycle setup and operation
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/references/profiling.md
Configure Sentry SDK for manual profiling lifecycle and demonstrate how to start and stop the profiler around a specific operation. The profiler runs only between explicit start and stop calls.
```swift
import Sentry
SentrySDK.start {
options.dsn = "___PUBLIC_DSN___"
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .manual // default if omitted
}
}
// Profile a specific operation
@IBAction func onSyncTapped() {
SentrySDK.startProfiler()
URLSession.shared.dataTask(with: syncRequest) { data, _, _ in
self.processData(data)
DispatchQueue.main.async {
self.tableView.performBatchUpdates({
// update cells
}) {
SentrySDK.stopProfiler()
}
}
}.resume()
}
```
--------------------------------
### Start Spotlight UI
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-ruby-sdk/SKILL.md
Launches the Spotlight UI for local development, allowing you to visualize traces and events without a DSN.
```bash
npx @spotlightjs/spotlight
```
--------------------------------
### Production Recommended Setup (Continuous Profiling)
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-python-sdk/references/profiling.md
A recommended configuration for production environments using continuous profiling. It samples 10% of transactions and profiles all sampled sessions, with the SDK managing the profiler lifecycle.
```python
import sentry_sdk
import signal
sentry_sdk.init(
dsn="https://@.ingest.sentry.io/",
environment="production",
release="my-app@2.0.0",
traces_sample_rate=0.1, # sample 10% of transactions
profile_session_sample_rate=1.0, # profile all sampled sessions
profile_lifecycle="trace",
)
```
--------------------------------
### Basic setup with trace lifecycle
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/references/profiling.md
Configure Sentry SDK with UI Profiling enabled using the trace lifecycle. Ensure tracing is also enabled. This is the recommended setup.
```swift
import Sentry
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
// Tracing must be enabled for .trace lifecycle
options.tracesSampleRate = 1.0
options.configureProfiling = {
$0.sessionSampleRate = 1.0 // 100% of sessions; lower for production
$0.lifecycle = .trace // profiler runs while a root span is active
}
}
```
--------------------------------
### Attaching to an Active Transaction
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/tracing.md
Get the current span from the scope, or start a new root transaction if none exists. This allows for nested or independent tracing.
```csharp
public async Task DoSomethingAsync()
{
var activeSpan = SentrySdk.GetSpan();
if (activeSpan == null)
{
// No transaction in scope — start a new root transaction
activeSpan = SentrySdk.StartTransaction("task", "background-job");
}
else
{
// Transaction already running — add a child
activeSpan = activeSpan.StartChild("subtask");
}
// ... work ...
activeSpan.Finish();
}
```
--------------------------------
### Browser Profiling Setup with Sentry Next.js SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/profiling.md
Configure browser profiling for your Next.js application. Ensure `browserProfilingIntegration()` is included in your `Sentry.init` call. This example is for `instrumentation-client.ts`.
```typescript
// instrumentation-client.ts (Browser)
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.browserProfilingIntegration(),
],
tracesSampleRate: process.env.NODE_ENV === "development" ? 1.0 : 0.1,
profileSessionSampleRate: process.env.NODE_ENV === "development" ? 1.0 : 0.1,
profileLifecycle: "trace",
});
```
--------------------------------
### Basic Tracing Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/references/tracing.md
Configure the Sentry SDK with a DSN and set a uniform traces sample rate for performance monitoring. Use a lower rate for production.
```swift
import Sentry
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.tracesSampleRate = 1.0 // 100% in dev; lower for production (e.g., 0.2)
}
```
--------------------------------
### Reference File Structure
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-sdk-skill-creator/references/philosophy.md
Structure reference files with essential sections like Installation, Configuration, Code Examples, Best Practices, and Troubleshooting for a specific feature and platform.
```markdown
# — SDK
> Minimum SDK: `@X.Y.Z+`
## Installation
## Configuration
## Code Examples
### Basic usage
### Framework-specific notes (if applicable)
## Best Practices
## Troubleshooting
| Issue | Solution |
|-------|----------|
```
--------------------------------
### Configure Transaction-based Profiling
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-python-sdk/references/profiling.md
Use this for simple setups or short-lived transactions. Profiles start with the transaction and stop after 30 seconds or when the transaction ends. Ensure `traces_sample_rate` is greater than 0.
```python
import sentry_sdk
sentry_sdk.init(
dsn="https://@.ingest.sentry.io/",
traces_sample_rate=1.0,
profiles_sample_rate=1.0, # relative to traces_sample_rate
# e.g. profiles_sample_rate=0.5 → profiles 50% of sampled transactions
)
```
--------------------------------
### Load Function Tracing (SvelteKit)
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-svelte-sdk/references/tracing.md
Details how SvelteKit load functions are automatically instrumented for tracing with `@sentry/sveltekit` version 10.8.0 and later. Provides legacy setup examples for older versions.
```APIDOC
## Load Function Tracing (SvelteKit)
With `sentryHandle()` (≥10.8.0), all load functions are automatically instrumented. No wrapper needed.
**Legacy setup only** (if using `@sentry/sveltekit` <10.8.0):
```typescript
// src/routes/+page.ts (client load) — legacy only
import { wrapLoadWithSentry } from "@sentry/sveltekit";
export const load = wrapLoadWithSentry(async ({ fetch, params }) => {
return { data: await fetch(`/api/${params.id}`).then(r => r.json()) };
});
// src/routes/+page.server.ts (server load) — legacy only
import { wrapServerLoadWithSentry } from "@sentry/sveltekit";
export const load = wrapServerLoadWithSentry(async ({ params }) => {
return { id: params.id };
});
```
Remove these wrappers when upgrading to `@sentry/sveltekit` ≥10.8.0.
```
--------------------------------
### Browser Runtime Configuration Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/tracing.md
Example of initializing the Sentry SDK in a browser environment with tracing enabled, including custom span creation logic and trace propagation targets.
```APIDOC
```typescript
// instrumentation-client.ts (Browser)
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
environment: process.env.NODE_ENV,
integrations: [
Sentry.browserTracingIntegration({
shouldCreateSpanForRequest: (url) => !url.match(///health$/),
}),
],
tracesSampler: ({ name, inheritOrSampleWith }) => {
if (name.includes("health")) return 0;
if (name.includes("/checkout")) return 1.0;
return inheritOrSampleWith(0.1);
},
tracePropagationTargets: [
"localhost",
/^https:\/\/api\.myapp\.com/,
],
});
```
```
--------------------------------
### Automatic Performance Tracing Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-native-sdk/references/tracing.md
Enable automatic performance tracing by adding the reactNativeTracingIntegration to Sentry.init and wrapping your root component with Sentry.wrap for accurate app start and user interaction measurements.
```typescript
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_DSN",
tracesSampleRate: 1.0,
integrations: [
Sentry.reactNativeTracingIntegration(),
],
});
```
```typescript
// App.tsx
export default Sentry.wrap(App);
```
```typescript
Sentry.init({
dsn: "YOUR_DSN",
enableAutoPerformanceTracing: false, // disables all auto instrumentation
});
```
--------------------------------
### Node.js Profiling Setup with Sentry Next.js SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/references/profiling.md
Configure server-side profiling for your Next.js application using Node.js. This requires importing and including `nodeProfilingIntegration()` in your `Sentry.init` call. This example is for `sentry.server.config.ts`.
```typescript
// sentry.server.config.ts (Node.js)
import * as Sentry from "@sentry/nextjs";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
tracesSampleRate: process.env.NODE_ENV === "development" ? 1.0 : 0.1,
profileSessionSampleRate: process.env.NODE_ENV === "development" ? 1.0 : 0.1,
profileLifecycle: "trace",
});
```
--------------------------------
### Full User Feedback Configuration Example
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-cocoa-sdk/references/user-feedback.md
A comprehensive example demonstrating how to configure the Sentry SDK for user feedback. This includes setting the DSN, enabling/disabling features like shake gestures and animations, customizing form and widget properties, and defining callbacks for form events.
```swift
import Sentry
SentrySDK.start {
options.dsn = "___PUBLIC_DSN___"
options.configureUserFeedback {
config.showFormForScreenshots = true
config.useShakeGesture = false
config.animations = true
config.configureForm {
form.formTitle = "Report a Bug"
form.submitButtonLabel = "Send Bug Report"
form.isNameRequired = true
form.isEmailRequired = false
form.showBranding = false
form.useSentryUser = true
}
config.configureWidget {
widget.labelText = "Report a Bug"
widget.location = [.bottom, .trailing]
widget.autoInject = true
}
config.theme {
theme.submitBackground = .init(color: .systemBlue)
}
config.darkTheme {
theme.background = .init(color: .black)
}
config.onFormOpen = { print("Feedback form opened") }
config.onFormClose = { print("Feedback form closed") }
config.onSubmitSuccess = { data in
print("✅ Feedback: \(data["message"] ?? "")
}
config.onSubmitError = { error in
print("❌ Submission failed: \(error)")
}
}
}
```
--------------------------------
### React Router v6/v7 Browser Tracing Setup
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/SKILL.md
Integrate Sentry's browser tracing for React Router v6 and v7. This example shows how to wrap createBrowserRouter or use the integration with hooks.
```typescript
// in instrument.ts integrations array:
import React from "react";
import {
createRoutesFromChildren,
matchRoutes,
useLocation,
useNavigationType,
} from "react-router-dom"; // or "react-router" for v7
import * as Sentry from "@sentry/react";
import { reactRouterV6BrowserTracingIntegration } from "@sentry/react";
import { createBrowserRouter } from "react-router-dom";
// Option A — createBrowserRouter (recommended for v6.4+):
const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV6(createBrowserRouter);
const router = sentryCreateBrowserRouter([...routes]);
// Option B — createBrowserRouter for React Router v7:
// const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV7(createBrowserRouter);
// Option C — integration with hooks (v6 without data APIs):
Sentry.init({
integrations: [
reactRouterV6BrowserTracingIntegration({
useEffect: React.useEffect,
useLocation,
useNavigationType,
matchRoutes,
createRoutesFromChildren,
}),
],
});
```
--------------------------------
### Run Sentry Wizard for Next.js
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-nextjs-sdk/SKILL.md
Use the Sentry wizard to automatically configure your Next.js project. It handles login, project selection, auth token setup, SDK installation, and file creation.
```bash
npx @sentry/wizard@latest -i nextjs
```
--------------------------------
### Wizard-First Pattern for Framework SDKs
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-sdk-skill-creator/references/philosophy.md
Demonstrates the recommended pattern for skills supporting a framework SDK wizard, emphasizing its use before manual instructions.
```markdown
Pattern for skills with wizard support:
```
--------------------------------
### Install Sentry Next.js SDK using Wizard
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Use the Sentry wizard to automatically configure the Sentry SDK for Next.js applications. This method handles authentication, organization/project setup, and source map uploads.
```bash
# Option 1: Wizard (Recommended — handles auth, org/project, source maps automatically)
npx @sentry/wizard@latest -i nextjs
```
--------------------------------
### Go pprof Integration with HTTP
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/references/profiling.md
This example demonstrates how to integrate the standard Go `pprof` package to expose profiling endpoints on an HTTP server. Ensure the `net/http/pprof` package is imported.
```go
import _ "net/http/pprof"
// Exposes /debug/pprof/ on your HTTP server
http.ListenAndServe(":6060", nil)
```
--------------------------------
### Route-Based Session Replay Recording with React Router
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/session-replay.md
Implement route-based recording using React Router. This example starts replay recording for '/checkout' paths and stops it for others, ensuring selective data capture.
```typescript
Sentry.init({
dsn: "...",
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
integrations: [Sentry.replayIntegration()],
});
// React Router example: only record checkout flow
import { useLocation } from 'react-router-dom';
import { useEffect } from 'react';
function ReplayController() {
const location = useLocation();
useEffect(() => {
const replay = Sentry.getReplay();
const isCheckout = location.pathname.startsWith('/checkout');
if (isCheckout && !replay.getReplayId()) {
replay.start();
} else if (!isCheckout && replay.getReplayId()) {
replay.stop();
}
}, [location.pathname]);
return null;
}
```
--------------------------------
### Basic Sentry Profiling Setup for React Native
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-native-sdk/references/tracing.md
Enable profiling by setting `profilesSampleRate` relative to `tracesSampleRate`. A transaction must be sampled for tracing before profiling can be applied. This example shows 100% tracing and profiling for development.
```typescript
Sentry.init({
dsn: "YOUR_DSN",
tracesSampleRate: 1.0, // 100% traced
profilesSampleRate: 1.0, // 100% of traced → 100% profiled (dev/testing only)
// Production example:
// tracesSampleRate: 0.2, // 20% traced
// profilesSampleRate: 0.5, // 50% of those → 10% of all transactions profiled
});
```
--------------------------------
### Initialize Sentry Go SDK with Gin
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Recommended initialization for the Sentry Go SDK, including Gin framework integration. Ensure this is added before any other code.
```go
// main.go — recommended init (add before any other code)
import (
"log"
"os"
"time"
"github.com/getsentry/sentry-go"
sentrygin "github.com/getsentry/sentry-go/gin"
"github.com/gin-gonic/gin"
)
var release string // set via -ldflags="-X main.release=myapp@$(git describe --tags)"
func main() {
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
Environment: os.Getenv("SENTRY_ENVIRONMENT"),
Release: release,
SendDefaultPII: true,
AttachStacktrace: true,
EnableTracing: true,
TracesSampleRate: 1.0, // lower to 0.1 in production
EnableLogs: true,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
}
defer sentry.Flush(2 * time.Second)
router := gin.Default()
router.Use(sentrygin.New(sentrygin.Options{Repanic: true}))
router.GET("/ping", func(c *gin.Context) {
hub := sentrygin.GetHubFromContext(c)
hub.Scope().SetTag("endpoint", "ping")
c.JSON(200, gin.H{"message": "pong"})
})
router.Run(":8080")
}
// Verify: triggers an error event in the Sentry dashboard
// sentry.CaptureMessage("Sentry Go SDK test")
```
--------------------------------
### Create New SDK Skill Bundle - Phase 1 & 2
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Commands for identifying existing SDK skill bundles and initiating research tasks for new ones. Includes a quality gate check for research files.
```bash
# Phase 1: Identify feature matrix
ls skills/sentry-*-sdk/ # review existing bundles for quality reference
```
```bash
# Phase 2: Research (run parallel research tasks per feature area)
# Each task visits official Sentry docs + SDK GitHub repo, writes to a file
# research/mysdk-setup-config.md
# research/mysdk-error-monitoring.md
# research/mysdk-tracing-profiling.md
# research/mysdk-logging-metrics-crons.md
```
```bash
# Quality gate — each file should have real content and code examples
for f in research/mysdk-*.md; do
echo "=== $(basename $f) ==="
wc -l "$f"
grep -c "^#" "$f" # should show multiple headings
done
# Re-run any task that produced fewer than 100 lines
```
--------------------------------
### Run Sentry Wizard CLI for React Native
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-native-sdk/SKILL.md
Use the Wizard CLI to automate the Sentry SDK setup, including login, project selection, authentication, installation, native configuration, source map upload, and initial Sentry.init().
```bash
npx @sentry/wizard@latest -i reactNative
```
--------------------------------
### Full Sentry React SDK Initialization with Tracing
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/tracing.md
This comprehensive example demonstrates initializing the Sentry React SDK with `browserTracingIntegration` and various common options, including lifecycle timeouts, HTTP span tracing, performance observations, span naming, filtering, and trace linking.
```typescript
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
environment: import.meta.env.MODE,
integrations: [
Sentry.browserTracingIntegration({
// Lifecycle
idleTimeout: 1000,
finalTimeout: 30_000,
childSpanTimeout: 15_000,
markBackgroundSpan: true,
// HTTP spans
traceFetch: true,
traceXHR: true,
enableHTTPTimings: true,
shouldCreateSpanForRequest: (url) =>
!url.includes("/health") && !url.includes("/__webpack_hmr"),
onRequestSpanStart: (span, { headers }) => {
const rid = headers?.["x-request-id"];
if (rid) span.setAttribute("request.id", rid);
},
// Performance observations
enableLongTask: true,
enableLongAnimationFrame: true, // SDK ≥8.18.0
enableInp: true,
interactionsSampleRate: 1.0,
// Span naming
beforeStartSpan: (context) => ({
...context,
name: context.name.replace(/\/\d+/g, "/"),
}),
// Filtering
ignoreResourceSpans: ["resource.css"],
// Trace linking
linkPreviousTrace: "in-memory",
}),
],
tracesSampleRate: 1.0,
tracePropagationTargets: ["localhost", /^https:\/\/api\.myapp\.com/],
});
```
--------------------------------
### Install Sentry Python SDK
Source: https://context7.com/getsentry/sentry-agent-skills/llms.txt
Install the Sentry SDK for Python using pip. Optional extras can be installed for specific frameworks like Django and Celery.
```bash
# Install
pip install sentry-sdk
pip install "sentry-sdk[django,celery]" # optional extras for your framework
```
--------------------------------
### Install All Sentry Agent Skills
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/README.md
Use this command to install all available Sentry agent skills via the skills CLI. Ensure you have Node.js and npm installed.
```bash
npx skills add https://github.com/getsentry/sentry-agent-skills
```
--------------------------------
### Install Sentry React Native SDK for Expo Managed
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-native-sdk/SKILL.md
Install the core Sentry React Native SDK package using the Expo install command for Expo managed projects.
```bash
npx expo install @sentry/react-native
```
--------------------------------
### SentrySdk.Init Configuration for Tracing
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-dotnet-sdk/references/tracing.md
Example of initializing the Sentry SDK with tracing-related options. This includes setting a uniform traces sample rate, defining a dynamic traces sampler, and specifying hosts for trace propagation.
```APIDOC
## `SentrySdk.Init` Configuration for Tracing
### Description
Initialize the Sentry SDK with tracing configurations. This example demonstrates setting a uniform sampling rate for traces, implementing a dynamic sampler based on transaction context, and defining specific hosts for trace propagation.
### Code Example
```csharp
SentrySdk.Init(options =>
{
// Tracing configuration
options.TracesSampleRate = 0.2; // 20% uniform rate
// OR dynamic sampler (takes precedence when set)
options.TracesSampler = ctx =>
{
if (ctx.TransactionContext.Name.Contains("/health")) return 0.0;
return 0.1;
};
// Restrict which outbound hosts receive trace headers (default: all)
options.TracePropagationTargets = new List
{
"api.mycompany.internal",
new StringOrRegex(new Regex(@"^https://.*\.mycompany\.com"))
};
// Disable diagnostic source integration (e.g., EF Core / SQLClient spans)
// options.DisableDiagnosticSourceIntegration();
// Use OpenTelemetry for trace context propagation
// options.UseOpenTelemetry();
});
```
### Key Options
- **`TracesSampleRate`**: `double?` - Uniform sampling rate between 0.0 and 1.0. Disabled if `null`.
- **`TracesSampler`**: `Func` - A dynamic sampler function that overrides `TracesSampleRate`. It receives transaction context and returns a sampling rate.
- **`TracePropagationTargets`**: `IList` - A list of hosts (strings or regular expressions) that will receive `sentry-trace` and `baggage` headers for trace propagation. Defaults to all hosts (`".*"`).
- **`DisableDiagnosticSourceIntegration()`**: Method - Opts out of automatic span creation for libraries like EF Core and SQLClient.
- **`UseOpenTelemetry()`**: Method - Enables trace context propagation using OpenTelemetry.
```
--------------------------------
### Full-Featured Sentry.init() Configuration
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-native-sdk/SKILL.md
Recommended Sentry SDK initialization with all features enabled, including tracing, profiling, session replay, and logging.
```typescript
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
sendDefaultPii: true,
// Tracing — lower to 0.1–0.2 in high-traffic production
tracesSampleRate: 1.0,
// Profiling — runs on a subset of traced transactions
profilesSampleRate: 1.0,
// Session Replay — always capture on error, sample 10% of all sessions
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
// Logging — enable Sentry.logger.* API
enableLogs: true,
// Integrations — mobile replay is opt-in
integrations: [
Sentry.mobileReplayIntegration({
maskAllText: true, // masks text by default for privacy
maskAllImages: true,
}),
],
// Native frames tracking (disable in Expo Go)
enableNativeFramesTracking: true,
// Environment
environment: __DEV__ ? "development" : "production",
// Release — set from CI or build system
// release: "my-app@1.0.0+1",
// dist: "1",
});
// REQUIRED: Wrap root component to capture React render errors
export default Sentry.wrap(App);
```
--------------------------------
### List Existing SDK Skill Directories
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-sdk-skill-creator/SKILL.md
List existing SDK skill directories to reference their patterns and quality.
```bash
ls skills/sentry-*-sdk/ 2>/dev/null
```
--------------------------------
### Fallback UI Examples
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-react-sdk/references/error-monitoring.md
Demonstrates how to configure the `fallback` prop with a static element or a render function.
```APIDOC
#### `fallback` — Render Fallback UI on Error
```jsx
// 1. Static element
Something went wrong. Please refresh.}>
// 2. Render function — access error details and reset handler
(
Something broke
Error: {error.message}
Component stack
{componentStack}
)}>
```
**`resetError()`** resets the boundary's internal state and re-attempts rendering children. Use it for retry UIs.
```
--------------------------------
### Initialize Sentry SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/references/crons.md
Initialize the Sentry SDK with a DSN. Always defer `sentry.Flush()` before program exit as check-ins are async.
```go
sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
})
defer sentry.Flush(2 * time.Second)
```
--------------------------------
### Install Sentry Svelte SDK for Plain Svelte
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-svelte-sdk/SKILL.md
Install the Sentry Svelte SDK for applications not using SvelteKit.
```bash
npm install @sentry/svelte --save
```
--------------------------------
### Manual API Verification Steps
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-sdk-skill-creator/references/research-playbook.md
Outlines manual steps for verifying API names and signatures against a specified SDK GitHub repository. This involves checking existence, correctness, and source URLs for listed APIs.
```text
Verify these specific API names and signatures against the GitHub repo
(). For each, state whether it EXISTS or NOT, the correct API if
different, and the source URL:
1.
2.
3.
...
```
--------------------------------
### Initialize Sentry Go SDK
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Initialize the Sentry SDK with essential options. Ensure this is called before any other Sentry-related code. The `Release` value should be injected at build time.
```go
import (
"log"
"os"
"time"
"github.com/getsentry/sentry-go"
)
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
Environment: os.Getenv("SENTRY_ENVIRONMENT"), // "production", "staging", etc.
Release: release, // inject via -ldflags at build time
SendDefaultPII: true,
AttachStacktrace: true,
// Tracing (adjust sample rate for production)
EnableTracing: true,
TracesSampleRate: 1.0, // lower to 0.1–0.2 in high-traffic production
// Logs
EnableLogs: true,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
}
defersentry.Flush(2 * time.Second)
```
--------------------------------
### Install Sentry Go SDK for Echo
Source: https://github.com/getsentry/sentry-agent-skills/blob/main/skills/sentry-go-sdk/SKILL.md
Installs the sentry-go sub-package for integrating with the Echo web framework in Go.
```bash
go get github.com/getsentry/sentry-go/echo # Echo
```