chore: remove deprecated setup skills superseded by SDK bundles (#14)

* chore: remove deprecated setup skills superseded by SDK bundles

Remove sentry-ios-swift-setup, sentry-react-native-setup, sentry-setup-tracing,
sentry-setup-logging, and sentry-setup-metrics skills. These are now covered by
the full SDK bundle skills (sentry-cocoa-sdk, sentry-react-native-sdk, etc.)
which provide comprehensive platform-specific guidance.

Update README.md to remove all references: table rows, usage examples, and
directory structure examples (replaced sentry-setup-tracing with sentry-fix-issues).

* chore(release): generate skill list dynamically from SKILL.md frontmatter

Replace the hardcoded (and stale) skill list in the release workflow with a
script that reads name and description from each skills/*/SKILL.md frontmatter.
This ensures the release notes stay current as skills are added or removed.

Adds scripts/generate-skill-list.sh which extracts the first sentence of each
skill's description and formats it as a markdown list.
This commit is contained in:
Daniel Griesser
2026-02-26 22:07:05 +01:00
committed by GitHub
parent 76e5021158
commit 7d7fb4fcc8
8 changed files with 76 additions and 939 deletions
+31 -32
View File
@@ -26,6 +26,36 @@ jobs:
- name: Delete latest tag
run: git push origin :refs/tags/latest || true
- name: Generate release body
id: release-body
run: |
SKILL_LIST=$(./scripts/generate-skill-list.sh)
# Use heredoc to handle multiline output
{
echo 'BODY<<RELEASE_EOF'
cat <<EOF
Automatically updated Sentry agent skills package.
## Installation
Download and extract to your editor's skills directory:
\`\`\`bash
# Example for Claude Code (project-level)
mkdir -p .claude/skills
curl -L https://github.com/getsentry/sentry-agent-skills/releases/download/latest/sentry-agent-skills.tar.gz | tar -xz -C .claude/skills
# Or use sentry-wizard
npx @sentry/wizard@latest --skills
\`\`\`
## Included Skills
$SKILL_LIST
EOF
echo 'RELEASE_EOF'
} >> "$GITHUB_OUTPUT"
- name: Create latest release
uses: softprops/action-gh-release@v2
with:
@@ -34,35 +64,4 @@ jobs:
files: sentry-agent-skills.tar.gz
prerelease: false
make_latest: true
body: |
Automatically updated Sentry agent skills package.
## Installation
Download and extract to your editor's skills directory:
```bash
# Example for Claude Code (project-level)
mkdir -p .claude/skills
curl -L https://github.com/getsentry/sentry-agent-skills/releases/download/latest/sentry-agent-skills.tar.gz | tar -xz -C .claude/skills
# Or use sentry-wizard
npx @sentry/wizard@latest --skills
```
## Included Skills
**Setup:**
- `sentry-nextjs-setup` - Setup Sentry in Next.js projects
- `sentry-react-setup` - Setup Sentry in React apps
- `sentry-react-native-setup` - Setup Sentry in React Native/Expo apps
- `sentry-python-setup` - Setup Sentry in Python apps (Django, Flask, FastAPI)
- `sentry-ruby-setup` - Setup Sentry in Ruby/Rails apps
- `sentry-setup-tracing` - Setup Sentry Tracing and Performance Monitoring
- `sentry-setup-logging` - Setup Sentry Logging
- `sentry-setup-metrics` - Setup Sentry Metrics
- `sentry-setup-ai-monitoring` - Setup Sentry AI Agent Monitoring
**Workflow:**
- `sentry-fix-issues` - Find and fix production issues using Sentry MCP
- `sentry-pr-code-review` - Analyze and resolve Sentry comments on GitHub PRs
body: ${{ steps.release-body.outputs.BODY }}
+6 -15
View File
@@ -20,11 +20,6 @@ Official agent skills for integrating Sentry into your projects. These skills pr
| Skill | Description | Platforms | Docs |
|-------|-------------|-----------|------|
| `sentry-react-setup` | Setup Sentry in React apps | React | [React Guide](https://docs.sentry.io/platforms/javascript/guides/react/) |
| `sentry-react-native-setup` | Setup Sentry in React Native using the wizard CLI | React Native, Expo | [React Native Guide](https://docs.sentry.io/platforms/react-native/) |
| `sentry-ios-swift-setup` | Setup Sentry in iOS/Swift apps (superseded by `sentry-cocoa-sdk`) | iOS (Swift, UIKit, SwiftUI) | [Apple Guide](https://docs.sentry.io/platforms/apple/guides/ios/) |
| `sentry-setup-tracing` | Setup Sentry Tracing (Performance Monitoring) | JS, Python, Ruby | [Tracing](https://docs.sentry.io/platforms/javascript/tracing/) |
| `sentry-setup-logging` | Setup Sentry Logging | JS, Python, Ruby | [Logs](https://docs.sentry.io/platforms/javascript/logs/) |
| `sentry-setup-metrics` | Setup Sentry Metrics | JS, Python | [Metrics](https://docs.sentry.io/platforms/javascript/metrics/) |
| `sentry-setup-ai-monitoring` | Setup Sentry AI Agent Monitoring | JS, Python | [AI Monitoring](https://docs.sentry.io/product/ai-monitoring/) |
### Workflow Skills
@@ -93,7 +88,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.claude/skills/ # Project-level
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -126,7 +121,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.codex/skills/ # Project-level
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -159,7 +154,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.github/skills/ # Project-level
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -194,7 +189,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.cursor/skills/ # Project-level
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -231,7 +226,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.claude/skills/ # Project-level (alternative)
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -268,7 +263,7 @@ git clone https://github.com/getsentry/sentry-agent-skills.git /tmp/sentry-skill
.claude/skills/ # Project-level (alternative)
# Each skill:
sentry-setup-tracing/
sentry-fix-issues/
SKILL.md
```
</details>
@@ -320,10 +315,6 @@ Once installed, your AI assistant will automatically discover the skills. Simply
|-------------|------------|
| "Add Sentry to my React app" | `sentry-react-setup` |
| "Add Sentry to my iOS/Swift app" | `sentry-cocoa-sdk` |
| "Set up Sentry in React Native" | `sentry-react-native-setup` |
| "Add performance monitoring to my app" | `sentry-setup-tracing` |
| "Enable Sentry logging" | `sentry-setup-logging` |
| "Track custom metrics with Sentry" | `sentry-setup-metrics` |
| "Monitor my OpenAI/LangChain calls" | `sentry-setup-ai-monitoring` |
### Debugging & Workflow
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Generates a markdown list of skills from skills/*/SKILL.md frontmatter.
# Used by the release workflow to keep the "Included Skills" section current.
set -euo pipefail
SKILLS_DIR="${1:-skills}"
for skill_file in "$SKILLS_DIR"/*/SKILL.md; do
[ -f "$skill_file" ] || continue
name=""
desc=""
in_frontmatter=false
while IFS= read -r line; do
if [[ "$line" == "---" ]]; then
if $in_frontmatter; then
break
else
in_frontmatter=true
continue
fi
fi
if $in_frontmatter; then
if [[ "$line" =~ ^name:\ *(.*) ]]; then
name="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^description:\ *(.*) ]]; then
# Take only the first sentence (up to first period followed by space or end)
raw="${BASH_REMATCH[1]}"
desc=$(echo "$raw" | sed 's/\. .*/\./')
fi
fi
done < "$skill_file"
if [[ -n "$name" && -n "$desc" ]]; then
echo "- \`$name\` - $desc"
fi
done
-259
View File
@@ -1,259 +0,0 @@
---
name: sentry-ios-swift-setup
description: Setup Sentry in iOS/Swift apps. Use when asked to add Sentry to iOS, install sentry-cocoa SDK, or configure error monitoring for iOS applications using Swift and SwiftUI.
license: Apache-2.0
---
# Sentry iOS Swift Setup
Install and configure Sentry in iOS projects using Swift and SwiftUI.
## Invoke This Skill When
- User asks to "add Sentry to iOS" or "install Sentry" in a Swift app
- User wants error monitoring, tracing, or session replay in iOS
- User mentions "sentry-cocoa" or iOS crash reporting
**Important:** The configuration options and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and defaults may have changed.
## Requirements
- iOS 15.0+, macOS 12.0+, tvOS 15.0+, watchOS 8.0+
## Install
### Swift Package Manager (Recommended)
1. File > Add Package Dependencies
2. Enter: `https://github.com/getsentry/sentry-cocoa.git`
3. Select version rule: "Up to Next Major" from `9.5.0`
**SPM Products:** Choose based on your needs:
| Product | Use Case |
|---------|----------|
| `Sentry` | Default (static linking) |
| `Sentry-Dynamic` | Dynamic framework |
| `SentrySwiftUI` | SwiftUI view performance tracking |
| `Sentry-WithoutUIKitOrAppKit` | App extensions or CLI tools |
### CocoaPods
```ruby
# Podfile
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '9.5.0'
```
Then run `pod install`.
## Configure
### SwiftUI App
```swift
import SwiftUI
import Sentry
@main
struct YourApp: App {
init() {
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = true
// Tracing
options.tracesSampleRate = 1.0
// Profiling
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}
// Session Replay
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0
// Logs (SDK 9.0.0+; for 8.55.0-8.x use options.experimental.enableLogs)
options.enableLogs = true
// Error context
options.attachScreenshot = true
options.attachViewHierarchy = true
}
}
var body: some Scene {
WindowGroup { ContentView() }
}
}
```
### UIKit App
```swift
import UIKit
import Sentry
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = true
options.tracesSampleRate = 1.0
options.enableLogs = true
}
return true
}
}
```
## Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `tracesSampleRate` | % of transactions traced | `0` |
| `sessionReplay.sessionSampleRate` | % of sessions replayed | `0` |
| `sessionReplay.onErrorSampleRate` | % of error sessions replayed | `0` |
| `enableLogs` | Send logs to Sentry | `false` |
| `attachScreenshot` | Attach screenshot on error | `false` |
| `attachViewHierarchy` | Attach view hierarchy on error | `false` |
## Auto-Instrumented Features
| Feature | What's Captured |
|---------|-----------------|
| App Launches | Cold/warm start times |
| Network | URLSession requests |
| UI | UIViewController loads, user interactions |
| File I/O | Read/write operations |
| Core Data | Fetch/save operations |
| Frames | Slow and frozen frame detection |
## Logging
```swift
let logger = SentrySDK.logger
logger.info("User action", attributes: [
"userId": "123",
"action": "checkout"
])
// Log levels: trace, debug, info, warn, error, fatal
```
## Session Replay
**iOS 26+ / Xcode 26+ caveat:** SDK 8.57.0+ automatically disables Session Replay on iOS 26.0+ when built with Xcode 26.0+ due to Apple's Liquid Glass rendering breaking masking reliability. Replay still works on iOS < 26 or Xcode < 26. To force-enable (use with caution): `options.experimental.enableSessionReplayInUnreliableEnvironment = true`.
### Masking
```swift
// SwiftUI modifiers
Text("Safe content").sentryReplayUnmask()
Text(user.email).sentryReplayMask()
```
## User Context
```swift
let user = User()
user.userId = "user_123"
user.email = "user@example.com"
SentrySDK.setUser(user)
// Clear on logout
SentrySDK.setUser(nil)
```
## Verification
```swift
// Test error capture
SentrySDK.capture(message: "Test from iOS")
// Or trigger a test error
do {
try someFailingFunction()
} catch {
SentrySDK.capture(error: error)
}
```
## Production Settings
```swift
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = false
options.tracesSampleRate = 0.2 // 20%
options.sessionReplay.sessionSampleRate = 0.1 // 10%
options.sessionReplay.onErrorSampleRate = 1.0 // 100% on error
options.enableLogs = true
}
```
## Size Analysis (Fastlane)
Track app bundle size with Sentry using the Fastlane plugin.
### Install Plugin
```bash
bundle exec fastlane add_plugin fastlane-plugin-sentry
```
### Configure Authentication
```bash
# Environment variable (recommended for CI)
export SENTRY_AUTH_TOKEN=your_token_here
```
Or create `.sentryclirc` (add to `.gitignore`):
```ini
[auth]
token=YOUR_SENTRY_AUTH_TOKEN
```
### Fastfile Lane
```ruby
lane :sentry_size do
build_app(
scheme: "YourApp",
configuration: "Release",
export_method: "app-store"
)
sentry_upload_build(
org_slug: "your-org",
project_slug: "your-project",
build_configuration: "Release"
)
end
```
### Run Size Analysis
```bash
bundle exec fastlane sentry_size
```
View results in the Sentry UI after the upload completes.
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Events not appearing | Check DSN, enable `debug = true` |
| No traces | Set `tracesSampleRate` > 0 |
| No replays | Set `sessionSampleRate` > 0, check SDK 8.31.1+. On iOS 26+/Xcode 26+ see Liquid Glass caveat above |
| No logs | Set `enableLogs = true` (SDK 9.0.0+) or `experimental.enableLogs = true` (SDK 8.55.0-8.x) |
| CocoaPods fails | Run `pod repo update`, check iOS 15+ target |
| Size upload fails | Check `SENTRY_AUTH_TOKEN`, verify org/project slugs |
-141
View File
@@ -1,141 +0,0 @@
---
name: sentry-react-native-setup
description: Setup Sentry in React Native using the wizard CLI. Use when asked to add Sentry to React Native, install @sentry/react-native, or configure error monitoring for React Native or Expo apps.
license: Apache-2.0
---
# Sentry React Native Setup
Install and configure Sentry in React Native projects using the official wizard CLI.
## Invoke This Skill When
- User asks to "add Sentry to React Native" or "install Sentry" in a React Native app
- User wants error monitoring, logging, or tracing in React Native or Expo
- User mentions "@sentry/react-native" or mobile error tracking
**Important:** The configuration options and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and defaults may have changed.
## Wizard Setup (Recommended)
```bash
npx @sentry/wizard@latest -i reactNative
```
### What the Wizard Does
| Task | Description |
|------|-------------|
| Install SDK | Adds `@sentry/react-native` package |
| Metro config | Adds `@sentry/react-native/metro` to `metro.config.js` |
| Expo config | Adds `@sentry/react-native/expo` to `app.json` |
| Android setup | Enables Gradle build step for source maps |
| iOS setup | Wraps Xcode build phase, adds debug symbol upload |
| Pod install | Runs `pod install` for iOS |
| Credentials | Stores in `ios/sentry.properties`, `android/sentry.properties`, `env.local` |
| Init code | Configures Sentry in `App.tsx` or `_layout.tsx` |
## Manual Configuration
If not using wizard, add to your app entry point:
```javascript
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
sendDefaultPii: true,
// Tracing
tracesSampleRate: 1.0,
// Logs
enableLogs: true,
// Profiling
profilesSampleRate: 1.0,
// Session Replay
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
integrations: [Sentry.mobileReplayIntegration()],
});
```
### Wrap Your App
```javascript
export default Sentry.wrap(App);
```
## Expo Projects
For Expo, follow the [Expo-specific setup](https://docs.sentry.io/platforms/react-native/manual-setup/expo/):
```bash
npx @sentry/wizard@latest -i reactNative
```
Works for both managed and bare Expo projects.
## Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `sendDefaultPii` | Include user data | `false` |
| `tracesSampleRate` | % of transactions traced | `0` |
| `profilesSampleRate` | % of traces profiled | `0` |
| `enableLogs` | Send logs to Sentry | `false` |
| `replaysOnErrorSampleRate` | % of error sessions replayed | `0` |
| `replaysSessionSampleRate` | % of all sessions replayed | `0` |
## Files Created/Modified
| File | Purpose |
|------|---------|
| `App.js` / `_layout.tsx` | Sentry initialization |
| `metro.config.js` | Metro bundler config |
| `app.json` | Expo config (if Expo) |
| `ios/sentry.properties` | iOS build credentials |
| `android/sentry.properties` | Android build credentials |
| `env.local` | Environment variables |
## Environment Variables
```bash
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```
## Verification
Add test error:
```javascript
throw new Error("My first Sentry error!");
```
Or use a test button:
```javascript
<Button title="Test Sentry" onPress={() => { throw new Error("Test"); }} />
```
## Source Maps
Source maps are automatically uploaded during build when wizard configures:
- Android: Gradle plugin
- iOS: Xcode build phase
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Wizard fails | Try manual setup, check Node version |
| iOS build fails | Run `cd ios && pod install` |
| Source maps not uploading | Verify `sentry.properties` files have auth token |
| Expo errors | Ensure using compatible Expo SDK version |
| App not wrapped | Add `export default Sentry.wrap(App)` |
-149
View File
@@ -1,149 +0,0 @@
---
name: sentry-setup-logging
description: Setup Sentry Logging in any project. Use when asked to add Sentry logs, enable structured logging, capture console logs, or integrate logging libraries (Consola, Loguru) with Sentry. Supports JavaScript, Python, and Ruby.
license: Apache-2.0
---
# Setup Sentry Logging
Configure Sentry's structured logging feature.
## Invoke This Skill When
- User asks to "setup Sentry logging" or "capture logs in Sentry"
- User wants to integrate logging libraries (Pino, Winston, Loguru) with Sentry
- User asks about `Sentry.logger` or `sentry_sdk.logger`
**Important:** The SDK versions, API names, and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and minimum versions may have changed.
## Quick Reference
| Platform | Min SDK | Enable Flag | Logger API |
|----------|---------|-------------|------------|
| JavaScript | 9.41.0+ | `enableLogs: true` | `Sentry.logger.*` |
| Python | 2.35.0+ | `enable_logs=True` | `sentry_sdk.logger.*` |
| Ruby | 5.24.0+ | `config.enable_logs = true` | `Sentry.logger.*` |
## JavaScript Setup
### 1. Verify SDK version
```bash
grep -E '"@sentry/(nextjs|react|node|browser)"' package.json
```
### 2. Enable in Sentry.init()
```javascript
Sentry.init({
dsn: "YOUR_DSN",
enableLogs: true,
});
```
### 3. Console capture (optional)
```javascript
integrations: [
Sentry.consoleLoggingIntegration({ levels: ["warn", "error"] }),
],
```
### 4. Use structured logging
```javascript
Sentry.logger.info("User logged in", { userId: "123" });
Sentry.logger.error("Payment failed", { orderId: "456", amount: 99.99 });
// Template literals (creates searchable attributes)
Sentry.logger.info(Sentry.logger.fmt`User ${userId} purchased ${productName}`);
```
### Third-party integrations
| Library | Integration | Min SDK |
|---------|-------------|---------|
| Consola | `Sentry.createConsolaReporter()` | 10.12.0+ |
| Console capture | `Sentry.consoleLoggingIntegration()` | 10.13.0+ |
## Python Setup
### 1. Verify SDK version
```bash
pip show sentry-sdk | grep Version
```
### 2. Enable in init()
```python
sentry_sdk.init(
dsn="YOUR_DSN",
enable_logs=True,
)
```
### 3. Stdlib logging capture (optional)
```python
from sentry_sdk.integrations.logging import LoggingIntegration
integrations=[LoggingIntegration(sentry_logs_level=logging.INFO)]
```
### 4. Use structured logging
```python
from sentry_sdk import logger as sentry_logger
sentry_logger.info("User logged in: {user_id}", user_id="123")
sentry_logger.error("Payment failed", order_id="456", amount=99.99)
```
### Loguru integration
```python
from sentry_sdk.integrations.loguru import LoguruIntegration
integrations=[LoguruIntegration(sentry_logs_level=LoggingLevels.INFO.value)]
```
## Ruby Setup
### 1. Verify SDK version
```bash
bundle show sentry-ruby
```
### 2. Enable in init
```ruby
Sentry.init do |config|
config.dsn = "YOUR_DSN"
config.enable_logs = true
config.enabled_patches << :logger # Optional: capture stdlib Logger
end
```
### 3. Use structured logging
```ruby
Sentry.logger.info("User logged in")
Sentry.logger.error("Payment failed. Order: %{order_id}", order_id: "456")
```
## Log Filtering
### JavaScript
```javascript
beforeSendLog: (log) => log.level === "info" ? null : log,
```
### Python
```python
def before_send_log(log, hint):
return None if log["severity_text"] == "info" else log
```
## Verification
After enabling logs, emit a test log and check the Sentry Logs dashboard (Explore > Logs):
```javascript
Sentry.logger.info("Sentry logging test");
```
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Logs not appearing | Verify SDK version, check `enableLogs`/`enable_logs` is set |
| Too many logs | Use `beforeSendLog` to filter, reduce captured levels |
| Console not captured | Add `consoleLoggingIntegration` to integrations array |
-184
View File
@@ -1,184 +0,0 @@
---
name: sentry-setup-metrics
description: Setup Sentry Metrics in any project. Use when asked to add custom metrics, track counters/gauges/distributions, or instrument application performance. Supports JavaScript, Python, and Ruby.
license: Apache-2.0
---
# Setup Sentry Metrics
Configure Sentry's custom metrics for tracking counters, gauges, and distributions.
## Invoke This Skill When
- User asks to "add Sentry metrics" or "track custom metrics"
- User wants counters, gauges, or distributions
- User asks about `Sentry.metrics` or `sentry_sdk.metrics`
**Important:** The SDK versions, API names, and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and minimum versions may have changed.
## Quick Reference
Check [Sentry Metrics Getting Started](https://docs.sentry.io/product/explore/metrics/getting-started/) for the full list of supported SDKs and minimum versions. Examples below use JavaScript and Python:
| Platform | Min SDK | API | Status |
|----------|---------|-----|--------|
| JavaScript | 10.25.0+ | `Sentry.metrics.*` | Open Beta |
| Python | 2.44.0+ | `sentry_sdk.metrics.*` | Open Beta |
| Ruby | 6.3.0+ | `Sentry.metrics.*` | Open Beta |
## Metric Types
| Type | Purpose | Example Use Cases |
|------|---------|-------------------|
| **Counter** | Cumulative counts | API calls, clicks, errors |
| **Gauge** | Point-in-time values | Queue depth, memory, connections |
| **Distribution** | Statistical values | Response times, cart amounts |
## JavaScript Setup
Metrics are **enabled by default** in SDK 10.25.0+.
### Counter
```javascript
Sentry.metrics.count("api_call", 1, {
attributes: { endpoint: "/api/users", status_code: 200 },
});
```
### Gauge
```javascript
Sentry.metrics.gauge("queue_depth", 42, {
unit: "none",
attributes: { queue: "jobs" },
});
```
### Distribution
```javascript
Sentry.metrics.distribution("response_time", 187.5, {
unit: "millisecond",
attributes: { endpoint: "/api/products" },
});
```
### Filtering (optional)
```javascript
Sentry.init({
beforeSendMetric: (metric) => {
if (metric.attributes?.sensitive) return null;
return metric;
},
});
```
## Python Setup
Metrics are **enabled by default** in SDK 2.44.0+.
### Counter
```python
sentry_sdk.metrics.count("api_call", 1, attributes={"endpoint": "/api/users"})
```
### Gauge
```python
sentry_sdk.metrics.gauge("queue_depth", 42, attributes={"queue": "jobs"})
```
### Distribution
```python
sentry_sdk.metrics.distribution(
"response_time", 187.5,
unit="millisecond",
attributes={"endpoint": "/api/products"}
)
```
### Filtering (optional)
```python
def before_send_metric(metric, hint):
if metric.get("attributes", {}).get("sensitive"):
return None
return metric
sentry_sdk.init(dsn="YOUR_DSN", before_send_metric=before_send_metric)
```
## Common Units
| Category | Values |
|----------|--------|
| Time | `millisecond`, `second`, `minute`, `hour` |
| Size | `byte`, `kilobyte`, `megabyte` |
| Currency | `usd`, `eur`, `gbp` |
| Other | `none`, `percent`, `ratio` |
## Timing Helper Pattern
### JavaScript
```javascript
async function withTiming(name, fn, attrs = {}) {
const start = performance.now();
try { return await fn(); }
finally {
Sentry.metrics.distribution(name, performance.now() - start, {
unit: "millisecond", attributes: attrs,
});
}
}
```
### Python
```python
import time, sentry_sdk
def track_duration(name, **attrs):
def decorator(fn):
def wrapper(*args, **kwargs):
start = time.time()
try: return fn(*args, **kwargs)
finally:
sentry_sdk.metrics.distribution(
name, (time.time() - start) * 1000,
unit="millisecond", attributes=attrs
)
return wrapper
return decorator
```
## Ruby Setup
Metrics are **enabled by default** in SDK 6.3.0+.
### Counter
```ruby
Sentry.metrics.count("api_call", 1, attributes: { endpoint: "/api/users" })
```
### Gauge
```ruby
Sentry.metrics.gauge("queue_depth", 42, attributes: { queue: "jobs" })
```
### Distribution
```ruby
Sentry.metrics.distribution("response_time", 187.5, unit: "millisecond", attributes: { endpoint: "/api/products" })
```
## Best Practices
- **Stay under 2KB per metric**: Each metric event has a 2KB size limit — keep attribute sets concise
- **Namespaced names**: `api.request.duration`, not `duration`
- **Flush on exit**: Call `Sentry.flush()` before process exit
## Verification
After adding a metric, trigger the code path that emits it and check the Sentry Metrics dashboard (Explore > Metrics). Metrics may take a few minutes to appear due to buffer flushing.
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Metrics not appearing | Verify SDK version, check DSN, wait for buffer flush |
| Metric dropped silently | Check that metric event is under 2KB size limit — reduce attributes |
| Too many metrics | Use `beforeSendMetric` to filter |
-159
View File
@@ -1,159 +0,0 @@
---
name: sentry-setup-tracing
description: Setup Sentry Tracing (Performance Monitoring) in any project. Use when asked to enable tracing, track transactions/spans, measure latency, or add performance monitoring. Supports JavaScript, Python, and Ruby.
license: Apache-2.0
---
# Setup Sentry Tracing
Configure Sentry's performance monitoring to track transactions and spans.
## Invoke This Skill When
- User asks to "enable tracing" or "add performance monitoring"
- User wants to track API response times, page loads, or latency
- User asks about `tracesSampleRate` or custom spans
**Important:** The SDK versions, API names, and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and minimum versions may have changed.
## Quick Reference
| Platform | Min SDK | Enable | Custom Span |
|----------|---------|--------|-------------|
| JS/Browser | 9.0.0+ | `tracesSampleRate` + `browserTracingIntegration()` | `Sentry.startSpan()` |
| Next.js | 9.0.0+ | `tracesSampleRate` in each runtime config file | `Sentry.startSpan()` |
| Node.js | 9.0.0+ | `tracesSampleRate` | `Sentry.startSpan()` |
| Python | 0.11.2+ | `traces_sample_rate` | `@sentry_sdk.trace` or `start_span()` |
| Ruby | 5.0.0+ | `traces_sample_rate` | `Sentry.with_child_span()` |
## JavaScript Setup
### Enable tracing
```javascript
Sentry.init({
dsn: "YOUR_DSN",
tracesSampleRate: 1.0, // 1.0 = 100%, lower for production
integrations: [Sentry.browserTracingIntegration()], // Browser/React only
tracePropagationTargets: ["localhost", /^https:\/\/api\./],
});
```
### Custom spans
```javascript
// Async operation
const result = await Sentry.startSpan(
{ name: "fetch-user", op: "http.client" },
async () => {
return await fetch("/api/user").then(r => r.json());
}
);
// Nested spans
await Sentry.startSpan({ name: "checkout", op: "transaction" }, async () => {
await Sentry.startSpan({ name: "validate", op: "validation" }, validateCart);
await Sentry.startSpan({ name: "payment", op: "payment" }, processPayment);
});
```
### Dynamic sampling
```javascript
tracesSampler: ({ name, inheritOrSampleWith }) => {
if (name.includes("healthcheck")) return 0;
if (name.includes("checkout")) return 1.0;
return inheritOrSampleWith(0.1); // Respects parent sampling decision, falls back to 0.1
},
```
## Python Setup
### Enable tracing
```python
sentry_sdk.init(
dsn="YOUR_DSN",
traces_sample_rate=1.0,
)
```
### Custom spans
```python
# Decorator
@sentry_sdk.trace
def expensive_function():
return do_work()
# Context manager
with sentry_sdk.start_span(name="process-order", op="task") as span:
span.set_data("order.id", order_id)
process(order_id)
```
### Dynamic sampling
```python
from sentry_sdk.types import SamplingContext
def traces_sampler(sampling_context: SamplingContext) -> float:
name = sampling_context.get("transaction_context", {}).get("name", "")
parent_sampled = sampling_context.get("parent_sampled")
if "healthcheck" in name: return 0
if "checkout" in name: return 1.0
if parent_sampled is not None: return float(parent_sampled) # Respect parent decision
return 0.1
sentry_sdk.init(dsn="YOUR_DSN", traces_sampler=traces_sampler)
```
## Ruby Setup
```ruby
Sentry.init do |config|
config.dsn = "YOUR_DSN"
config.traces_sample_rate = 1.0
end
```
## Common Operation Types
| `op` Value | Use Case |
|------------|----------|
| `http.client` | Outgoing HTTP |
| `http.server` | Incoming HTTP |
| `db` / `db.query` | Database |
| `cache` | Cache operations |
| `queue.task` | Background jobs |
| `function` | Function calls |
## Sampling Recommendations
| Traffic | Rate |
|---------|------|
| Development | `1.0` |
| Low (<1K req/min) | `0.5 - 1.0` |
| Medium (1K-10K) | `0.1 - 0.5` |
| High (>10K) | `0.01 - 0.1` |
## Distributed Tracing
Configure `tracePropagationTargets` to send trace headers to your APIs:
```javascript
tracePropagationTargets: ["localhost", "https://api.yourapp.com"],
```
For Next.js 14 App Router, add to root layout (not needed in Next.js 15+):
```typescript
export function generateMetadata(): Metadata {
return { other: { ...Sentry.getTraceData() } };
}
```
## Verification
After enabling tracing, trigger a traced operation (e.g., an HTTP request) and check the Sentry Performance dashboard for transactions. Custom spans should appear nested under the parent transaction.
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Transactions not appearing | Check `tracesSampleRate > 0`, verify DSN |
| Browser traces missing | Add `browserTracingIntegration()` |
| Distributed traces disconnected | Check `tracePropagationTargets`, CORS headers |
| Too many transactions | Lower sample rate, use `tracesSampler` to filter |