Sentry 分类
通过 Composio CLI 将 Sentry 问题、事件和可疑提交直接拉入代理。省去复制-粘贴-堆栈跟踪的繁琐过程。
使用时机
- 收到新的 Sentry 警报时,希望代理进行调查,而不是仅仅引用标题行。
- 诊断回归问题:找到发布版本、可疑提交和受影响文件。
- 构建“前 10 个未解决问题”摘要,包含复现提示。
前置条件
curl -fsSL https://composio.dev/install | bash
composio login
composio link sentry # 需要 event:read + project:read 权限的认证令牌
发现工具
composio search "get sentry issue" --toolkits sentry
composio search "list events for issue" --toolkits sentry
composio tools list sentry
常用操作标识(通过 --get-schema 验证):
SENTRY_GET_AN_ISSUESENTRY_LIST_AN_ISSUES_EVENTSSENTRY_RETRIEVE_AN_EVENT_FOR_A_PROJECTSENTRY_LIST_A_PROJECTS_ISSUESSENTRY_UPDATE_AN_ISSUE
诊断单个问题
- 获取问题(使用短 ID,如
PROJ-1F4或数字 ID):composio execute SENTRY_GET_AN_ISSUE -d '{"issue_id":"PROJ-1F4"}' - 获取最新事件,包含完整堆栈和面包屑:
composio execute SENTRY_LIST_AN_ISSUES_EVENTS \ -d '{"issue_id":"PROJ-1F4","full":true,"limit":1}' - 将每个堆栈帧映射到本地源代码。 对于堆栈中的每个
filename和lineno,代理打开文件并读取 ±20 行。无需手动复制粘贴。 - 检查可疑提交(当设置了版本发布追踪时,Sentry 会附加这些信息)—— 使用
git show <sha>在本地打开它们。 - 提出修复方案,附带 diff,运行测试,测试通过后将问题标记为已解决:
composio execute SENTRY_UPDATE_AN_ISSUE \ -d '{"issue_id":"PROJ-1F4","status":"resolved","statusDetails":{"inNextRelease":true}}'
批量分类
composio execute SENTRY_LIST_A_PROJECTS_ISSUES -d '{
"organization_slug":"acme",
"project_slug":"api",
"query":"is:unresolved age:-24h",
"sort":"freq",
"limit":20
}'
通过管道传递给 jq 以生成排名摘要:
composio execute SENTRY_LIST_A_PROJECTS_ISSUES -d '{"organization_slug":"acme","project_slug":"api","query":"is:unresolved"}' \
| jq -r '.[] | "\(.count)\t\(.shortId)\t\(.title)"' | sort -rn | head
工作流文件
scripts/sentry-diag.ts,使用 composio run --file scripts/sentry-diag.ts -- --id PROJ-1F4 运行:
const id = process.argv[process.argv.indexOf("--id") + 1];
const issue = await execute("SENTRY_GET_AN_ISSUE", { issue_id: id });
const [event] = await execute("SENTRY_LIST_AN_ISSUES_EVENTS", {
issue_id: id, full: true, limit: 1
});
const frames = (event?.entries ?? [])
.filter(e => e.type === "exception")
.flatMap(e => e.data.values.flatMap(v => v.stacktrace?.frames ?? []))
.filter(f => f.inApp)
.map(f => ({ file: f.filename, line: f.lineno, fn: f.function }));
console.log(JSON.stringify({ title: issue.title, culprit: issue.culprit, frames }, null, 2));
然后代理读取每个 file 在 line ± 20 的位置,并草拟补丁。
路由到 Linear / Slack
链式调用工具,为最严重的未解决问题创建工单:
composio run '
const [top] = await execute("SENTRY_LIST_A_PROJECTS_ISSUES", {
organization_slug: "acme", project_slug: "api",
query: "is:unresolved", sort: "freq", limit: 1
});
await execute("LINEAR_CREATE_ISSUE", {
teamId: "TEAM_ID",
title: `[Sentry] ${top.title}`,
description: `Short ID: ${top.shortId}\nPermalink: ${top.permalink}\nCount: ${top.count}`
});
'
故障排除
404 on issue_id→ 使用短 ID(如PROJ-1F4),而不是 URL 路径格式。- 空事件 → 问题已解决/归档;使用
query:"is:resolved"查询或增加limit。 - 缺少可疑提交 → Sentry 中未配置版本发布追踪;在 CI 中设置
sentry-cli releases。 - 没有
inApp帧 → 未上传 source map;堆栈将仅显示供应商代码。
完整的 CLI 参考: docs.composio.dev/docs/cli