メインコンテンツへスキップ
監視ドキュメントは開発中です。以下にコアコンセプトを概説します。

概要

Shannonは、本番環境でタスク実行、システムパフォーマンス、リソース使用状況を追跡するための包括的な監視および可観測性機能を提供します。

監視機能

タスク監視

個別のタスク実行を追跡:
  • 実行ステータスと進捗
  • リソース消費
  • エラー率とタイプ
  • レイテンシメトリクス
  • コスト追跡

システム監視

Shannonインフラストラクチャを監視:
  • サービスヘルスステータス
  • APIエンドポイントレイテンシ
  • キューの深さ
  • Agentの可用性
  • LLMプロバイダーステータス

メトリクス

タスクメトリクス

メトリクス説明単位
task.latencyエンドツーエンドタスク完了時間ms
task.costタスクごとの総コストUSD
task.tokens.input消費された入力トークンcount
task.tokens.output生成された出力トークンcount
task.iterationsAgent反復回数count
task.tools.invocationsツール使用回数count

システムメトリクス

メトリクス説明単位
api.latencyAPIレスポンス時間ms
api.requestsリクエストレートreq/s
api.errorsエラーレートerrors/s
queue.depth待機中のタスクcount
agents.activeアクティブなAgent数count

ヘルスチェック

APIヘルス

curl http://localhost:8080/health
レスポンス(Gateway):
{
  "status": "healthy",
  "version": "0.1.0",
  "time": "2025-01-20T10:00:00Z",
  "checks": {
    "gateway": "ok"
  }
}
Readiness(Orchestrator接続を確認):
curl http://localhost:8080/readiness
レスポンス:
{
  "status": "ready",
  "version": "0.1.0",
  "time": "2025-01-20T10:00:02Z",
  "checks": {
    "orchestrator": "ok"
  }
}

コンポーネントヘルス

import requests

health = requests.get("http://localhost:8080/health").json()
print("Gateway:", health.get("status"), health.get("checks"))

ready = requests.get("http://localhost:8080/readiness").json()
print("Readiness:", ready.get("status"), ready.get("checks"))

ログ

ログレベル

Shannonは以下のレベルで構造化ログを使用:
  • DEBUG - 詳細な診断情報
  • INFO - 一般的な運用メッセージ
  • WARN - 警告状態
  • ERROR - エラー状態
  • FATAL - 重大な障害

ログフォーマット

{
  "timestamp": "2024-10-27T10:00:00Z",
  "level": "INFO",
  "service": "orchestrator",
  "task_id": "task-dev-1730000000",
  "message": "Task submitted",
  "metadata": {
    "mode": "standard",
    "estimated_cost": 0.15
  }
}

ダッシュボード

タスクダッシュボード

リアルタイムでタスク実行を監視:
  • アクティブなタスク
  • 完了率
  • 平均レイテンシ
  • エラー率
  • 時間あたりのコスト

システムダッシュボード

システムヘルスを追跡:
  • サービスステータス
  • リソース使用率
  • キューの長さ
  • プロバイダーの可用性

アラート

アラートタイプ

以下のアラートを設定:
  • タスク失敗
  • 予算超過
  • 高レイテンシ
  • サービス劣化
  • レート制限

アラート設定

alerts:
  - name: high_error_rate
    condition: error_rate > 0.05
    action: notify
    channels: [email, slack]

  - name: budget_warning
    condition: daily_cost > 100
    action: notify
    channels: [email]

  - name: service_down
    condition: health_check_failed
    action: page
    channels: [pagerduty]

Prometheus統合

Prometheusにメトリクスをエクスポート(ローカル開発用のスクレイプターゲット例):
# prometheus.yml
scrape_configs:
  - job_name: 'orchestrator'
    static_configs:
      - targets: ['localhost:2112']   # Go Orchestrator /metrics

  - job_name: 'agent_core'
    static_configs:
      - targets: ['localhost:2113']   # Rust Agent Core /metrics

  - job_name: 'llm_service'
    metrics_path: '/metrics'
    static_configs:
      - targets: ['localhost:8000']   # Python LLM Service /metrics

利用可能なメトリクス

# HELP shannon_task_total Total number of tasks
# TYPE shannon_task_total counter
shannon_task_total{status="completed"} 1234
shannon_task_total{status="failed"} 12

# HELP shannon_task_duration_seconds Task execution duration
# TYPE shannon_task_duration_seconds histogram
shannon_task_duration_seconds_bucket{le="1.0"} 100
shannon_task_duration_seconds_bucket{le="5.0"} 450

Grafanaダッシュボード

以下のための事前構築Grafanaダッシュボード:
  • タスク分析
  • コスト追跡
  • パフォーマンス監視
  • エラー分析

OpenTelemetry

Shannonは分散トレーシングのためにOpenTelemetryをサポート:
from opentelemetry import trace
from shannon import ShannonClient

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("analyze_data"):
    client = ShannonClient()
    handle = client.submit_task(query="Analyze dataset")
    result = client.get_status(handle.task_id)

ベストプラクティス

  1. 重要なメトリクスのアラートを設定
  2. 予算超過を防ぐためにコストを監視
  3. 問題を特定するためにエラーパターンを追跡
  4. デバッグに分散トレーシングを使用
  5. コンプライアンスのためにログをアーカイブ
  6. ユースケースに合わせたカスタムダッシュボードを作成
  7. 信頼性のためにSLOを実装

デバッグ

デバッグログを有効化

import logging
logging.basicConfig(level=logging.DEBUG)

# Shannonが詳細ログを出力するようになります
client = ShannonClient()

リクエストのトレース

OpenTelemetry経由で分散トレーシングを使用するか、サービスのログ詳細度を上げます。エクスポーターについては可観測性スタック設定(Jaeger/Tempo)を参照してください。

次のステップ