Technology
OpenCode
Track what OpenCode costs, who uses it, and which pull requests it helps ship, across your engineering teams.
Overview
OpenCode
OpenCode is an open-source agentic coding tool. The Dash0 agent plugin sends an OpenTelemetry trace for every OpenCode turn. Each trace records token usage, the model, tool calls, and sub-agent activity. Dash0 links those sessions to the pull requests they help ship. Engineering leaders and platform teams see in one place how widely OpenCode is used, what it costs, and what it delivers.
Use Cases
- Cost visibility: Track spend by user, team, and model so you can understand and control what OpenCode costs.
- Adoption tracking: Follow active users, new adopters, and usage distribution to see how OpenCode rolls out across your engineering teams.
- Productivity signals: Correlate sessions, tool calls, and assisted pull requests to understand the impact OpenCode has on your team's output.
Setup
Overview
The Dash0 agent plugin uses OpenCode's V2 plugin API. It reads each session's event stream and sends one trace per turn, with token usage per model, tool calls, and sub-agent activity. Dash0 prices the tokens to show cost. The plugin leaves prompt and response text out unless you turn it on. See Data collected and privacy. The AI Coding section in Dash0 then shows what OpenCode costs, how widely your teams use it, and what it helps ship.
To give OpenCode access to your Dash0 data instead, use the OpenCode MCP integration.
Prerequisites
- OpenCode with the V2 plugin API (
opencode plugin add), on macOS, Linux, or Windows, onamd64orarm64. - A Dash0 auth token with ingest permissions.
- Your name and email in your git configuration. The plugin uses them to attribute activity to users:
git config --global user.name "{{user_full_name}}"
git config --global user.email "{{user_email}}"Install the plugin
Add the plugin from npm and reload OpenCode:
opencode plugin add @dash0/agent-plugin-opencode-v2
opencode reloadOpenCode installs the package and adds it to your global opencode.json. On first use the plugin downloads the
opencode-v2-on-event binary from GitHub Releases and checks
it against the published checksum.
opencode reload reloads OpenCode's background service. If you run your own opencode serve, add --server <url>.
Configure
Run the configure skill in an OpenCode session:
/dash0-configureWhen prompted, enter your Dash0 connection details:
- OTLP URL:
{{endpoint_otlp_http}} - Auth token:
{{token_ingestion}} - Dataset (optional):
{{dataset}}
By default the skill writes them to ~/.opencode-v2/dash0-agent-plugin.local.md
(%USERPROFILE%\.opencode-v2\dash0-agent-plugin.local.md on Windows). It can also write a project-level file instead.
The token stays out of opencode.json, which projects often commit. The plugin reads its settings when it starts, so
reload OpenCode afterwards:
opencode reloadYou can also write the file yourself:
---
otlp_url: "{{endpoint_otlp_http}}"
auth_token: "{{token_ingestion}}"
dataset: "{{dataset}}"
team_name: "<your team>"
---dataset and team_name are optional. The plugin sends team_name as dash0.team.name on every span.
A .opencode-v2/dash0-agent-plugin.local.md inside a repository replaces the global file for that repository. The two
files do not merge. Options set on the plugin's entry in opencode.json override both files. Set enabled: false to
turn the plugin off for a scope without uninstalling it.
Every option except the auth token and enabled can also come from a DASH0_* environment variable, for example
DASH0_TEAM_NAME. The plugin never reads the token from DASH0_AUTH_TOKEN. On macOS, set
auth_token_keychain_service to read the token from a keychain item instead of the file.
For the privacy options (omit_io, omit_user_info), see Data collected and privacy.
For help choosing a dataset, see the
dataset documentation.
Attribute Usage by Team (Optional)
Dash0 breaks OpenCode activity down by user and model without extra setup. To break it down by team as well, enter a
team name when you run /dash0-configure, or set team_name in the configuration file. The plugin sends it as
dash0.team.name on every span.
Verify
- Run
opencode reload, start a session, and send a prompt that uses a tool. - Within a few seconds, the trace appears in the AI Coding section of Dash0. Each turn has a
chat <model>span with token usage, anexecute_tool <Name>span per tool call, and aninvoke_agent <agent>span per sub-agent.
If no traces arrive, add debug: true and debug_file: /tmp/dash0-opencode-debug.log to the configuration file and run
opencode reload. The plugin then writes every span it sends to that file as a [dash0:trace] line. If the lines are
there but Dash0 shows nothing, check the endpoint and token.
Uninstall
Remove the plugin and reload OpenCode:
opencode plugin remove @dash0/agent-plugin-opencode-v2
opencode reloadDelete ~/.opencode-v2/ if you no longer need its settings.
Data collected and privacy
The plugin sends spans over OTLP/HTTP to the endpoint you configure. It authenticates with your auth token and sets the
Dash0-Dataset header when you configure a dataset. Before it runs the binary from
GitHub Releases, it checks it against the release checksums.
The plugin always sends:
- The developer's git
user.nameanduser.email, or the OS account name when git has no name set. - The working directory, the repository, the branch, and the commit SHA.
- The model, token usage, tool names, skill names, and sub-agent names. MCP tools keep OpenCode's
<server>_<tool>name. - For commands run through the
shelltool, only the binary name (for examplegitornpm), not the full command line. - Pull request, issue, and commit references found in tool output.
The plugin never sends provider headers, provider state, reasoning text, or raw error-response bodies.
By default the plugin does not send prompts, responses, tool inputs, or tool outputs. With omit_io at its default of
true, it replaces them with <REDACTED>, and a failed turn reports only its error type. With omit_io: false, it
sends that content truncated at 16 KB per attribute. It does not scrub secrets, so file contents, command output, and
anything pasted into a prompt reach Dash0 unchanged.
With omit_user_info: true (default false), the plugin hashes user.name, drops user.email, and
replaces your home directory in the working directory with ~. With
omit_identity_fallback: true, it drops the OS account name instead of reporting it. Set these options in the YAML
frontmatter of the configuration file.
To turn the plugin off in one repository, add .opencode-v2/dash0-agent-plugin.local.md to it with enabled: false in
the YAML frontmatter.