本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)10k · #12032

error-tracking

できること

このスキルは、エラーをレビュー用に送信するよう、コード内でオンラインのエラー追跡サービスであるSentryを設定します。Webサービスを運用し、失敗や遅い呼び出しを把握したい開発者に向けたものです。

使う場面

  • ✓サービスにエラー処理を追加する、または新しいコントローラーを作成するとき。
  • ✓定期実行されるジョブに、失敗を報告させたいとき。
  • ✓遅いデータベース呼び出しを追跡したい、またはパフォーマンスのスパンを追加したいとき。

スキルのリンク

https://github.com/diet103/claude-code-infrastructure-showcase/blob/main/.agents/skills/error-tracking/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/diet103/claude-code-infrastructure-showcase/blob/main/.agents/skills/error-tracking/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“新しいコントローラーにSentryのエラー追跡を追加して、すべてのエラーがSentryに送信されるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、エラーとパフォーマンスのデータをSentryに送るための標準的なパターンを示します。エラーはログに残すだけでなく必ず報告するよう、AIに注意を促し、コントローラー、ルート、バックグラウンドジョブを扱います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Sentry Integration Skill

Purpose

This skill enforces comprehensive Sentry error tracking and performance monitoring across all services following Sentry v8 patterns.

When to Use This Skill

  • Adding error handling to any code
  • Creating new controllers or routes
  • Instrumenting cron jobs
  • Tracking database performance
  • Adding performance spans
  • Handling workflow errors

🚨 CRITICAL RULE

ALL ERRORS MUST BE CAPTURED TO SENTRY - No exceptions. Never use console.error alone.

Current Status

Example: API Service ✅ Complete

  • Sentry v8 fully integrated
  • All workflow errors tracked
  • Background job processors instrumented
  • Test endpoints available

Sentry Integration Patterns

1. Controller Error Handling

// ✅ CORRECT - Use BaseController
import { BaseController } from '../controllers/BaseController';

export class MyController extends BaseController {
    async myMethod() {
        try {
            // ... your code
        } catch (error) {
            this.handleError(error, 'myMethod'); // Automatically sends to Sentry
        }
    }
}

2. Route Error Handling (Without BaseController)

import * as Sentry from '@sentry/node';

router.get('/route', async (req, res) => {
    try {
        // ... your code
    } catch (error) {
        Sentry.captureException(error, {
            tags: { route: '/route', method: 'GET' },
            extra: { userId: req.user?.id }
        });
        res.status(500).json({ error: 'Internal server error' });
    }
});

3. Workflow Error Handling

Example of a domain-specific Sentry helper from the original production project. If you build a helper like this for your domain, the call site looks like:

import { WorkflowSentryHelper } from '../workflow/utils/sentryHelper';

WorkflowSentryHelper.captureWorkflowError(error, {
    workflowCode: 'INVOICE_APPROVAL',
    instanceId: 123,
    stepId: 456,
    userId: 'user-123',
    operation: 'stepCompletion',
    metadata: { additionalInfo: 'value' }
});

Without a helper, plain Sentry works everywhere:

Sentry.captureException(error, {
    tags: { operation: 'stepCompletion' },
    extra: { workflowCode: 'INVOICE_APPROVAL', instanceId: 123, userId: 'user-123' }
});

4. Cron Jobs (MANDATORY Pattern)

#!/usr/bin/env node
// FIRST LINE after shebang - CRITICAL!
import '../instrument';
import * as Sentry from '@sentry/node';

async function main() {
    return await Sentry.startSpan({
        name: 'cron.job-name',
        op: 'cron',
        attributes: {
            'cron.job': 'job-name',
            'cron.startTime': new Date().toISOString(),
        }
    }, async () => {
        try {
            // Your cron job logic
        } catch (error) {
            Sentry.captureException(error, {
                tags: {
                    'cron.job': 'job-name',
                    'error.type': 'execution_error'
                }
            });
            console.error('[Job] Error:', error);
            process.exit(1);
        }
    });
}

main()
    .then(() => {
        console.log('[Job] Completed successfully');
        process.exit(0);
    })
    .catch((error) => {
        console.error('[Job] Fatal error:', error);
        process.exit(1);
    });

5. Database Performance Monitoring

Example from the original production project - a small helper that wraps DB calls in Sentry spans. Adapt to your codebase:

import { DatabasePerformanceMonitor } from '../utils/databasePerformance';

const result = await DatabasePerformanceMonitor.withPerformanceTracking(
    'findMany',
    'UserProfile',
    async () => {
        return await PrismaService.main.userProfile.findMany({
            take: 5,
        });
    }
);

The universally-available equivalent is a direct Sentry span:

const result = await Sentry.startSpan({
    name: 'db.userProfile.findMany',
    op: 'db.query',
    attributes: { 'db.model': 'UserProfile', 'db.operation': 'findMany' }
}, async () => {
    return await prisma.userProfile.findMany({ take: 5 });
});

6. Async Operations with Spans

import * as Sentry from '@sentry/node';

const result = await Sentry.startSpan({
    name: 'operation.name',
    op: 'operation.type',
    attributes: {
        'custom.attribute': 'value'
    }
}, async () => {
    // Your async operation
    return await someAsyncOperation();
});

Error Levels

よくある質問

Sentryとは何ですか?

Sentryは、ソフトウェアからエラーを収集し、開発者に表示するオンラインサービスです。

エラーをコンソールに記録するだけですか?

いいえ。スキルは、エラーをコンソールだけに書くのではなく、Sentryに送信しなければならないとしています。

バックグラウンドジョブも対象ですか?

はい。スキルには、定期ジョブやバックグラウンド処理の指針が含まれています。

詳細

作者による元の説明

Add Sentry v8 error tracking and performance monitoring to your services. Use this skill when adding error handling, creating new controllers, instrumenting cron jobs, or tracking database performance. ALL ERRORS MUST BE CAPTURED TO SENTRY - no exceptions.

repo: diet103/claude-code-infrastructure-showcase

人気

GitHubのスター
10k
ランキング
#12032
ライセンス
MIT
更新日
2026/7/13

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

似ているスキル