AgentSkillsCN

sentry-and-monitoring

监控集成模式(错误捕获、上下文记录与性能追踪)。关键词:监控、Sentry、错误追踪、追踪、跨度、可观测性。

SKILL.md
--- frontmatter
name: sentry-and-monitoring
description: "Monitoring integration patterns (error capture, context, and performance spans). Keywords: monitoring, sentry, error tracking, tracing, spans, observability."

Monitoring, Error Tracking, and Performance

This skill provides backend-focused monitoring patterns (error capture + tracing/spans).


Core rules

  1. Initialize monitoring early (before app logic).
  2. Capture exceptions with useful context (route, layer, correlation id).
  3. Use spans around slow or critical operations (DB, external APIs).
  4. Redact secrets and sensitive fields.

Request lifecycle instrumentation

Recommended ordering:

  1. Monitoring request handler / tracing
  2. Body parsing
  3. Request context (correlation id)
  4. Routes
  5. Error boundary (last)
  6. Monitoring error handler (last)

Capturing exceptions (example)

ts
try {
  await operation();
} catch (err) {
  monitor.captureException(err, { tags: { layer: "service", operation: "operation" } });
  throw err;
}

Performance spans (example)

ts
return monitor.startSpan({ name: "db.user.findByEmail", op: "db" }, async () => {
  return await userRepository.findByEmail(email);
});

Related Skills

  • error-tracking (in repo/)