Skip to content

claude_code.skill_activated OpenTelemetryイベントにinvocation_trigger属性を追加

原文(日本語に翻訳)

claude_code.skill_activated OpenTelemetryイベントが、ユーザーが入力したスラッシュコマンドでも発火するようになり、invocation_trigger 属性("user-slash""claude-proactive""nested-skill" のいずれか)が新たに追加されました。

原文(英語)

claude_code.skill_activated OpenTelemetry event now fires for user-typed slash commands and carries a new invocation_trigger attribute ("user-slash", "claude-proactive", or "nested-skill")

概要

Claude Codeのテレメトリシステムが強化され、claude_code.skill_activated イベントがユーザーの入力によるスラッシュコマンド実行時にも発火するようになりました。また、新しい invocation_trigger 属性によってスキルがどのように起動されたか(ユーザー入力、Claudeによる自律的実行、ネストされたスキルからの呼び出し)を追跡できるようになりました。これにより、組織内でのClaude Codeの利用パターンをより詳細に分析できます。

基本的な使い方

OpenTelemetryコレクターを設定すると、スキル起動イベントを収集できます:

bash
# OpenTelemetry設定(claude_code.otelExporter)
# settings.jsonに設定
json
{
  "claude_code.otelExporter": {
    "endpoint": "http://localhost:4318/v1/traces",
    "headers": {
      "Authorization": "Bearer your-token"
    }
  }
}

invocation_trigger 属性の値:

  • "user-slash" — ユーザーが /skill-name と入力して起動
  • "claude-proactive" — Claudeが自律的に判断して起動
  • "nested-skill" — 別のスキルから呼び出されて起動

実践例

Grafana/Prometheusでのスキル利用状況ダッシュボード

yaml
# OpenTelemetry Collector設定例
# otel-collector-config.yaml
receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318

processors:
  filter:
    traces:
      include:
        match_type: strict
        span_names: ["claude_code.skill_activated"]

exporters:
  prometheus:
    endpoint: "0.0.0.0:9090"

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [filter]
      exporters: [prometheus]

スキル起動パターンの分析クエリ(Jaeger/Tempo)

# ユーザーが手動で起動したスキルのみ取得
invocation_trigger = "user-slash"

# Claudeが自律的に起動したスキルのみ取得
invocation_trigger = "claude-proactive"

# ネストされたスキル呼び出しの追跡
invocation_trigger = "nested-skill"

ログ集計でのスキル分析

python
# スキル起動ログを分析するPythonスクリプト例
import json
from collections import Counter

def analyze_skill_triggers(log_file):
    triggers = Counter()
    skill_names = Counter()
    
    with open(log_file) as f:
        for line in f:
            event = json.loads(line)
            if event.get('name') == 'claude_code.skill_activated':
                trigger = event['attributes'].get('invocation_trigger')
                skill = event['attributes'].get('skill_name')
                triggers[trigger] += 1
                skill_names[skill] += 1
    
    print("起動トリガー別集計:")
    for trigger, count in triggers.most_common():
        print(f"  {trigger}: {count}回")
    
    print("\nスキル名別集計:")
    for skill, count in skill_names.most_common(10):
        print(f"  {skill}: {count}回")

analyze_skill_triggers('/var/log/claude-code/otel.jsonl')

注意点

  • claude_code.skill_activated イベントはOpenTelemetryが設定されている場合のみ発火します
  • invocation_trigger 属性は今回のアップデートで新たに追加されたため、既存のダッシュボードを更新する場合はこの属性を活用してください
  • テレメトリデータには会話内容は含まれません(プライバシーに配慮した設計)
  • "claude-proactive" は将来のAuto mode強化に伴い、より多くの場面で発生する可能性があります

関連情報