技能 error-debugging-error-trace
🔍

error-debugging-error-trace

安全

使用 Sentry 实现错误追踪

生产环境中的错误如果没有适当的监控很难被发现。本技能帮助您设置 Sentry 和其他错误追踪系统,以便在用户反馈之前检测、分类和解决问题。

支持: Claude Codex Code(CC)
🥉 72 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“error-debugging-error-trace”。 Set up Sentry for my Express API

预期结果:

我将为您的 Express API 设置 Sentry 错误追踪。这涉及安装 SDK、使用您的 DSN 初始化它,并配置它以捕获未处理的异常和 Promise 拒绝。

正在使用“error-debugging-error-trace”。 Configure alerts for critical errors

预期结果:

我将创建告警规则,在发生关键错误时通过 Slack 通知您的团队。这包括设置特定于环境的规则和定义严重阈值。

安全审计

安全
v1 • 2/24/2026

All 35 static findings are false positives. The backtick characters flagged are JavaScript template literals, not shell execution. Network calls are legitimate error tracking API communications. Environment access patterns are configuration objects, not secret exfiltration. This is a legitimate error monitoring implementation guide.

2
已扫描文件
1,408
分析行数
4
发现项
1
审计总数
中风险问题 (3)
JavaScript Template Literals Misidentified as Shell Execution
Static analyzer incorrectly flagged JavaScript backtick characters as Ruby shell backtick execution. Backticks in this code are used for template literals (string interpolation), a standard JavaScript feature. No shell execution occurs.
Network Calls Are Legitimate Error Tracking
Fetch API and SSE connections are used for sending error events to configured error tracking endpoints. This is the core intended functionality of an error monitoring skill, not data exfiltration.
Configuration Access Misidentified as Environment Variable Access
The 'this.config' pattern flagged as env_access is a configuration object, not process.env. Additionally, the sensitive key sanitization is a security feature that prevents logging secrets.
低风险问题 (1)
Codebase Analysis Patterns
Static analyzer flagged code pattern analysis as 'system reconnaissance'. This is the intended functionality - analyzing error handling patterns in a codebase for monitoring implementation.
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
88
安全
91
规范符合性

你能构建什么

为新的 Node.js API 添加错误追踪

从零开始为 REST API 设置 Sentry,配置源映射,并为 5xx 错误创建告警

改进现有错误处理

分析当前错误模式,实施结构化日志记录,减少来自不可操作错误的噪音

创建可观测性仪表板

构建具有趋势分析和团队告警工作流程的实时错误监控仪表板

试试这些提示

基础 Sentry 设置
为我的 Node.js 应用程序设置 Sentry 错误追踪。项目位于 /app,使用 Express。配置它以捕获未处理的拒绝和异常,环境为 'production'。
配置错误分组
我们的 Sentry 仪表板有太多重复错误。设置自定义指纹以根据错误消息和堆栈跟踪模式将相似错误分组在一起。向我展示如何在 SDK 中配置此项。
告警路由设置
为我们的团队配置 Sentry 告警。将关键错误(5xx 响应)路由到 Slack #incidents,警告路由到 #engineering,速率限制路由到 #alerts-oncall。使用基于环境的规则。
结构化日志迁移
将我们的 console.log 语句迁移到与 Sentry 兼容的结构化日志。在每个日志语句的上下文中包含请求 ID、用户 ID 和操作名称。

最佳实践

  • 在可用时始终包含用户上下文(ID、邮箱),以帮助调试用户特定的问题
  • 使用基于环境的 DSN 配置将生产环境错误与开发环境错误分开
  • 实施版本追踪以将错误与特定部署关联起来

避免

  • 捕获完整请求正文而未清理密码等敏感字段
  • 在高流量期间设置采样率过高导致账单激增
  • 忽略重复错误而未进行适当的指纹配置

常见问题

本技能支持哪些语言和框架?
本技能涵盖 Node.js、Python 和 Web JavaScript。示例使用 Sentry,但概念适用于其他服务如 Rollbar 和 Bugsnag。
我需要 Sentry 账户吗?
是的,您需要 Sentry 账户和项目 DSN。免费套餐每月覆盖 5k 错误,对于小型项目来说足够了。
本技能能帮助进行性能监控吗?
是的,实现手册包含性能监控设置,带有追踪和性能分析配置。
如何处理错误中的敏感数据?
使用 beforeSend 钩子来清理事件。该技能包含过滤密码、令牌和密钥字段的示例。
这是否适用于自托管错误追踪?
是的,您可以使用自托管 Sentry 或任何与 Sentry SDK 协议兼容的服务,只需指向您自己的 DSN 即可。
如何调试 Sentry 未捕获的错误?
确保 SDK 在其他中间件之前初始化,验证 DSN 正确,并确保采样率未设置为 0。