大模型应用
用 Composio CLI 拉取 Sentry…
当收到 Sentry 告警需要排查单个或批量问题时,通过 Composio CLI 拉取 issue、事件、面包屑和可疑提交,并映射到本地源码提出修复。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
用 Composio CLI 拉取 Se特定
解决思路
- 安装并登录 Composio CLI:运行 `curl -fsSL https://composio.dev/install | bash`,然后 `composio login`,再 `composio link sentry` 授权(token 需含 event:read + project:read)。
- 发现可用工具:用 `composio search "get sentry issue" --toolkits sentry`、`composio search "list events for issue" --toolkits sentry`、`composio tools list sentry` 查找;常用 slug 有 `SENTRY_GET_AN_ISSUE`、`SENTRY_LIST_AN_ISSUES_EVENTS`、`SENTRY_RETRIEVE_AN_EVENT_FOR_A_PROJECT`、`SENTRY_LIST_A_PROJECTS_ISSUES`、`SENTRY_UPDATE_AN_ISSUE`,用 `--get-schema` 校验。
- 诊断单个 issue 第一步:按 short ID(如 `PROJ-1F4`)或数字 ID 拉取 issue:`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}'`。
- 第三步:把堆栈中每个 frame 的 `filename` + `lineno` 映射到本地源码,打开对应文件并读取上下各 20 行,无需手动复制粘贴。
- 第四步:检查可疑提交(Sentry 在配置 release tracking 时会附带),在本地用 `git show <sha>` 打开查看。
- 第五步:提出带 diff 的修复,运行测试,通过后标记 issue 为已解决:`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` 运行;脚本读取 `--id` 参数,调用 `SENTRY_GET_AN_ISSUE` 和 `SENTRY_LIST_AN_ISSUES_EVENTS`,过滤 exception 类型条目、展开 stacktrace frames、仅保留 `inApp` 帧,输出 title、culprit 和 frames 的 JSON。
- 拿到 frames 后,agent 读取每个 `file` 的 `line ± 20` 行并起草补丁。
- 路由到 Linear/Slack:用 `composio run` 链式调用,先取最高频未解决问题,再调用 `LINEAR_CREATE_ISSUE` 创建工单,标题为 `[Sentry] ${top.title}`,描述包含 shortId、permalink 和 count。
- 排障:`404 on issue_id` 时改用 short ID(如 `PROJ-1F4`)而非 URL slug;事件为空说明 issue 已解决或归档,改用 `query:"is:resolved"` 或增大 `limit`;缺少 suspect commit 说明 Sentry 未配置 release tracking,需在 CI 中设置 `sentry-cli releases`;没有 `inApp` 帧说明 source maps 未上传,堆栈只显示 vendor 代码。
适用边界 · 注意事项
- 未安装或未登录 Composio CLI、未授权 Sentry 时无法使用。
- Sentry 未配置 release tracking 时无法获取可疑提交。
- 未上传 source maps 时堆栈只显示 vendor 代码,无法映射到本地源码。