feat(claude-code): add telemetry input for OTEL export with workspace attribution#862
Open
morganl-ant wants to merge 1 commit intocoder:mainfrom
Open
feat(claude-code): add telemetry input for OTEL export with workspace attribution#862morganl-ant wants to merge 1 commit intocoder:mainfrom
morganl-ant wants to merge 1 commit intocoder:mainfrom
Conversation
Collaborator
|
Thank you for the contribution! Everything looks good to me, but the one thing we do need in this, is for the module version to be bumped. You can use the version bump script to do so. This would be a minor version bump. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Claude Code ships an OpenTelemetry exporter for token usage, tool calls, session lifecycle and errors (https://docs.anthropic.com/en/docs/claude-code/monitoring-usage), but the module exposes no first-class wiring for it. Template authors who want telemetry have to know the env var names (
CLAUDE_CODE_ENABLE_TELEMETRY, theOTEL_EXPORTER_OTLP_*family) and write their owncoder_envblocks. More importantly there is no convention for how to correlate Claude Code telemetry with Coder's own audit logs andexectracerecords, so even when both are exported they end up as two unjoined datasets.Change
Adds a
telemetryinput that turns onCLAUDE_CODE_ENABLE_TELEMETRYand the standard OTLP exporter env vars in one place:When enabled, the module automatically appends
coder.workspace_id,coder.workspace_name,coder.workspace_ownerandcoder.template_nametoOTEL_RESOURCE_ATTRIBUTES. This gives a stable join key between Claude Code spans/metrics and Coder's audit log and exectrace events onworkspace_id, so a platform team can answer "show me every shell command Claude executed in workspace X alongside the token spend for that session" without custom plumbing.This is purely additive (
coder_envresources behindcount), defaults to disabled, and is independent of how Claude is launched, so it composes cleanly with the install-only direction in #861.Validation
terraform fmt,terraform validate,terraform test(19/19) passbun test -t telemetry(2/2) pass: env vars are set with the expected values when enabled, and absent when the input is omittedDisclosure: I work at Anthropic on the Claude Code team.