Class: ClaudeMemory::Commands::OtelCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/claude_memory/commands/otel_command.rb

Overview

CLI shell for the OTel ingestion feature. Subcommands flip flags in ‘.claude/settings.json` (delegated to OTel::SettingsWriter) or report status (delegated to OTel::Status). The command itself contains no domain logic.

claude-memory otel                       # default --status
claude-memory otel --status
claude-memory otel --enable
claude-memory otel --disable
claude-memory otel --enable-traces
claude-memory otel --disable-traces
claude-memory otel --capture-prompts    # opt-in: OTEL_LOG_USER_PROMPTS=1
claude-memory otel --no-capture-prompts
claude-memory otel --verify             # POST a fixture and confirm round-trip

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from ClaudeMemory::Commands::BaseCommand

Instance Method Details

#call(args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/claude_memory/commands/otel_command.rb', line 25

def call(args)
  opts = parse_options(args, default_options) do |o|
    OptionParser.new do |parser|
      parser.banner = "Usage: claude-memory otel [options]"
      parser.on("--status", "Show ingestion status (default)") { o[:action] = :status }
      parser.on("--enable", "Configure Claude Code to export telemetry") { o[:action] = :enable }
      parser.on("--disable", "Remove telemetry env from settings.json") { o[:action] = :disable }
      parser.on("--enable-traces", "Opt in to trace ingestion") { o[:action] = :enable_traces }
      parser.on("--disable-traces", "Tell Claude Code to skip trace export") { o[:action] = :disable_traces }
      parser.on("--capture-prompts", "Opt in to OTEL_LOG_USER_PROMPTS=1") { o[:action] = :capture_prompts }
      parser.on("--no-capture-prompts", "Stop capturing prompt content") { o[:action] = :disable_capture_prompts }
      parser.on("--verify", "Send a sample envelope and confirm it persisted") { o[:action] = :verify }
      parser.on("--backfill", "Tag historical activity_events from prior OTel events") { o[:action] = :backfill }
      parser.on("--port PORT", Integer, "Receiver port for the dashboard (default 3377)") { |v| o[:port] = v }
      parser.on("--batch-size N", Integer, "Backfill batch size (default 500)") { |v| o[:batch_size] = v }
    end
  end
  return 1 if opts.nil?

  case opts[:action]
  when :enable then run_enable(opts)
  when :disable then run_disable(opts)
  when :enable_traces then run_settings_change(opts) { |w| w.enable_traces! }
  when :disable_traces then run_settings_change(opts) { |w| w.disable_traces! }
  when :capture_prompts then run_capture_prompts(opts)
  when :disable_capture_prompts then run_settings_change(opts) { |w| w.disable_capture_prompts! }
  when :verify then run_verify(opts)
  when :backfill then run_backfill(opts)
  else run_status(opts)
  end
end