AI

OSSのエラートラッキング比較:Sentry vs GlitchTip でアプリのバグを即座に検知する

オープンソースラボ編集部2026年6月13日

OSSのエラートラッキング比較:Sentry vs GlitchTip vs OpenTelemetry でアプリのバグを即座に検知する

Sentry(月$26〜)・Rollbar(月$59〜)に対して、GlitchTip(Sentry互換・セルフホスト最軽量)・Sentry OSS(Sentry公式のセルフホスト版)・OpenTelemetry Logs(ベンダー非依存の標準)はOSSのエラートラッキングソリューションです。

エラートラッキングが解決する問題

console.log・ユーザー報告に頼った障害検知からの脱却:

  • リアルタイムアラート: 本番でNullPointerException → Slackに即時通知
  • エラーの重複集約: 同じエラーが1000回起きても1つのissueとして管理
  • スタックトレース: エラーが起きたファイル・行番号・変数の値を記録
  • ユーザー影響度: 「このエラーで100名のユーザーが影響を受けている」を可視化
  • リリース追跡: 新しいデプロイ後にエラーレートが増加したことを即検知

主要ツールの概要

GlitchTip

2020年に公開されたPython/Django製のOSSエラートラッキングツールです。GitHubスター1.5k+。Sentry SDKと完全互換のエンドポイントをセルフホストで提供し、Sentryの公式クラウドより軽量・低コストです。Docker Composeで起動でき、PostgreSQL・Redis・S3(MinIO)構成です。エラー集約・通知・リリーストラッキング・パフォーマンスモニタリング基本機能を提供します。

# docker-compose.yml - GlitchTip セルフホスト
version: '3.8'
services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: glitchtip
      POSTGRES_USER: glitchtip
      POSTGRES_PASSWORD: glitchtip_password
    volumes:
      - pg_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine

  web:
    image: glitchtip/glitchtip:latest
    depends_on: [postgres, redis]
    ports:
      - "8000:8000"
    environment:
      DATABASE_URL: postgresql://glitchtip:glitchtip_password@postgres/glitchtip
      SECRET_KEY: your-secret-key-here
      REDIS_URL: redis://redis:6379
      EMAIL_URL: smtp://user:password@smtp.yourcompany.com:587
      GLITCHTIP_DOMAIN: https://errors.yourcompany.com
      DEFAULT_FROM_EMAIL: errors@yourcompany.com
      ENABLE_USER_REGISTRATION: "False"   # 招待制にする
    command: ./bin/run-migrate-and-start.sh

  worker:
    image: glitchtip/glitchtip:latest
    depends_on: [postgres, redis]
    environment:
      DATABASE_URL: postgresql://glitchtip:glitchtip_password@postgres/glitchtip
      SECRET_KEY: your-secret-key-here
      REDIS_URL: redis://redis:6379
    command: celery -A glitchtip worker -B -l INFO

volumes:
  pg_data:
// Next.js でGlitchTip(Sentry互換)を初期化
// GlitchTipはSentry SDKをそのまま使える
npm install @sentry/nextjs

// next.config.js
const { withSentryConfig } = require("@sentry/nextjs");
module.exports = withSentryConfig({
  // ... next.config
}, {
  org: "my-org",
  project: "nextjs-app",
  silent: true,
});

// sentry.client.config.ts - ブラウザ側の設定
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,  // GlitchTipのプロジェクトDSN
  environment: process.env.NODE_ENV,
  tracesSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1.0,
  // カスタムユーザー情報を追加
  beforeSend(event) {
    if (event.user) {
      delete event.user.email;   // PII削除(GDPR対応)
    }
    return event;
  },
});

// sentry.server.config.ts - サーバー側の設定
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  tracesSampleRate: 0.1,
  integrations: [
    Sentry.postgresIntegration(),   // PostgreSQL自動計装
    Sentry.redisIntegration(),      // Redis自動計装
  ],
});
// エラーの手動キャプチャとコンテキスト付与
import * as Sentry from "@sentry/nextjs";

// Server Actionでエラーをキャプチャ
export async function processPaymentAction(formData: FormData) {
  const orderId = formData.get("orderId") as string;

  return Sentry.withScope(async (scope) => {
    // エラーに追加コンテキストを設定
    scope.setTag("payment.provider", "stripe");
    scope.setExtra("orderId", orderId);
    scope.setUser({ id: session.user.id });

    try {
      const result = await stripe.charges.create({ amount: total, currency: "jpy" });
      return { success: true, chargeId: result.id };
    } catch (error) {
      // エラーをGlitchTipに送信(スタックトレース+コンテキスト)
      Sentry.captureException(error);
      return { success: false, error: "Payment failed" };
    }
  });
}

// バウンダリを超えたエラーをキャプチャ
// app/error.tsx - Next.js App Routerのグローバルエラーバウンダリ
"use client";
import { useEffect } from "react";
import * as Sentry from "@sentry/nextjs";

export default function GlobalError({ error, reset }: { error: Error; reset: () => void }) {
  useEffect(() => {
    Sentry.captureException(error);
  }, [error]);

  return (
    <html>
      <body>
        <h2>予期しないエラーが発生しました</h2>
        <button onClick={reset}>再試行</button>
      </body>
    </html>
  );
}
# FastAPI(Python)でGlitchTip(Sentry互換)を設定
import sentry_sdk
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
from sentry_sdk.integrations.celery import CeleryIntegration

