[FEATURE] Emit repo/worktree/branch attributes in OpenTelemetry from Claude Code Desktop

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 24, 2026

What area is this feature request for?

OpenTelemetry (monitoring / observability)

Is your feature request related to a problem?

Claude Code exports metrics and events via OpenTelemetry (OTLP), which is
great for tracking usage across a team. However, for the Claude Code
Desktop app (Code tab)
the telemetry does not expose which repository, work
directory, or git worktree/branch a session is running in.

Teams that use multiple worktrees of the same repository (one worktree per
feature branch, or the parallel-agent workflow) cannot distinguish sessions by
worktree/repo in their observability backend. All worktrees look identical in
the collected data, so we can't answer:

  • Which repo/worktree/branch is consuming the most tokens / cost?
  • How is agent activity distributed across parallel worktrees?
  • Which worktree a given session/event belongs to.

Empirical evidence (why the existing attribute does not solve this)

The docs mention an event attribute:

workspace.host_paths: host workspace directories selected in the desktop app, as a string array (https://code.claude.com/docs/en/monitoring-usage.md)

In practice this attribute is NOT emitted by the Claude Code Desktop app
(Code tab)
— it appears to be populated only in Cowork. Measured against a
local OTLP collector capturing raw log events:

| Metric | Value |
|---|---|
| Total log records captured | 8,553 (45 sessions) |
| Records with service.name = claude-code-desktop | 618 |
| Records carrying workspace.host_paths | 0 |

So on Desktop there is currently no attribute — on resource, metric, or
event — carrying repo / working directory / worktree / branch. Token and cost
data (cost_usd, input_tokens, output_tokens) ARE present on
api_request events, but there is no dimension to attribute that cost to a
repo or worktree.

The OTEL_RESOURCE_ATTRIBUTES workaround also does not work on Desktop.
Setting OTEL_RESOURCE_ATTRIBUTES via the env block of settings.json
(both user ~/.claude/settings.json and per-worktree
.claude/settings.local.json) has no effect on the Desktop resource
block. Verified on fresh, fully cold-started Desktop sessions: the resource
block contained only the built-in attributes and none of the injected values:

service.name = claude-code-desktop
service.version = 1.24012.1
claude.deployment_mode = 1p
host.arch = amd64
os.type = windows
os.version = 10.0.26100
process.owner = <user>

Other OTEL_* vars from the same env block (endpoint, exporter, enable flag)
DO take effect — telemetry flows — so the app appears to build a fixed
Resource and never merges OTEL_RESOURCE_ATTRIBUTES from the environment.
The same variable works fine when Claude Code runs from the terminal CLI,
where it is picked up as a genuine OS env var. Net result: on Desktop there is
currently no supported mechanism, native or workaround, to attribute
telemetry to a repo/worktree.

Describe the solution you'd like

Add git/workspace context as attributes emitted by the Desktop app, on the
OTel resource (so they land on both metrics and events), for example:

  • workspace.path / repo root of the active session (Desktop, not just Cowork)
  • git.worktree.path — absolute path of the active worktree
  • git.branch — branch checked out in that worktree
  • git.repo.name — low-cardinality repo name, suitable as a metric label

This would let us group, filter, and aggregate telemetry (including cost) per
repo/worktree, the same way we already can with session.id, user.id, and
organization.id.

Describe alternatives you've considered

  • workspace.host_paths — not emitted by the Desktop Code tab (see evidence

above); only useful in Cowork, and events-only (excluded from metrics for
cardinality).

  • Setting OTEL_RESOURCE_ATTRIBUTES per worktree via

<worktree>/.claude/settings.local.json envverified NOT to work on
Desktop
(see evidence above); the value never reaches the resource block.
It works only on the terminal CLI.

  • Setting OTEL_RESOURCE_ATTRIBUTES as an OS-level env var — even if it were

honored by Desktop, it is a single static value per machine and cannot
distinguish one worktree/repo from another.

  • Parsing paths heuristically on the collector side — nothing to parse, since

Desktop emits no path/repo attribute at all.

Additional context

Verified against otel/opentelemetry-collector-contrib:0.116.1 with the raw
OTLP log stream from Claude Code Desktop on Windows. The manual
OTEL_RESOURCE_ATTRIBUTES workaround is what teams have to fall back on today;
native repo/worktree/branch attributes on the Desktop app would make
per-worktree cost and activity monitoring possible out of the box.

View original on GitHub ↗