# Sentry — Open Source Error Tracking & Performance Monitoring > Sentry is the developer-first error tracking and performance monitoring platform. Capture exceptions, trace performance issues, and debug production errors across all languages. ## Install Save in your project root: ## Quick Use ### Self-Hosted ```bash git clone https://github.com/getsentry/self-hosted.git cd self-hosted ./install.sh docker compose up -d ``` Open `http://localhost:9000` — create your account and start tracking errors. ### SaaS (Quick Start) ```bash npm install @sentry/node ``` ```javascript const Sentry = require("@sentry/node"); Sentry.init({ dsn: "https://key@sentry.io/project-id" }); ``` ## Intro **Sentry** is the leading error tracking and performance monitoring platform for developers. It captures unhandled exceptions, tracks performance bottlenecks, monitors releases, and provides the context needed to debug production issues — all with SDKs for 100+ languages and frameworks. With 43.5K+ GitHub stars, Sentry is used by millions of developers at organizations from startups to Fortune 500 companies. The self-hosted version provides the full Sentry experience on your own infrastructure. ## What Sentry Does - **Error Tracking**: Capture and group unhandled exceptions with full stack traces - **Performance Monitoring**: Trace transactions across services with latency breakdowns - **Session Replay**: Replay user sessions to see exactly what happened before an error - **Release Tracking**: Track error rates per release, detect regressions automatically - **Source Maps**: Unminify JavaScript errors with automatic source map processing - **Alerts**: Configurable alert rules for error spikes, new issues, and performance degradation - **Issue Assignment**: Auto-assign issues to code owners based on stack trace - **Integrations**: GitHub, GitLab, Jira, Slack, PagerDuty, and 50+ integrations - **Breadcrumbs**: Automatic event trail leading up to each error (clicks, API calls, console logs) ## SDK Examples ### JavaScript/Node.js ```javascript const Sentry = require("@sentry/node"); const { nodeProfilingIntegration } = require("@sentry/profiling-node"); Sentry.init({ dsn: "https://your-dsn@sentry.io/project", integrations: [nodeProfilingIntegration()], tracesSampleRate: 0.1, profilesSampleRate: 0.1, }); // Errors are captured automatically // Manual capture: try { riskyOperation(); } catch (error) { Sentry.captureException(error); } // Add context Sentry.setUser({ id: "user123", email: "user@example.com" }); Sentry.setTag("feature", "checkout"); ``` ### Python ```python import sentry_sdk sentry_sdk.init( dsn="https://your-dsn@sentry.io/project", traces_sample_rate=0.1, ) # Auto-captures unhandled exceptions # Django, Flask, FastAPI auto-instrumented # Manual capture try: process_payment(order) except PaymentError as e: sentry_sdk.capture_exception(e) sentry_sdk.capture_message("Payment failed for order %s" % order.id) ``` ### Go ```go import "github.com/getsentry/sentry-go" func main() { sentry.Init(sentry.ClientOptions{ Dsn: "https://your-dsn@sentry.io/project", TracesSampleRate: 0.1, }) defer sentry.Flush(2 * time.Second) } ``` ## Self-Hosting ### Requirements - Docker 19.03+ and Docker Compose 2.19+ - 8GB RAM minimum (16GB recommended) - 20GB disk space ### Docker Compose ```bash git clone https://github.com/getsentry/self-hosted.git cd self-hosted ./install.sh # Interactive setup docker compose up -d ``` Components deployed: - Sentry Web (Django) - Sentry Worker (Celery) - Sentry Cron - PostgreSQL - Redis - Kafka - ClickHouse - Snuba (query engine) - Symbolicator (source maps) - Relay (event ingestion) ## Key Features ### Issue Grouping Sentry automatically groups similar errors: ``` Issue: TypeError: Cannot read property 'name' of undefined ├── 1,234 events ├── 56 users affected ├── First seen: 2 days ago ├── Last seen: 5 minutes ago ├── Stack trace with source context ├── Breadcrumbs (30 events before crash) ├── Tags: browser=Chrome, os=Windows, release=v2.1.0 └── Linked commits (suspect commits) ``` ### Performance Tracing ``` Transaction: POST /api/checkout (p50: 450ms, p95: 1.2s) ├── HTTP Handler (12ms) ├── Auth Middleware (5ms) ├── Validate Cart (8ms) ├── DB: SELECT products (45ms) ├── Payment API Call (380ms) ← bottleneck ├── DB: INSERT order (15ms) ├── Send Email (async) └── Response (465ms total) ``` ### Release Health ``` Release v2.1.0: ├── Crash-free sessions: 99.2% (↓ from 99.8%) ├── Crash-free users: 98.5% ├── New issues: 3 ├── Regressed issues: 1 ├── Adoption: 45% of users └── Suspect commits: abc1234 by @developer ``` ## Sentry vs Alternatives | Feature | Sentry | Datadog | New Relic | GlitchTip | Bugsnag | |---------|--------|---------|-----------|-----------|---------| | Open Source | Yes | No | No | Yes | No | | Self-hosted | Yes | No | No | Yes | No | | Error tracking | Excellent | Good | Good | Basic | Good | | Performance | APM + Profiling | Full APM | Full APM | No | No | | Session replay | Yes | Yes | Yes | No | No | | SDKs | 100+ | 15+ | 15+ | Sentry-compat | 15+ | | Pricing | Free (self-host) | $15/host | $0.30/GB | Free | $99/mo | ## 常见问题 **Q: 自托管 Sentry 资源需求大吗?** A: 是的,完整的 Sentry 包含 Kafka、ClickHouse、PostgreSQL 等多个组件,最低需要 8GB RAM。对于小团队,可以考虑轻量替代 GlitchTip(Sentry 兼容但资源需求小得多)。 **Q: 自托管版本和 SaaS 功能一样吗?** A: 核心功能(错误追踪、性能监控、告警)完全一样。SaaS 版额外提供 Session Replay、Cron Monitoring 等高级功能,以及更好的扩展性和免维护。 **Q: 数据量大了性能会下降吗?** A: 自托管版本建议配置事件采样率(tracesSampleRate)来控制数据量。对于高流量应用,0.01-0.1 的采样率即可提供足够的洞察。ClickHouse 后端确保查询性能。 ## 来源与致谢 - GitHub: [getsentry/sentry](https://github.com/getsentry/sentry) — 43.5K+ ⭐ - 自托管: [getsentry/self-hosted](https://github.com/getsentry/self-hosted) - 官网: [sentry.io](https://sentry.io) --- Source: https://tokrepo.com/en/workflows/ece57add-34d8-11f1-9bc6-00163e2b0d79 Author: AI Open Source