sentry-python-sdk by getsentry/sentry-for-ai
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-python-sdk一个经过精心设计的向导,用于扫描您的 Python 项目并指导您完成完整的 Sentry 设置。
sentry-sdk、sentry_sdk 或 Sentry 与任何 Python 框架的组合注意: 下面的 SDK 版本和 API 反映了撰写时的 Sentry 文档(sentry-sdk 2.x)。在实施前,请务必对照 docs.sentry.io/platforms/python/ 进行验证。
在给出建议之前,运行以下命令来了解项目情况:
# 检查是否已存在 Sentry
grep -i sentry requirements.txt pyproject.toml setup.cfg setup.py 2>/dev/null
# 检测 Web 框架
grep -rE "django|flask|fastapi|starlette|aiohttp|tornado|quart|falcon|sanic|bottle" \
requirements.txt pyproject.toml 2>/dev/null
# 检测任务队列
grep -rE "celery|rq|huey|arq|dramatiq" requirements.txt pyproject.toml 2>/dev/null
# 检测日志库
grep -E "loguru" requirements.txt pyproject.toml 2>/dev/null
# 检测 AI 库
grep -rE "openai|anthropic|langchain|huggingface|google-genai|pydantic-ai|litellm" \
requirements.txt pyproject.toml 2>/dev/null
# 检测调度器 / 定时任务
grep -rE "celery|apscheduler|schedule|crontab" requirements.txt pyproject.toml 2>/dev/null
# OpenTelemetry 追踪 — 检查 SDK + 仪表化库
grep -rE "opentelemetry-sdk|opentelemetry-instrumentation|opentelemetry-distro" \
requirements.txt pyproject.toml 2>/dev/null
grep -rn "TracerProvider\|trace\.get_tracer\|start_as_current_span" \
--include="*.py" 2>/dev/null | head -5
# 检查配套的前端项目
ls frontend/ web/ client/ ui/ static/ templates/ 2>/dev/null
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
需要注意的事项:
sentry-sdk 是否已在 requirements 中?如果是,检查 sentry_sdk.init() 是否存在 — 可能只需要配置功能。sentry_sdk.init()。)根据您的发现,提出具体的建议方案。不要问开放式问题 — 直接给出推荐:
根据 OTel 检测结果的路由:
opentelemetry-sdk / opentelemetry-distro,或源代码中有 TracerProvider)→ 使用 OTLP 路径:OTLPIntegration();不要设置 traces_sample_rate;Sentry 会自动将错误链接到 OTel 追踪始终推荐(核心覆盖):
ExceptionGroup(Python 3.11+)logging 标准库自动捕获;如果检测到 Loguru 则增强检测到时推荐:
推荐矩阵:
| 功能 | 推荐时机... | 参考文档 |
|---|---|---|
| 错误监控 | 始终 — 不可或缺的基线 | ${SKILL_ROOT}/references/error-monitoring.md |
| OTLP 集成 | 检测到 OTel 追踪 — 替代 原生追踪 | ${SKILL_ROOT}/references/tracing.md |
| 追踪 | 检测到 Django/Flask/FastAPI/AIOHTTP/等;如果检测到 OTel 追踪则跳过 | ${SKILL_ROOT}/references/tracing.md |
| 性能分析 | 生产环境 + 性能敏感型工作负载;如果检测到 OTel 追踪则跳过(需要 traces_sample_rate,与 OTLP 不兼容) | ${SKILL_ROOT}/references/profiling.md |
| 日志记录 | 始终(标准库);Loguru 增强 | ${SKILL_ROOT}/references/logging.md |
| 指标 | 需要业务事件或 SLO 跟踪 | ${SKILL_ROOT}/references/metrics.md |
| 定时任务监控 | Celery Beat、APScheduler 或定时任务模式 | ${SKILL_ROOT}/references/crons.md |
| AI 监控 | 检测到 OpenAI/Anthropic/LangChain/等 | ${SKILL_ROOT}/references/ai-monitoring.md |
检测到 OTel 追踪: "我在项目中看到了 OpenTelemetry 追踪。我推荐使用 Sentry 的 OTLP 集成进行追踪(通过您现有的 OTel 设置)+ 错误监控 + Sentry 日志记录 [+ 指标/定时任务监控/AI 监控(如果适用)]。可以继续吗?"
没有 OTel: "我推荐错误监控 + 追踪 [+ 日志记录(如果适用)]。还需要性能分析、定时任务监控或 AI 监控吗?"
# 核心 SDK(始终需要)
pip install sentry-sdk
# 可选扩展(仅安装与检测到的框架匹配的):
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]"
# 多个扩展:
pip install "sentry-sdk[django,celery]"
扩展是可选的 — 普通的
sentry-sdk适用于所有框架。扩展会安装补充包。
完整的初始化,以合理的默认值启用最多功能。放置在任何应用/框架代码之前:
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
environment=os.environ.get("SENTRY_ENVIRONMENT", "production"),
release=os.environ.get("SENTRY_RELEASE"), # 例如 "myapp@1.0.0"
send_default_pii=True,
# 追踪(在高流量生产环境中可降低到 0.1–0.2)
traces_sample_rate=1.0,
# 性能分析 — 连续的,与活动跨度绑定
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
# 结构化日志(SDK ≥ 2.35.0)
enable_logs=True,
)
| 框架 | 调用 sentry_sdk.init() 的位置 | 备注 |
|---|---|---|
| Django | settings.py 顶部,在任何导入之前 | 不需要中间件 — Sentry 内部修补 Django |
| Flask | 在 app = Flask(__name__) 之前 | 必须在应用创建之前 |
| FastAPI | 在 app = FastAPI() 之前 | StarletteIntegration + FastApiIntegration 自动一起启用 |
| Starlette | 在 app = Starlette(...) 之前 | 与 FastAPI 相同的自动集成 |
| AIOHTTP | 模块级别,在 web.Application() 之前 | |
| Tornado | 模块级别,在应用设置之前 | 不需要集成类 |
| Quart | 在 app = Quart(__name__) 之前 | |
| Falcon | 模块级别,在 app = falcon.App() 之前 | |
| Sanic | 在 @app.listener("before_server_start") 内部 | Sanic 的生命周期需要异步初始化 |
| Celery | 工作进程和调用进程中的 @signals.celeryd_init.connect | 需要双进程初始化 |
| RQ | 工作进程通过 rq worker -c mysettings 加载的 mysettings.py | |
| ARQ | 工作模块和入队进程都需要 |
Django 示例(settings.py):
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
send_default_pii=True,
traces_sample_rate=1.0,
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
enable_logs=True,
)
# 其余的 Django 设置...
INSTALLED_APPS = [...]
FastAPI 示例(main.py):
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
send_default_pii=True,
traces_sample_rate=1.0,
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
enable_logs=True,
)
from fastapi import FastAPI
app = FastAPI()
大多数集成在其包被安装时会自动激活 — 不需要 integrations=[...]:
| 自动启用 | 需要显式指定 |
|---|---|
| Django, Flask, FastAPI, Starlette, AIOHTTP, Tornado, Quart, Falcon, Sanic, Bottle | DramatiqIntegration |
| Celery, RQ, Huey, ARQ | GRPCIntegration |
| SQLAlchemy, Redis, asyncpg, pymongo | StrawberryIntegration |
| Requests, HTTPX, aiohttp-client | AsyncioIntegration |
| OpenAI, Anthropic, LangChain, Pydantic AI, MCP | OpenTelemetryIntegration |
Python logging, Loguru | WSGIIntegration / ASGIIntegration |
逐个功能进行指导。加载参考文档,按照其步骤操作,在继续之前进行验证:
| 功能 | 参考文件 | 加载时机... |
|---|---|---|
| 错误监控 | ${SKILL_ROOT}/references/error-monitoring.md | 始终(基线) |
| 追踪 | ${SKILL_ROOT}/references/tracing.md | HTTP 处理器 / 分布式追踪 |
| 性能分析 | ${SKILL_ROOT}/references/profiling.md | 性能敏感的生产环境 |
| 日志记录 | ${SKILL_ROOT}/references/logging.md | 始终;Loguru 增强 |
| 指标 | ${SKILL_ROOT}/references/metrics.md | 业务 KPI / SLO 跟踪 |
| 定时任务监控 | ${SKILL_ROOT}/references/crons.md | 检测到调度器 / 定时任务模式 |
| AI 监控 | ${SKILL_ROOT}/references/ai-monitoring.md | 检测到 AI 库 |
对于每个功能:读取 ${SKILL_ROOT}/references/<功能>.md,严格按照步骤操作,验证其工作。
sentry_sdk.init() 选项| 选项 | 类型 | 默认值 | 用途 |
|---|---|---|---|
dsn | str | None | 如果为空则 SDK 被禁用;环境变量:SENTRY_DSN |
environment | str | "production" | 例如 "staging";环境变量:SENTRY_ENVIRONMENT |
release | str | None | 例如 "myapp@1.0.0";环境变量:SENTRY_RELEASE |
send_default_pii | bool | False | 包含 IP、请求头、Cookie、认证用户 |
traces_sample_rate | float | None | 事务采样率;None 禁用追踪 |
traces_sampler | Callable | None | 自定义的每事务采样(覆盖采样率) |
profile_session_sample_rate | float | None | 连续性能分析会话采样率 |
profile_lifecycle | str | "manual" | "trace" = 随跨度自动启动性能分析器 |
profiles_sample_rate | float | None | 基于事务的性能分析采样率 |
enable_logs | bool | False | 将日志发送到 Sentry(SDK ≥ 2.35.0) |
sample_rate | float | 1.0 | 错误事件采样率 |
attach_stacktrace | bool | False | capture_message() 上的堆栈跟踪 |
max_breadcrumbs | int | 100 | 每个事件的最大面包屑数量 |
debug | bool | False | 详细的 SDK 调试输出 |
before_send | Callable | None | 用于修改/丢弃错误事件的钩子 |
before_send_transaction | Callable | None | 用于修改/丢弃事务事件的钩子 |
ignore_errors | list | [] | 要抑制的异常类型或正则表达式模式 |
auto_enabling_integrations | bool | True | 设置为 False 以禁用所有自动检测 |
OTLPIntegration 选项(传递给构造函数)| 选项 | 类型 | 默认值 | 用途 |
|---|---|---|---|
setup_otlp_traces_exporter | bool | True | 自动配置 OTLP 导出器;如果您发送到自己的 Collector,则设置为 False |
collector_url | str | None | OTel Collector 的 OTLP HTTP 端点(例如 http://localhost:4318/v1/traces);设置后,跨度将发送到收集器而不是直接发送到 Sentry |
setup_propagator | bool | True | 为分布式追踪自动配置 Sentry 传播器 |
capture_exceptions | bool | False | 拦截通过 OTel Span.record_exception 记录的异常 |
| 变量 | 映射到 | 备注 |
|---|---|---|
SENTRY_DSN | dsn | |
SENTRY_RELEASE | release | 也可以从 git SHA、Heroku、CircleCI、CodeBuild、GAE 自动检测 |
SENTRY_ENVIRONMENT | environment | |
SENTRY_DEBUG | debug |
测试 Sentry 是否正在接收事件:
# 触发一个真实的错误事件 — 几秒内在仪表板中检查
division_by_zero = 1 / 0
或者进行一个非崩溃的检查:
sentry_sdk.capture_message("Sentry Python SDK 测试")
如果没有显示任何内容:
sentry_sdk.init() 中设置 debug=True — 将 SDK 内部信息打印到 stdoutSENTRY_DSN 环境变量完成 Python 设置后,检查是否有配套的前端项目缺少 Sentry:
ls frontend/ web/ client/ ui/ 2>/dev/null
cat frontend/package.json web/package.json client/package.json 2>/dev/null \
| grep -E '"react"|"svelte"|"vue"|"next"|"nuxt"'
如果存在没有 Sentry 的前端项目,建议匹配的技能:
| 检测到的前端 | 建议的技能 |
|---|---|
| React / Next.js | sentry-react-sdk |
| Svelte / SvelteKit | sentry-svelte-sdk |
| Vue / Nuxt | 使用 @sentry/vue — 参见 docs.sentry.io/platforms/javascript/guides/vue/ |
| 其他 JS/TS | sentry-react-sdk(涵盖通用的浏览器 JS 模式) |
| 问题 | 解决方案 |
|---|---|
| 事件未出现 | 设置 debug=True,验证 DSN,检查运行进程中的环境变量 |
| DSN 格式错误 | 格式:https://<key>@o<org>.ingest.sentry.io/<project> |
| Django 异常未捕获 | 确保 sentry_sdk.init() 在 settings.py 的顶部,在其他导入之前 |
| Flask 异常未捕获 | 初始化必须在 app = Flask(__name__) 之前 |
| FastAPI 异常未捕获 | 在 app = FastAPI() 之前初始化;StarletteIntegration 和 FastApiIntegration 都会自动启用 |
| Celery 任务错误未捕获 | 必须在工作进程中通过 celeryd_init 信号调用 sentry_sdk.init() |
| Sanic 初始化无效 | 初始化必须在 @app.listener("before_server_start") 内部,而不是模块级别 |
| uWSGI 未捕获 | 在 uWSGI 命令中添加 --enable-threads --py-call-uwsgi-fork-hooks |
| 未出现追踪(原生) | 验证 traces_sample_rate 已设置(不是 None);检查集成是否自动启用 |
| 未出现追踪(OTLP) | 验证 sentry-sdk[opentelemetry-otlp] 已安装;使用 OTLPIntegration 时不要设置 traces_sample_rate |
| 性能分析未启动 | 需要 traces_sample_rate > 0 + profile_session_sample_rate 或 profiles_sample_rate;与 OTLP 路径不兼容 |
enable_logs 无效 | 需要 SDK ≥ 2.35.0;对于直接的结构化日志使用 sentry_sdk.logger;对于标准库桥接使用 LoggingIntegration(sentry_logs_level=...) |
| 事务过多 | 降低 traces_sample_rate 或使用 traces_sampler 丢弃健康检查 |
| 跨请求数据泄漏 | 不要使用 get_global_scope() 存储每个请求的数据 — 使用 get_isolation_scope() |
| RQ 工作进程未报告 | 传递 --sentry-dsn="" 以禁用 RQ 自身的 Sentry 快捷方式;通过设置文件进行初始化 |
每周安装次数
198
仓库
GitHub 星标数
82
首次出现
2026年3月1日
安全审计
安装于
codex195
gemini-cli191
github-copilot191
cursor191
kimi-cli190
amp190
All Skills > SDK Setup > Python SDK
Opinionated wizard that scans your Python project and guides you through complete Sentry setup.
sentry-sdk, sentry_sdk, or Sentry + any Python frameworkNote: SDK versions and APIs below reflect Sentry docs at time of writing (sentry-sdk 2.x). Always verify against docs.sentry.io/platforms/python/ before implementing.
Run these commands to understand the project before making recommendations:
# Check existing Sentry
grep -i sentry requirements.txt pyproject.toml setup.cfg setup.py 2>/dev/null
# Detect web framework
grep -rE "django|flask|fastapi|starlette|aiohttp|tornado|quart|falcon|sanic|bottle" \
requirements.txt pyproject.toml 2>/dev/null
# Detect task queues
grep -rE "celery|rq|huey|arq|dramatiq" requirements.txt pyproject.toml 2>/dev/null
# Detect logging libraries
grep -E "loguru" requirements.txt pyproject.toml 2>/dev/null
# Detect AI libraries
grep -rE "openai|anthropic|langchain|huggingface|google-genai|pydantic-ai|litellm" \
requirements.txt pyproject.toml 2>/dev/null
# Detect schedulers / crons
grep -rE "celery|apscheduler|schedule|crontab" requirements.txt pyproject.toml 2>/dev/null
# OpenTelemetry tracing — check for SDK + instrumentations
grep -rE "opentelemetry-sdk|opentelemetry-instrumentation|opentelemetry-distro" \
requirements.txt pyproject.toml 2>/dev/null
grep -rn "TracerProvider\|trace\.get_tracer\|start_as_current_span" \
--include="*.py" 2>/dev/null | head -5
# Check for companion frontend
ls frontend/ web/ client/ ui/ static/ templates/ 2>/dev/null
What to note:
sentry-sdk already in requirements? If yes, check if sentry_sdk.init() is present — may just need feature config.sentry_sdk.init().)Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation:
Route from OTel detection:
opentelemetry-sdk / opentelemetry-distro in requirements, or TracerProvider in source) → use OTLP path: OTLPIntegration(); do not set traces_sample_rate; Sentry links errors to OTel traces automaticallyAlways recommended (core coverage):
ExceptionGroup (Python 3.11+)logging stdlib auto-captured; enhanced if Loguru detectedRecommend when detected:
Recommendation matrix:
| Feature | Recommend when... | Reference |
|---|---|---|
| Error Monitoring | Always — non-negotiable baseline | ${SKILL_ROOT}/references/error-monitoring.md |
| OTLP Integration | OTel tracing detected — replaces native Tracing | ${SKILL_ROOT}/references/tracing.md |
| Tracing | Django/Flask/FastAPI/AIOHTTP/etc. detected; skip if OTel tracing detected | ${SKILL_ROOT}/references/tracing.md |
| Profiling | Production + performance-sensitive workload; skip if OTel tracing detected (requires traces_sample_rate, incompatible with OTLP) |
OTel tracing detected: "I see OpenTelemetry tracing in the project. I recommend Sentry's OTLP integration for tracing (via your existing OTel setup) + Error Monitoring + Sentry Logging [+ Metrics/Crons/AI Monitoring if applicable]. Shall I proceed?"
No OTel: "I recommend Error Monitoring + Tracing [+ Logging if applicable]. Want Profiling, Crons, or AI Monitoring too?"
# 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]"
Extras are optional — plain
sentry-sdkworks for all frameworks. Extras install complementary packages.
Full init enabling the most features with sensible defaults. Place before any app/framework code:
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
environment=os.environ.get("SENTRY_ENVIRONMENT", "production"),
release=os.environ.get("SENTRY_RELEASE"), # e.g. "myapp@1.0.0"
send_default_pii=True,
# Tracing (lower to 0.1–0.2 in high-traffic production)
traces_sample_rate=1.0,
# Profiling — continuous, tied to active spans
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
# Structured logs (SDK ≥ 2.35.0)
enable_logs=True,
)
| Framework | Where to call sentry_sdk.init() | Notes |
|---|---|---|
| Django | Top of settings.py, before any imports | No middleware needed — Sentry patches Django internally |
| Flask | Before app = Flask(__name__) | Must precede app creation |
| FastAPI | Before app = FastAPI() | StarletteIntegration + FastApiIntegration auto-enabled together |
Django example (settings.py):
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
send_default_pii=True,
traces_sample_rate=1.0,
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
enable_logs=True,
)
# rest of Django settings...
INSTALLED_APPS = [...]
FastAPI example (main.py):
import sentry_sdk
sentry_sdk.init(
dsn=os.environ["SENTRY_DSN"],
send_default_pii=True,
traces_sample_rate=1.0,
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
enable_logs=True,
)
from fastapi import FastAPI
app = FastAPI()
Most integrations activate automatically when their package is installed — no integrations=[...] needed:
| Auto-enabled | Explicit required |
|---|---|
| Django, Flask, FastAPI, Starlette, AIOHTTP, Tornado, Quart, Falcon, Sanic, Bottle | DramatiqIntegration |
| Celery, RQ, Huey, ARQ | GRPCIntegration |
| SQLAlchemy, Redis, asyncpg, pymongo | StrawberryIntegration |
| Requests, HTTPX, aiohttp-client | AsyncioIntegration |
| OpenAI, Anthropic, LangChain, Pydantic AI, MCP | OpenTelemetryIntegration |
Python logging, Loguru |
Walk through features one at a time. Load the reference, follow its steps, verify before moving on:
| Feature | Reference file | Load when... |
|---|---|---|
| Error Monitoring | ${SKILL_ROOT}/references/error-monitoring.md | Always (baseline) |
| Tracing | ${SKILL_ROOT}/references/tracing.md | HTTP handlers / distributed tracing |
| Profiling | ${SKILL_ROOT}/references/profiling.md | Performance-sensitive production |
| Logging | ${SKILL_ROOT}/references/logging.md | Always; enhanced for Loguru |
| Metrics | ${SKILL_ROOT}/references/metrics.md |
For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.
sentry_sdk.init() Options| Option | Type | Default | Purpose |
|---|---|---|---|
dsn | str | None | SDK disabled if empty; env: SENTRY_DSN |
environment | str | "production" | e.g., "staging"; env: |
OTLPIntegration Options (pass to constructor)| Option | Type | Default | Purpose |
|---|---|---|---|
setup_otlp_traces_exporter | bool | True | Auto-configure OTLP exporter; set False if you send to your own Collector |
collector_url | str | None | OTLP HTTP endpoint of an OTel Collector (e.g., ); when set, spans are sent to the collector instead of directly to Sentry |
| Variable | Maps to | Notes |
|---|---|---|
SENTRY_DSN | dsn | |
SENTRY_RELEASE | release | Also auto-detected from git SHA, Heroku, CircleCI, CodeBuild, GAE |
SENTRY_ENVIRONMENT | environment | |
SENTRY_DEBUG |
Test that Sentry is receiving events:
# Trigger a real error event — check dashboard within seconds
division_by_zero = 1 / 0
Or for a non-crashing check:
sentry_sdk.capture_message("Sentry Python SDK test")
If nothing appears:
debug=True in sentry_sdk.init() — prints SDK internals to stdoutSENTRY_DSN env var is set in the running processAfter completing Python setup, check for a companion frontend missing Sentry:
ls frontend/ web/ client/ ui/ 2>/dev/null
cat frontend/package.json web/package.json client/package.json 2>/dev/null \
| grep -E '"react"|"svelte"|"vue"|"next"|"nuxt"'
If a frontend exists without Sentry, suggest the matching skill:
| Frontend detected | Suggest skill |
|---|---|
| React / Next.js | sentry-react-sdk |
| Svelte / SvelteKit | sentry-svelte-sdk |
| Vue / Nuxt | Use @sentry/vue — see docs.sentry.io/platforms/javascript/guides/vue/ |
| Other JS/TS | sentry-react-sdk (covers generic browser JS patterns) |
| Issue | Solution |
|---|---|
| Events not appearing | Set debug=True, verify DSN, check env vars in the running process |
| Malformed DSN error | Format: https://<key>@o<org>.ingest.sentry.io/<project> |
| Django exceptions not captured | Ensure sentry_sdk.init() is at the top of settings.py before other imports |
| Flask exceptions not captured | Init must happen before app = Flask(__name__) |
| FastAPI exceptions not captured | Init before app = FastAPI(); both and auto-enabled |
Weekly Installs
198
Repository
GitHub Stars
82
First Seen
Mar 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex195
gemini-cli191
github-copilot191
cursor191
kimi-cli190
amp190
Stripe API 版本升级指南:SDK、Stripe.js 和移动端SDK更新教程
2,400 周安装
RivetKit React客户端:快速连接Rivet Actors的React应用开发工具
2,400 周安装
Django专家技能:模型设计、API开发、性能优化与安全最佳实践指南
2,400 周安装
ontology 本体论技能:类型化知识图谱构建与验证系统
2,400 周安装
RivetKit JavaScript客户端:快速构建连接Rivet Actors的浏览器与Node.js应用
2,400 周安装
OpenClaw 运维配置手册:AI助手网关诊断、修复与健康检查指南
2,300 周安装
${SKILL_ROOT}/references/profiling.md |
| Logging | Always (stdlib); enhanced for Loguru | ${SKILL_ROOT}/references/logging.md |
| Metrics | Business events or SLO tracking needed | ${SKILL_ROOT}/references/metrics.md |
| Crons | Celery Beat, APScheduler, or cron patterns | ${SKILL_ROOT}/references/crons.md |
| AI Monitoring | OpenAI/Anthropic/LangChain/etc. detected | ${SKILL_ROOT}/references/ai-monitoring.md |
| Starlette | Before app = Starlette(...) | Same auto-integration as FastAPI |
| AIOHTTP | Module level, before web.Application() |
| Tornado | Module level, before app setup | No integration class needed |
| Quart | Before app = Quart(__name__) |
| Falcon | Module level, before app = falcon.App() |
| Sanic | Inside @app.listener("before_server_start") | Sanic's lifecycle requires async init |
| Celery | @signals.celeryd_init.connect in worker AND in calling process | Dual-process init required |
| RQ | mysettings.py loaded by worker via rq worker -c mysettings |
| ARQ | Both worker module and enqueuing process |
WSGIIntegration / ASGIIntegration |
| Business KPIs / SLO tracking |
| Crons | ${SKILL_ROOT}/references/crons.md | Scheduler / cron patterns detected |
| AI Monitoring | ${SKILL_ROOT}/references/ai-monitoring.md | AI library detected |
SENTRY_ENVIRONMENTrelease | str | None | e.g., "myapp@1.0.0"; env: SENTRY_RELEASE |
send_default_pii | bool | False | Include IP, headers, cookies, auth user |
traces_sample_rate | float | None | Transaction sample rate; None disables tracing |
traces_sampler | Callable | None | Custom per-transaction sampling (overrides rate) |
profile_session_sample_rate | float | None | Continuous profiling session rate |
profile_lifecycle | str | "manual" | "trace" = auto-start profiler with spans |
profiles_sample_rate | float | None | Transaction-based profiling rate |
enable_logs | bool | False | Send logs to Sentry (SDK ≥ 2.35.0) |
sample_rate | float | 1.0 | Error event sample rate |
attach_stacktrace | bool | False | Stack traces on capture_message() |
max_breadcrumbs | int | 100 | Max breadcrumbs per event |
debug | bool | False | Verbose SDK debug output |
before_send | Callable | None | Hook to mutate/drop error events |
before_send_transaction | Callable | None | Hook to mutate/drop transaction events |
ignore_errors | list | [] | Exception types or regex patterns to suppress |
auto_enabling_integrations | bool | True | Set False to disable all auto-detection |
http://localhost:4318/v1/tracessetup_propagator | bool | True | Auto-configure Sentry propagator for distributed tracing |
capture_exceptions | bool | False | Intercept exceptions recorded via OTel Span.record_exception |
debug |
StarletteIntegrationFastApiIntegration| Celery task errors not captured | Must call sentry_sdk.init() in the worker process via celeryd_init signal |
| Sanic init not working | Init must be inside @app.listener("before_server_start"), not module level |
| uWSGI not capturing | Add --enable-threads --py-call-uwsgi-fork-hooks to uWSGI command |
| No traces appearing (native) | Verify traces_sample_rate is set (not None); check that the integration is auto-enabled |
| No traces appearing (OTLP) | Verify sentry-sdk[opentelemetry-otlp] is installed; do not set traces_sample_rate when using OTLPIntegration |
| Profiling not starting | Requires traces_sample_rate > 0 + either profile_session_sample_rate or profiles_sample_rate; not compatible with OTLP path |
enable_logs not working | Requires SDK ≥ 2.35.0; for direct structured logs use sentry_sdk.logger; for stdlib bridging use LoggingIntegration(sentry_logs_level=...) |
| Too many transactions | Lower traces_sample_rate or use traces_sampler to drop health checks |
| Cross-request data leaking | Don't use get_global_scope() for per-request data — use get_isolation_scope() |
| RQ worker not reporting | Pass --sentry-dsn="" to disable RQ's own Sentry shortcut; init via settings file instead |