Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ thoughtbox-web-two/

.specs/channel-daemon/chatgpt01.md
rlm-code/

# OTEL collector file-exporter output (host backing for /var/log/otel)
otel-collector/data/
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,20 @@ services:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.113.0
command: ["--config=/etc/otelcol/config.yaml"]
# Run as root so the container can write to the mounted host path
# regardless of who owns it. Avoids uid 10001 / macOS perm friction.
user: "0:0"
environment:
# In-container directory the file exporter writes to. Fixed — it's
# the mount point. The HOST backing is the volume below, which
# honors CLAUDE_CODE_TMPDIR when set in the shell that runs compose.
OTEL_FILE_EXPORT_DIR: /var/log/otel
volumes:
- ./otel-collector/config-with-prometheus.yaml:/etc/otelcol/config.yaml:ro
# Sub-namespace under CLAUDE_CODE_TMPDIR so collector output doesn't
# share a directory with Claude Code's per-uid runtime tmpdir
# (claude-<uid>/). Files land at $CLAUDE_CODE_TMPDIR/otel/ on host.
- ${CLAUDE_CODE_TMPDIR:-./otel-collector/data}/otel:/var/log/otel
ports:
- "4318:4318"
- "8889:8889"
Expand Down
6 changes: 4 additions & 2 deletions otel-collector/config-with-prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ exporters:
namespace: mcp
debug:
verbosity: basic
# OTEL_FILE_EXPORT_DIR resolves inside the container; the host backing
# is set in docker-compose.yml and honors CLAUDE_CODE_TMPDIR when present.
file/logs:
path: /tmp/claude-code-events.jsonl
path: ${env:OTEL_FILE_EXPORT_DIR}/claude-code-events.jsonl
rotation:
max_megabytes: 100
max_days: 7
file/metrics:
path: /tmp/claude-code-metrics.jsonl
path: ${env:OTEL_FILE_EXPORT_DIR}/claude-code-metrics.jsonl
rotation:
max_megabytes: 50
max_days: 7
Expand Down
9 changes: 6 additions & 3 deletions otel-collector/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ exporters:
debug:
verbosity: detailed

# File exporter for persistent logs
# File exporter for persistent logs.
# Path is configurable via OTEL_FILE_EXPORT_DIR (in-container); the host
# backing of that directory is set in docker-compose.yml and honors
# CLAUDE_CODE_TMPDIR when present.
file/logs:
path: /tmp/claude-code-events.jsonl
path: ${env:OTEL_FILE_EXPORT_DIR}/claude-code-events.jsonl
rotation:
max_megabytes: 100
max_days: 7
max_backups: 5

file/metrics:
path: /tmp/claude-code-metrics.jsonl
path: ${env:OTEL_FILE_EXPORT_DIR}/claude-code-metrics.jsonl
rotation:
max_megabytes: 50
max_days: 7
Expand Down
7 changes: 7 additions & 0 deletions otel-collector/enable-telemetry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
#
# Or add these to your shell profile (~/.zshrc, ~/.bashrc)

# Where the OTEL collector should drop file-exported logs/metrics on the
# HOST. docker-compose interpolates this; if unset, falls back to the
# project-local ./otel-collector/data directory. Honors any project- or
# user-level override of CLAUDE_CODE_TMPDIR already in the shell env.
: "${CLAUDE_CODE_TMPDIR:=$(cd "$(dirname "${BASH_SOURCE[0]}")/data" && pwd)}"
export CLAUDE_CODE_TMPDIR

# Required: Enable telemetry
export CLAUDE_CODE_ENABLE_TELEMETRY=1

Expand Down
Loading