Token导航 LogoToken导航TokenDH.com
前端设计external-servicegithub未标认证来源可访问许可证需确认审计提醒

sentry-python-sdkSentry Python SDK 测试

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

3,011

周安装

128

GitHub Stars

19

下载量

1,055
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:sentry-python-sdk(Sentry Python SDK 测试)
来源仓库:https://github.com/getsentry/sentry-agent-skills
仓库路径:skills/sentry-python-sdk
安装命令:
npx skills add https://github.com/getsentry/sentry-agent-skills --skill sentry-python-sdk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/getsentry/sentry-agent-skills --skill sentry-python-sdk

简介

sentry-python-sdk 辅助 Python 项目开发、测试和依赖管理,适合阅读代码和分析数据处理逻辑。

  • 可用于定位测试问题、整理运行命令或生成脚本。
  • 需确认项目虚拟环境、依赖版本和测试入口后再使用。
  • 执行脚本或访问外部资源时,应明确运行目录和输入输出范围。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Sentry Python SDK

Opinionated wizard that scans your Python project and guides you through complete Sentry setup.

Invoke This Skill When

  • User asks to "add Sentry to Python" or "setup Sentry" in a Python app
  • User wants error monitoring, tracing, profiling, logging, metrics, or crons in Python
  • User mentions sentry-sdk, sentry_sdk, or Sentry + any Python framework
  • User wants to monitor Django views, Flask routes, FastAPI endpoints, Celery tasks, or scheduled jobs
Note: 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.

Phase 1: Detect

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

# Check for companion frontend
ls frontend/ web/ client/ ui/ static/ templates/ 2>/dev/null

What to note:

  • Is sentry-sdk already in requirements? If yes, check if sentry_sdk.init() is present — may just need feature config.
  • Which framework? (Determines where to place sentry_sdk.init().)
  • Which task queue? (Celery needs dual-process init; RQ needs a settings file.)
  • AI libraries? (OpenAI, Anthropic, LangChain are auto-instrumented.)
  • Companion frontend? (Triggers Phase 4 cross-link.)

Phase 2: Recommend

Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation:

Always recommended (core coverage):

  • Error Monitoring — captures unhandled exceptions, supports ExceptionGroup (Python 3.11+)
  • Logging — Python logging stdlib auto-captured; enhanced if Loguru detected

Recommend when detected:

  • Tracing — HTTP framework detected (Django/Flask/FastAPI/etc.)
  • AI Monitoring — OpenAI/Anthropic/LangChain/etc. detected (auto-instrumented, zero config)
  • Profiling — production apps where performance matters
  • Crons — Celery Beat, APScheduler, or cron patterns detected
  • Metrics — business KPIs, SLO tracking

Recommendation matrix:

FeatureRecommend when...Reference
Error MonitoringAlways — non-negotiable baseline${SKILL_ROOT}/references/error-monitoring.md
TracingDjango/Flask/FastAPI/AIOHTTP/etc. detected${SKILL_ROOT}/references/tracing.md
ProfilingProduction + performance-sensitive workload${SKILL_ROOT}/references/profiling.md
LoggingAlways (stdlib); enhanced for Loguru${SKILL_ROOT}/references/logging.md
MetricsBusiness events or SLO tracking needed${SKILL_ROOT}/references/metrics.md
CronsCelery Beat, APScheduler, or cron patterns${SKILL_ROOT}/references/crons.md
AI MonitoringOpenAI/Anthropic/LangChain/etc. detected${SKILL_ROOT}/references/ai-monitoring.md

Propose: *"I recommend Error Monitoring + Tracing [+ Logging if applicable]. Want Profiling, Crons, or AI Monitoring too?"*


Phase 3: Guide

Install

# 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-sdk works for all frameworks. Extras install complementary packages.

Quick Start — Recommended Init

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,
)

Where to Initialize Per Framework

FrameworkWhere to call sentry_sdk.init()Notes
DjangoTop of settings.py, before any importsNo middleware needed — Sentry patches Django internally
FlaskBefore app = Flask(__name__)Must precede app creation
FastAPIBefore app = FastAPI()StarletteIntegration + FastApiIntegration auto-enabled together
StarletteBefore app = Starlette(...)Same auto-integration as FastAPI
AIOHTTPModule level, before web.Application()
TornadoModule level, before app setupNo integration class needed
QuartBefore app = Quart(__name__)
FalconModule level, before app = falcon.App()
SanicInside @app.listener("before_server_start")Sanic's lifecycle requires async init
Celery@signals.celeryd_init.connect in worker AND in calling processDual-process init required
RQmysettings.py loaded by worker via rq worker -c mysettings
ARQBoth worker module and enqueuing process

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()

Auto-Enabled vs Explicit Integrations

Most integrations activate automatically when their package is installed — no integrations=[...] needed:

