Skip to main content
Claude Code exports OpenTelemetry metrics, log events, and traces. To connect it, run agentgolf harness setup claude-code. Add --endpoint <url> for a Self-Hosted Uplink instance. Then set the content limit. See Content length. The rest of this page is for manual setup and content policy.

Settings

The Harness Setup card on Settings > Uplink > Publishing Keys shows these settings for manual setup, with the publishing key in OTEL_EXPORTER_OTLP_HEADERS. agentgolf harness setup claude-code writes the same settings, but keeps the key in the system keychain. See Publishing key in the system keychain and Set up with the CLI. To copy the settings by hand, replace:
  • <endpoint> with https://uplink.agent.golf for Cloud Uplink, or with the listener of your Self-Hosted Uplink instance, for example http://127.0.0.1:4318.
  • <publishing-key> with your personal publishing key. See Publishing keys.
Add the variables to the env block of ~/.claude/settings.json, or of $CLAUDE_CONFIG_DIR/settings.json, and keep the file’s other settings:
Each user has their own publishing key, so do not put the header in the Claude Code managed settings. To roll out the other variables to every developer, see Team rollout.
claude-code is the default Claude Code service name. Set it anyway: a shell that exports OTEL_SERVICE_NAME for another tool changes the service name of Claude Code. Then Agent Golf does not record the session. Keep the other default settings of Claude Code, and do not set OTEL_METRICS_INCLUDE_SESSION_ID to false.

Publishing key in the system keychain

agentgolf harness setup claude-code saves your publishing key in the system keychain, not in settings.json. agentgolf 0.1.11 added the system keychain. The command writes the env block above without OTEL_EXPORTER_OTLP_HEADERS, and sets the otelHeadersHelper setting to agentgolf otel-headers. Claude Code runs this helper, which reads the key from the system keychain.
  • Claude Code must find agentgolf on its PATH. If it does not, give the full path of the binary in otelHeadersHelper, for example the output of command -v agentgolf.
  • When the helper fails, Claude Code exports nothing, and /status shows the error.
  • On a device without a system keychain, run agentgolf harness setup claude-code --print. It prints the settings with the key in OTEL_EXPORTER_OTLP_HEADERS, and writes no file. Keep the file where you put them readable only by you.
For a second run, a key that the system keychain already holds, and the move from an earlier release, see Claude Code and the system keychain.

Team rollout

An admin can roll out every variable except the publishing key in the Claude Code managed settings. Each developer then adds only their key, with agentgolf harness setup claude-code. See Roll out to a team. agentgolf harness managed-settings claude-code prints the managed settings: an env block with each variable above except OTEL_EXPORTER_OTLP_HEADERS. Add --endpoint <url> for a Self-Hosted Uplink instance. See agentgolf harness managed-settings. Install the file in one of these places:
  • Linux: /etc/claude-code/managed-settings.d/agentgolf.json.
  • macOS: /Library/Application Support/ClaudeCode/managed-settings.d/agentgolf.json.
  • Or merge the env block into your existing managed-settings.json.
For example, on Linux:
Then each developer runs agentgolf harness setup --all, or agentgolf harness setup --all --endpoint <url> with the same URL for a Self-Hosted Uplink instance. The command saves their personal publishing key in the system keychain, and sets otelHeadersHelper in ~/.claude/settings.json, or in $CLAUDE_CONFIG_DIR/settings.json. It does not write OTEL_EXPORTER_OTLP_HEADERS. Claude Code merges env variable by variable. When more than one settings file sets a variable, the file with the highest precedence applies. The managed settings leave OTEL_EXPORTER_OTLP_HEADERS and otelHeadersHelper unset, so the values of each user apply. Between managed-settings.json and the files of managed-settings.d, env also merges key by key. To lock the helper too, add --otel-headers-helper. The managed settings then also set otelHeadersHelper to agentgolf otel-headers, with --environment <env> for an API other than production. If you merge the env block into managed-settings.json, merge the otelHeadersHelper setting too. A managed otelHeadersHelper wins over the value of each user. See Settings precedence. The helper holds no key: on each device, it reads the personal publishing key of the user from the system keychain. Each device needs agentgolf on the PATH of Claude Code. agentgolf 0.1.11 added the flag and the helper. Roll out the managed helper in this order:
  1. Each developer runs agentgolf harness setup claude-code with a release that saves the key in the system keychain, 0.1.11 or later.
  2. Then install the managed settings with the helper.
A helper that fails stops all exports of the device. This is also true on a device that still has the static header of an earlier release.
Never set OTEL_EXPORTER_OTLP_HEADERS in the managed settings. A managed value wins over the value of each user, and replaces their personal publishing key.

Session content

By default, Claude Code sends lengths, tool names, and token counts, but no text and no tool arguments. These variables add content. The settings above turn on each one: Remove a variable where your policy does not allow the uplink instance to receive that content. With less content, Agent Golf links fewer sessions to pull requests automatically. See Session content.

Content length

Claude Code truncates each content value at a content limit. The default limit is 61,440 UTF-16 code units. A raw request body holds the full conversation history, so in a long session the default limit can truncate it. When you set OTEL_LOG_RAW_API_BODIES=1, also set the limit to 262144 for the claude process:
The CLI and the Harness Setup card do not set it, so add it yourself in the same place as the other variables, for example the env block of ~/.claude/settings.json. Uplink does not read it.
  • This value raises the limit. It does not remove it. Claude Code still truncates a longer body.
  • If you set OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, or one of its log record or span variants, to a lower value, Claude Code truncates at that lower value.
See CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH in the Claude Code monitoring reference.

TLS with a private CA

If your Self-Hosted Uplink instance’s certificate comes from a private CA, point Claude Code at the CA bundle:

Known limits

  • A tool call that fails input validation sends no tool telemetry. The session does not show that call.
  • Another failed tool call sends no tool output event. The session shows its outcome, but no output.

Verify the setup

  • Start claude and send a prompt. Then do the checks in Verify the setup.
  • If requests show no model, provider, or latency, confirm CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER=otlp.
  • If Uplink receives requests but no session shows, confirm that OTEL_SERVICE_NAME is claude-code in the environment of Claude Code.
  • If /status shows an otelHeadersHelper error, run the otelHeadersHelper command of your settings in a shell, for example agentgolf otel-headers > /dev/null. Exit code 3 means that the system keychain has no key: run agentgolf harness setup claude-code. For an --environment other than prod, set AGENTGOLF_API_BASE_URL to the API of that environment for the setup. Exit code 1 means that the CLI cannot read the system keychain. If the shell finds agentgolf but Claude Code does not, give the full path in otelHeadersHelper.