sentry_sdk.init(
    dsn="https://public_key@errors.yourcompany.com/project_id",
    integrations=[
        FastApiIntegration(transaction_style="url"),
        SqlalchemyIntegration(),
        CeleryIntegration(),
    ],
    traces_sample_rate=0.1,      # 10%のリクエストをトレース
    environment="production",
    release="myapp@1.2.3",       # リリースバージョン
    before_send=lambda event, hint: event if "test" not in event.get("environment", "") else None,
)

from fastapi import FastAPI
app = FastAPI()

# エラーは自動的にGlitchTipに送信される
# 追加コンテキストを付与する場合
from sentry_sdk import configure_scope

@app.get("/api/users/{user_id}")
async def get_user(user_id: str):
    with configure_scope() as scope:
        scope.set_user({"id": user_id})
        scope.set_tag("endpoint", "get_user")
        # エラーが発生した場合、ユーザーIDとタグが記録される
        user = await db.get_user(user_id)
        if not user:
            raise HTTPException(status_code=404, detail="User not found")
        return user

機能比較表

比較項目GlitchTipSentry OSS(公式)Sentry Cloud
Sentry SDK互換
セットアップ容易度高(軽量)低(複雑)不要
パフォーマンスモニタリング基本
リリーストラッキング
GDPR対応セルフホストのみセルフホストのみ要DPA
月額コスト$0(サーバー代のみ)$0(サーバー代)$26〜

エラー発生時のSlack通知はCommunicationカテゴリ/categories/communicationのSlack WebhookをGlitchTipのアラート設定で指定できます。エラーのトレースをAPMで追跡するにはDevOpsカテゴリ/categories/devopsのSigNoz・Jaegerと組み合わせてください。

FAQ

Q. GlitchTipとSentry公式セルフホストの違いは何ですか?

A. GlitchTip: ①セットアップが簡単(Docker Compose 1ファイル)②必要メモリが小さい(2GB〜)③機能は基本的なエラー集約・通知に絞られている④コミュニティ小さめ。Sentry公式セルフホスト(getsentry/self-hosted): ①Sentryクラウドとほぼ同等の機能(セッションリプレイ・プロファイリング等)②25以上のDocker Composeサービスを起動(Kafka・ClickHouseなど)③必要メモリが大きい(最低4GB・推奨8GB以上)④100GB以上のディスクが必要。チームが10〜30人規模でSentryの基本機能で十分ならGlitchTip推奨。大規模(100人+)でセッションリプレイ・プロファイリングが必要ならSentry公式セルフホストかSentryクラウドに課金を検討します。

Q. Next.jsのエラーがGlitchTipに送信されないときのデバッグ方法は?

A. 確認手順: ①ブラウザのNetworkタブでGlitchTipのエンドポイント(https://errors.yourcompany.com/api/NUMBER/envelope/)へのリクエストが発生しているか確認②CORS設定: GlitchTipのGLITCHTIP_DOMAINが正しく設定されているか確認③DSNが正しいか: ダッシュボードのProject Settings → SDK SetupからDSNを再確認④ローカルテスト: Sentry.captureException(new Error("test error"))を開発環境で実行してGlitchTipのIssues画面に表示されるか確認。

Q. Sentry SDKのソースマップをGlitchTipにアップロードするには?

A. SourceMapをアップロードすることでGlitchTipのスタックトレースがminifyされたコードではなく元のTypeScriptコードを表示できます。@sentry/cliを使います。

# CI/CDでビルド後にソースマップをアップロード
export SENTRY_AUTH_TOKEN=your-glitchtip-auth-token
export SENTRY_ORG=my-org
export SENTRY_PROJECT=nextjs-app
export SENTRY_URL=https://errors.yourcompany.com

# ビルド
npm run build

# ソースマップをアップロード(GlitchTip)
npx @sentry/cli releases new "v1.2.3"
npx @sentry/cli releases set-commits "v1.2.3" --auto
npx @sentry/cli releases files "v1.2.3" upload-sourcemaps .next/ --url-prefix "~/_next"
npx @sentry/cli releases finalize "v1.2.3"

Q. Vercel環境でGlitchTipを使う際の設定方法は?

A. Vercelのプロジェクト設定 → Environment Variablesに以下を追加します。NEXT_PUBLIC_SENTRY_DSN(ブラウザ側でも使うためPUBLIC付き)・SENTRY_DSN(サーバー側)・SENTRY_AUTH_TOKEN(ソースマップアップロード用)・SENTRY_ORGSENTRY_PROJECTSENTRY_URL(GlitchTipのURL)。next.config.jswithSentryConfigが自動的にビルド後にソースマップをアップロードするフックを追加するため、追加設定なしでソースマップが送信されます。

まとめ

ユースケース推奨ツール
Sentry互換・軽量セルフホスト・GDPR対応GlitchTip
Sentry全機能・フル機能セルフホストSentry OSS(公式)
セットアップ不要・SaaS利用Sentry Cloud

関連外部リソース

他の記事も読む

Let's Build Together

OSS導入、自社だけで悩まない。

ツール選定から構築・運用・AI活用まで、オープンソースラボ運営元のClasslessが伴走します。初回のご相談は無料です。