Auto-enabledExplicit required
Django, Flask, FastAPI, Starlette, AIOHTTP, Tornado, Quart, Falcon, Sanic, BottleDramatiqIntegration
Celery, RQ, Huey, ARQGRPCIntegration
SQLAlchemy, Redis, asyncpg, pymongoStrawberryIntegration
Requests, HTTPX, aiohttp-clientAsyncioIntegration
OpenAI, Anthropic, LangChain, Pydantic AI, MCPOpenTelemetryIntegration
Python logging, LoguruWSGIIntegration / ASGIIntegration

For Each Agreed Feature

Walk through features one at a time. Load the reference, follow its steps, verify before moving on:

FeatureReference fileLoad when...
Error Monitoring${SKILL_ROOT}/references/error-monitoring.mdAlways (baseline)
Tracing${SKILL_ROOT}/references/tracing.mdHTTP handlers / distributed tracing
Profiling${SKILL_ROOT}/references/profiling.mdPerformance-sensitive production
Logging${SKILL_ROOT}/references/logging.mdAlways; enhanced for Loguru
Metrics${SKILL_ROOT}/references/metrics.mdBusiness KPIs / SLO tracking
Crons${SKILL_ROOT}/references/crons.mdScheduler / cron patterns detected
AI Monitoring${SKILL_ROOT}/references/ai-monitoring.mdAI library detected

For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.


Configuration Reference

Key sentry_sdk.init() Options

OptionTypeDefaultPurpose
dsnstrNoneSDK disabled if empty; env: SENTRY_DSN
environmentstr"production"e.g., "staging"; env: SENTRY_ENVIRONMENT
releasestrNonee.g., "myapp@1.0.0"; env: SENTRY_RELEASE
send_default_piiboolFalseInclude IP, headers, cookies, auth user
traces_sample_ratefloatNoneTransaction sample rate; None disables tracing
traces_samplerCallableNoneCustom per-transaction sampling (overrides rate)
profile_session_sample_ratefloatNoneContinuous profiling session rate
profile_lifecyclestr"manual""trace" = auto-start profiler with spans
profiles_sample_ratefloatNoneTransaction-based profiling rate
enable_logsboolFalseSend logs to Sentry (SDK ≥ 2.35.0)
sample_ratefloat1.0Error event sample rate
attach_stacktraceboolFalseStack traces on capture_message()
max_breadcrumbsint100Max breadcrumbs per event
debugboolFalseVerbose SDK debug output
before_sendCallableNoneHook to mutate/drop error events
before_send_transactionCallableNoneHook to mutate/drop transaction events
ignore_errorslist[]Exception types or regex patterns to suppress
auto_enabling_integrationsboolTrueSet False to disable all auto-detection

Environment Variables

VariableMaps toNotes
SENTRY_DSNdsn
SENTRY_RELEASEreleaseAlso auto-detected from git SHA, Heroku, CircleCI, CodeBuild, GAE
SENTRY_ENVIRONMENTenvironment
SENTRY_DEBUGdebug

Verification

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:

  1. Set debug=True in sentry_sdk.init() — prints SDK internals to stdout
  2. Verify the DSN is correct
  3. Check SENTRY_DSN env var is set in the running process
  4. For Celery/RQ: ensure init runs in the worker process, not just the calling process

Phase 4: Cross-Link

After 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 detectedSuggest skill
React / Next.jssentry-react-sdk
Svelte / SvelteKitsentry-svelte-sdk
Vue / NuxtUse @sentry/vue — see docs.sentry.io/platforms/javascript/guides/vue/
Other JS/TSsentry-react-sdk (covers generic browser JS patterns)

Troubleshooting

IssueSolution
Events not appearingSet debug=True, verify DSN, check env vars in the running process
Malformed DSN errorFormat: https://<key>@o<org>.ingest.sentry.io/<project>
Django exceptions not capturedEnsure sentry_sdk.init() is at the top of settings.py before other imports
Flask exceptions not capturedInit must happen before app = Flask(__name__)
FastAPI exceptions not capturedInit before app = FastAPI(); both StarletteIntegration and FastApiIntegration auto-enabled
Celery task errors not capturedMust call sentry_sdk.init() in the worker process via celeryd_init signal
Sanic init not workingInit must be inside @app.listener("before_server_start"), not module level
uWSGI not capturingAdd --enable-threads --py-call-uwsgi-fork-hooks to uWSGI command
No traces appearingVerify traces_sample_rate is set (not None); check that the integration is auto-enabled
Profiling not startingRequires traces_sample_rate > 0 + either profile_session_sample_rate or profiles_sample_rate
enable_logs not workingRequires SDK ≥ 2.35.0; for direct structured logs use sentry_sdk.logger; for stdlib bridging use LoggingIntegration(sentry_logs_level=...)
Too many transactionsLower traces_sample_rate or use traces_sampler to drop health checks
Cross-request data leakingDon't use get_global_scope() for per-request data — use get_isolation_scope()
RQ worker not reportingPass --sentry-dsn="" to disable RQ's own Sentry shortcut; init via settings file instead

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.58%
按下载量换算407

Claude

29.22%
按下载量换算308

Cursor

18.89%
按下载量换算199

Gemini CLI

10.38%
按下载量换算110

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills