跳到正文
cccskills
免费在 GitHub 公开

api-observability-axiom-pino-sentry

Pino logging, Sentry error tracking, Axiom - structured logging with correlation IDs, error boundaries, performance monitoring, alerting

中文简介正在准备中。当前显示原文说明。

集成工具Sentry

实测评分 未实测

查看安装方法

包含的文件(10)

  • SKILL.md10.2 KB
  • examples/axiom.md2.9 KB
  • examples/core.md3.3 KB
  • examples/correlation-ids.md5.7 KB
  • examples/error-boundaries.md6.3 KB
  • examples/performance.md2.9 KB
  • examples/sentry-config.md4.7 KB
  • examples/tracing.md2.2 KB
  • metadata.yaml390 B
  • reference.md11.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Observability Patterns (Logging, Tracing, Error Handling)

Quick Guide: Structured logging with Pino (debug/info/warn/error). Correlation IDs for request tracing. Sentry error boundaries in React. Attach user context after auth. Filter expected errors (404s). Create Axiom monitors for alerts.


<critical_requirements>

CRITICAL: Before Using This Skill

(You MUST include correlation ID in ALL log statements for request tracing)

(You MUST use structured logging with required fields: level, message, correlationId, timestamp)

(You MUST filter expected errors (404, validation) from Sentry to avoid quota waste)

(You MUST attach user context to Sentry AFTER authentication completes)

(You MUST use child loggers with context instead of repeating fields in every log call)

</critical_requirements>


Auto-detection: log, logger, pino, Sentry, error boundary, correlation ID, trace, span, observability, monitoring, alerting

When to use:

  • Adding logging to new feature code
  • Implementing error handling patterns
  • Setting up request tracing with correlation IDs
  • Creating custom traces and spans for performance debugging
  • Configuring Sentry error boundaries in React components
  • Creating Axiom monitors and alerts

When NOT to use:

  • Initial project setup and dependency installation (one-time setup; follow official docs)
  • Framework-specific configuration files (follow framework SDK docs)

Key patterns covered:

  • Log levels decision tree (when to use debug/info/warn/error)
  • Structured logging with required fields
  • Correlation IDs: generating, propagating, attaching to logs
  • Custom traces/spans with OpenTelemetry
  • Sentry error boundaries in React
  • Attaching user context to Sentry after auth
  • Creating Axiom monitors and alerts
  • Filtering noise (expected errors like 404s)
  • Performance monitoring patterns
  • Debugging guide: tracing a request through the system

Detailed Resources:

Extended Examples:


<philosophy>

Philosophy

Good observability answers three questions:

  1. What happened? (Structured logs with context)
  2. Why did it happen? (Error tracking with stack traces)
  3. How do I find it? (Correlation IDs linking related events)

Logging should be intentional, not defensive. Every log statement should answer a specific question you might ask when debugging. Avoid logging "just in case" - it creates noise that makes real issues harder to find.

</philosophy>
<patterns>

Core Patterns

Pattern 1: Log Levels Decision Tree

Choose the appropriate log level based on the situation.

What are you logging?
├─ Development-only debugging info?
│   └─ debug (filtered in production)
├─ Normal operation events?
│   ├─ Request started/completed → info
│   ├─ User action completed → info
│   └─ Background job finished → info
├─ Something unexpected but recoverable?
│   ├─ Retry attempt → warn
│   ├─ Fallback used → warn
│   └─ Deprecation notice → warn
└─ Something that needs attention?
    ├─ Unhandled exception → error
    ├─ External service failure → error
    └─ Data integrity issue → error

Level Guidelines:

LevelProductionWhen to Use
debugFilteredDevelopment debugging, verbose tracing
infoVisibleNormal operations, request lifecycle, user actions
warnVisibleRecoverable issues, retries, fallbacks
errorVisible + AlertUnrecoverable issues, failures, exceptions

For code examples, see examples/core.md.


Pattern 2: Structured Logging with Required Fields

Every log statement should include structured context for searchability.

Required Fields:

FieldTypePurpose
correlationIdstringLinks all logs from same request
servicestringIdentifies the service (api, web, worker)
operationstringWhat action is being performed
userIdstring?User performing the action (if authenticated)
durationnumber?Time taken in milliseconds (for completed operations)

For code examples, see examples/core.md.


Pattern 3: Correlation IDs for Request Tracing

Generate and propagate correlation IDs to trace requests across services.

Key Components:

  1. Correlation ID Middleware - Generates/extracts correlation ID from headers
  2. Request Logger Middleware - Creates request-scoped logger with correlation context
  3. Route Handler Usage - Child loggers inherit correlation ID automatically

Modern Alternative: AsyncLocalStorage + Mixin

For larger applications, use AsyncLocalStorage with Pino's mixin option for automatic context injection without manual child logger creation in every handler.

For implementation examples of both approaches, see examples/correlation-ids.md.


Pattern 4: Custom Traces and Spans with OpenTelemetry

Add custom instrumentation for performance debugging.

Key Utilities:

  • withSpan() - Wrap async operations in traced spans
  • createSpan() - Create simple spans for synchronous operations

For code examples, see examples/tracing.md.


Pattern 5: Sentry Error Boundaries in React

Catch and report React component errors with recovery capability.

Key Components:

  1. ErrorBoundary - Class component for catching render errors
  2. global-error.tsx - SSR framework global error handler
  3. Feature-level boundaries - Wrap feature sections with custom fallbacks

For implementation examples, see examples/error-boundaries.md.


Pattern 6: Attaching User Context to Sentry

Add user information to Sentry after authentication for better debugging.

Key Functions:

  • setSentryUser() - Call after successful authentication
  • clearSentryUser() - Call on logout
  • setSentryContext() - Add additional context per-feature

For code examples, see examples/sentry-config.md.


Pattern 7: Filtering Expected Errors

Prevent expected errors from polluting Sentry quota and alerts.

Filtering Strategies:

  1. beforeSend hook - Filter by error message patterns
  2. HTTP status filtering - Skip 404, 401, 403
  3. beforeBreadcrumb hook - Remove noisy console.log breadcrumbs

For configuration examples, see examples/sentry-config.md.


Pattern 8: Creating Axiom Monitors and Alerts

Set up proactive monitoring for production issues.

Monitor Types:

  1. Error Rate Monitor - Alert when error rate > 1%
  2. Latency Monitor - Alert when P95 > 2 seconds
  3. Specific Error Monitor - Alert on database connection errors

For APL query examples, see examples/axiom.md.


Pattern 9: Performance Monitoring Patterns

Track and optimize slow operations.

Tracking Utilities:

  • trackedQuery() - Wrap database queries with performance tracking
  • trackedApiCall() - Wrap external API calls with performance tracking

For implementation examples, see examples/performance.md.


Pattern 10: Debugging Guide - Tracing a Request

How to trace a request through the system when debugging.

Steps:

  1. Get correlation ID from response headers, Sentry, or user report
  2. Search Axiom for all logs with that correlation ID
  3. Analyze request flow with timeline view
  4. Find related errors and stack traces
  5. Check Sentry for additional context

For detailed APL queries and checklist, see examples/axiom.md.

</patterns>

<red_flags>

RED FLAGS

For comprehensive anti-patterns and red flags, see reference.md.

Quick Reference - High Priority Issues:

  • Missing correlation ID in logs - Impossible to trace requests
  • Using console.log instead of structured logger - Not searchable, no levels
  • Logging sensitive data - Security vulnerability
  • Not filtering expected errors in Sentry - Wastes quota, buries real issues
  • Error logs without stack traces - Can't debug without knowing where error occurred

</red_flags>


<critical_reminders>

CRITICAL REMINDERS

(You MUST include correlation ID in ALL log statements for request tracing)

(You MUST use structured logging with required fields: level, message, correlationId, timestamp)

(You MUST filter expected errors (404, validation) from Sentry to avoid quota waste)

(You MUST attach user context to Sentry AFTER authentication completes)

(You MUST use child loggers with context instead of repeating fields in every log call)

Failure to follow these rules will result in untraceable requests, wasted Sentry quota, and impossible debugging.

</critical_reminders>

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming, embeddings, image generation, audio transcription, translation, summarization, and Inference Endpoints

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

LiteLLM proxy server setup, TypeScript client patterns via OpenAI SDK, model routing, fallbacks, load balancing, spend tracking, virtual keys, and production deployment

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

Serverless GPU compute platform for AI model deployment — web endpoints, GPU functions, model serving, and TypeScript client patterns

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output, model management, and OpenAI-compatible endpoint

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

Replicate SDK patterns for TypeScript/Node.js -- client setup, predictions, streaming, webhooks, file handling, model versioning, deployments, and training

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling, embeddings, image generation, fine-tuning, and OpenAI-compatible endpoints

中文简介正在准备中。当前显示原文说明。

agents-inc/skills252026年10月23日 更新

查看 agents-inc 的全部技能

报告此技能的问题