Gemini CLI
This page shows how to send Gemini CLI’s traces to cetra with cetra agents setup, and what you see in the UI.
Connect Gemini CLI
Section titled “Connect Gemini CLI”- Create a project key with the
ingestscope in the project’s API keys page. Copy thesk-cetra-…value. - Install the
cetrabinary and run this in a terminal, with<SK_CETRA_KEY>set to your key and<CETRA_URL>set to your server:
export CETRA_INGEST_KEY=<SK_CETRA_KEY>cetra agents setup gemini-cli --url <CETRA_URL>- Run Gemini CLI as usual. Its traces then go to cetra.
cetra agents setup gemini-cli writes these files, and keeps every other key in them:
~/.gemini/settings.json: thetelemetrykeys that turn on traces and send them to your server, and two hooks (SessionStartandBeforeAgent). The hooks send the session’s repository, branch and person to cetra. They never send spans.~/.gemini/.env, with mode 0600: theOTEL_EXPORTER_OTLP_HEADERSline that holds your key. Gemini CLI reads its headers from this file, not fromsettings.json.agents.toml, with mode 0600, next to the credentials file ofcetra login(~/.config/cetra/on Linux,~/Library/Application Support/cetra/on macOS): the server, the key and the person that the hooks use.
If .env already has an OTEL_EXPORTER_OTLP_HEADERS line, setup replaces it, and the original file is copied to .env.cetra-backup. Setup also copies settings.json to settings.json.cetra-backup before its first change.
To see the files without writing them, add --print. It prints the merged files and writes nothing. To attribute sessions to a person other than your git config --global user.email, add --user <EMAIL>.
To undo setup, run this. It removes only the keys and hooks that setup wrote:
cetra agents remove gemini-cliRun cetra agents setup gemini-cli again after you move or upgrade the cetra binary. The hooks hold the binary’s path.
What you get
Section titled “What you get”Gemini CLI does not group a prompt under one trace. Each model call is a trace of its own, and each batch of tool calls is another trace. So one prompt that calls a tool makes several traces, all in one session.
- a model call is an
llmspan, with the model and its input and output tokens. This includes the routing call that Gemini CLI makes; - a tool batch is a
chainspan, and each tool call inside it is atoolspan named after the tool, such asrun_shell_command; - the user prompt and the agent call are
agentspans.
Each trace has these fields:
- the session, from Gemini CLI’s conversation id;
- the person and the repository and branch, from the hook. Gemini CLI puts no person on its spans;
metadata.coding_agentset togemini-cli.
Use the Coding agents dashboard template to see API-equivalent cost per person, repository, branch and session, and tool usage.
Content
Section titled “Content”Setup writes logPrompts: true, and Gemini CLI sends the prompts and the model’s answers on its spans. With --no-content, setup writes logPrompts: false, which drops the prompts; whether Gemini CLI also drops the answers was not tested.
API-equivalent cost
Section titled “API-equivalent cost”cetra prices each model call from its token counts, using its price table. Gemini CLI does not report a cost.
Gemini CLI’s spans carry only input and output token counts. Cache and reasoning tokens are not on the spans, so cetra does not count them.
API-equivalent cost is what the same tokens would cost at API prices. If you use a subscription plan, it is not what you pay.
Limits
Section titled “Limits”- Tested with Gemini CLI 0.68.0.
- Every model call is its own trace, so a prompt is several traces of one session. Group them by session to see the whole prompt.
- Gemini CLI also sends logs and metrics. Setup does not turn them off, and cetra accepts and drops them. Setup prints this when it finishes.
cetra agents setupdoes not run on Windows. There, Gemini CLI can still export spans if you set its telemetry settings yourself, but no hooks run.
- Traces: read the trace as a tree and a timeline.
- Sessions: the calls of one Gemini CLI session.
- Custom dashboards: build your own cost views, or start from the Coding agents template.