Send goose traces to Agent Analytics
이 페이지는 아직 귀하의 언어로 번역되지 않았습니다. 현재 작업 중이므로 곧 다시 확인해 주십시오.
goose exports OpenTelemetry GenAI traces from the CLI and the desktop app. Point that exporter at Amplitude. You don't need the Amplitude AI SDK in the agent. Each goose session becomes one Agent Analytics session, with the model, tokens, and every tool call.
This page covers goose v1.28.0 or later. goose usually runs for your own engineers, so the user is an employee who usually isn't in your product analytics. The outcome to chart is what happened to the code. Refer to Connect to outcomes.
Set up with your AI coding agent (recommended)
Paste this prompt into your AI coding agent, such as Cursor, Claude Code, Windsurf, GitHub Copilot, or Codex.
Connect goose to Amplitude Agent Analytics with native OpenTelemetry.
Fetch https://raw.githubusercontent.com/amplitude/Amplitude-AI-Node/main/docs/integrations/goose.md
and follow "Part 2: Coding agent procedure".
If @amplitude/ai is installed, the same file is under node_modules/@amplitude/ai/docs/integrations/.
Also follow https://raw.githubusercontent.com/amplitude/Amplitude-AI-Node/main/docs/integrations/privacy.md
Follow links in the guide. If your source isn't listed, start at https://raw.githubusercontent.com/amplitude/Amplitude-AI-Node/main/docs/integrations/README.md
Review the changes, then verify with the steps in Get started.
What this means for you
- You run: goose, with its OpenTelemetry exporter pointed at Amplitude. A Collector is optional. Use one when you scrub attributes before export.
- You need: goose v1.28.0 or later, your Amplitude project API key, and the user ID to record for each engineer.
- Protocol: OTLP over HTTP. Amplitude doesn't accept gRPC.
- Privacy: Amplitude doesn't scrub content after receipt. Message and tool content is off unless you turn it on.
Export
Run this in the repository root. It requires @amplitude/ai 0.28.0 or amplitude-ai 1.25.0 or later.
export AMPLITUDE_AI_API_KEY=AMPLITUDE_API_KEY
npx -y -p @amplitude/ai amplitude-ai coding-agents init --harness goose
# or, in a Python project
amplitude-ai coding-agents init --harness goose
init takes the same flags as for Claude Code. Refer to the flag table. It writes the commit trailer hook, the outcomes workflow, and the gitignored .amplitude-ai/local.env, sets core.hooksPath to .githooks when the clone has no hooks path yet, and prints the environment for goose. It never prints the key itself. The printed lines are:
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.amplitude.com/otlp/v1/traces
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer%20${AMPLITUDE_AI_API_KEY}"
export OTEL_RESOURCE_ATTRIBUTES="enduser.id=$(git config user.email)"
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
Set them where goose runs. The header line that init prints also falls back to the AMPLITUDE_API_KEY variable when AMPLITUDE_AI_API_KEY isn't set. With --region eu, the endpoint is https://api.eu.amplitude.com/otlp/v1/traces. With --privacy metadata, init leaves out the content line. Also set OTEL_SERVICE_NAME=goose, which init doesn't print, so the agent ID is goose. Refer to Identity.
goose has no lifecycle hooks, so nothing sets core.hooksPath in a new clone. Run init or git config core.hooksPath .githooks once in each clone. coding-agents doctor checks the hooks path and the three goose variables.
Identity
| Value | Where it comes from |
|---|---|
| Session | session.id on every span, and gen_ai.conversation.id. A shared goosed server keeps sessions separate. |
| User | enduser.id from OTEL_RESOURCE_ATTRIBUTES |
| Agent | gen_ai.agent.id when set, else the resource service.name. goose sets gen_ai.agent.name, which traces don't use for the agent ID, so set OTEL_SERVICE_NAME. |
| Session trigger | amplitude.session_trigger in OTEL_RESOURCE_ATTRIBUTES, else ci when the resource has any cicd.pipeline.* attribute |
goose doesn't report how a session started, so add amplitude.session_trigger to OTEL_RESOURCE_ATTRIBUTES, after enduser.id and a comma, with one of interactive, headless, ci, scheduled, or event. Amplitude sets it as [Agent] Session Trigger on every event and ignores other values. It needs the Amplitude OTLP receiver release that maps it. Until that release is live in your data center, goose events have no [Agent] Session Trigger. The commit hook reads AMPLITUDE_SESSION_TRIGGER for the Agent-Trigger trailer, so in a CI job, set both from one variable:
export AMPLITUDE_SESSION_TRIGGER=ci
export OTEL_RESOURCE_ATTRIBUTES="enduser.id=<user ID>,amplitude.session_trigger=$AMPLITUDE_SESSION_TRIGGER"
What carries over
| goose span | Amplitude event |
|---|---|
| Model call | [Agent] AI Response with model, provider, tokens, cache tokens, and finish reason, plus an [Agent] User Message for each new user message |
| Tool call | [Agent] Tool Call with tool name, call ID, arguments, and result. A git commit call adds commit_sha when it can be read. Refer to Connect to outcomes. |
| Other agent spans | [Agent] Span |
goose doesn't send cost, and Amplitude doesn't estimate one. A native goose export doesn't send [Agent] Session End, so Amplitude closes the session after 30 minutes without a qualifying agent event. Refer to How sessions close.
Privacy gates
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true adds message text, tool arguments, and tool results. Without it, sessions, users, models, tokens, tool names, and tool success still arrive. Evaluators that find commits or pull requests in tool calls need tool arguments. Amplitude doesn't scrub content after receipt, so scrub in a Collector before export when you need to. Refer to Agent Analytics privacy modes.
Connect to outcomes
The trailer hook stamps AGENT_SESSION_ID, which goose sets to the same session ID as its spans, so each outcome score lands on the session that wrote the commit.
In-session outcomes come from your [Agent] Tool Call events, with no extra setup. Binary evaluators can label sessions that made a commit, opened a pull request, or ended with passing tests. A code evaluator with a regex over tool turns, such as \bgit\s+commit\b, finds commits and pull requests. An LLM evaluator judges whether the last test command succeeded. Refer to Create and calibrate evaluators.
Code evaluators read the tool input of every turn, so a commit at the end of a long session still counts. Each evaluator writes an [Agent] Evaluator Result, so you can compare it with built-in signals: do Task Completed sessions actually produce commits? A tool call that creates a commit can also carry a commit_sha event property. It's read from the [branch sha] line that git commit prints, or from the sha in a JSON result when the tool name or input names a commit, pull request, or file push as a whole word, such as create_pull_request or push_files. Output from git log, git show, and other hex strings is never read as a commit.
Downstream outcomes, such as merged, reverted, and deployed, need two pieces that coding-agents init writes into the repository:
- A
prepare-commit-msghook in.githooks/that stampsAgent-Session-IdandAgent-Nametrailers on every commit the agent makes. Human commits stay unchanged, and--no-verifydoesn't skip this hook. It also adds anAgent-Triggertrailer when it knows how the session started, as described after the score tables. - A GitHub Actions workflow,
.github/workflows/agent-outcomes.yml, that reads those trailers and sends each outcome to the Amplitude HTTP API as an[Agent] Scoreon the session that wrote the commit. The outcome appears next to the session's own events and evaluator results, with no new event type. Store the project API key in theAMPLITUDE_API_KEYrepository secret. These repository variables are optional:
| Variable | Effect |
|---|---|
AMPLITUDE_REGION | eu sends to the EU data center. The default is US. |
AMPLITUDE_OUTCOMES_DRY_RUN | true prints the scores instead of sending them. |
AMPLITUDE_USER_ID_SOURCE | email (default) uses the commit author email as the user ID. login uses the GitHub login. Use the value your agent sessions use as the user ID. |
AMPLITUDE_AGENT_SETUP_PATHS | Comma-separated root-level files or folders that make up your agent setup, for agent_setup_version. The default is AGENTS.md,CLAUDE.md,GEMINI.md,.claude,.codex,.cursor,.cursorrules,.gemini,.goosehints,.mcp.json. The workflow ignores names that contain / and uses the first 20 names. Changing it changes every later agent_setup_version. |
The workflow asks for read access to contents, pull-requests, deployments, actions, checks, and statuses. It reads workflow runs, check runs, and commit statuses for ci_passed_first_run. For a pull request from a fork, meaning one whose head branch is in another repository, GitHub doesn't pass repository secrets to the run, so the workflow logs a notice and sends nothing instead of failing.
Each score sets these properties:
| Property | Value |
|---|---|
[Agent] Session ID and [Agent] Target ID | The commit's Agent-Session-Id trailer. |
[Agent] Target Type | session. |
[Agent] Agent ID | The commit's Agent-Name trailer, such as claude-code, codex, cursor, or goose. Otherwise the agent that signed the commit, as its author or in a Co-authored-by line. |
[Agent] Evaluation Source | outcome. |
[Agent] Score Name and [Agent] Score Value | One of the scores in the next table. |
The event time is the commit's author date, so the score falls inside the session that wrote the commit. outcome_time holds when the outcome happened: the merge, the revert's merge, or the deployment.
| Score Name | Value | Sent when | Also carries |
|---|---|---|---|
commit_merged | 1 | A pull request merges. One score for each agent commit in the pull request. | pr_number, merge_commit_sha, and base_branch. |
commit_reverted | 1 | A merged pull request's description or commits contain This reverts commit <sha>. One score on the session that wrote the reverted commit. | revert_pr_number and revert_merge_commit_sha. |
deploy_succeeded | 1 | A GitHub deployment succeeds. One score for each agent commit from the previous successful deployment to the same environment up to the deployed commit. When there's no earlier successful deployment, the deployed commit only. | deployment_sha and environment. |
deploy_failed | 1 | A GitHub deployment status is failure or error. One score for each agent commit in the same range as deploy_succeeded. | deployment_sha, environment, and deployment_state, which is failure or error. |
ci_passed_first_run, review_rounds, review_count, changes_requested_count, hours_open, and hours_to_first_review | The measure. ci_passed_first_run is 1 or 0. | A pull request merges. One of each for every agent session in the pull request, on that session's first commit in it. | pr_number, merge_commit_sha, base_branch, commit_count, agent_commit_count, session_commit_count, and pr_session_count. |
Every score also carries commit_sha, agent_session_id, agent_name, agent_trigger, agent_setup_version, repo, outcome_time, and outcomes_workflow_version, set to 3.
- Only agent sessions get scores. A commit without an
Agent-Session-Idtrailer sends nothing. That covers human commits, Gemini CLI commits, commits made through the GitHub API or MCP tools, and cloud-agent commits known only by their author orCo-authored-byline. For a pull request with no such commit, the workflow also skips the reviews and CI lookups. - A pull request counts once for each session. When several sessions wrote one pull request, each gets the pull request scores, and
pr_session_countsays how many sessions there were. To count pull requests, count distinctpr_numbervalues. - The user ID is the commit author email, or the GitHub login with
AMPLITUDE_USER_ID_SOURCE=login. It must match the user ID your agent sessions use.coding-agents initsets the session user ID to the git email. Withlogin, the pull request scores fall back to the pull request author when the session's first commit has no GitHub account. A commit with no user ID gets no scores. - A score with no value isn't sent, such as
hours_to_first_reviewfor a pull request with no human review. - Insert IDs are the score name, the repository, and the commit SHA, plus the deployment ID for deploy scores, the revert's pull request number for
commit_reverted, and the pull request number and session instead of the SHA for the pull request scores. A rerun within Amplitude's 7-day deduplication window doesn't count twice. - Outcome scores aren't user feedback. Agent Analytics reads only scores with the
usersource as user feedback, so an outcome never counts as a thumbs up or down.
agent_trigger says how the session that wrote the commit started, with the same values as [Agent] Session Trigger on the session's events: interactive, headless, ci, scheduled, or event. It comes from the Agent-Trigger trailer. The hook adds that trailer only to commits it stamps with an agent session or name, and only when it knows the value. It resolves the value the way the Codex and Cursor hooks resolve [Agent] Session Trigger, so a commit and its session get the same value:
AMPLITUDE_SESSION_TRIGGERin the environment, when it's one of the five values. Set it where the agent runs, for exampleAMPLITUDE_SESSION_TRIGGER=headlessfor a script that runs the agent without a person, orscheduledfor a scheduled job. When the variable is set, the hook doesn't read.amplitude-ai/local.envfor it.- Otherwise
AMPLITUDE_SESSION_TRIGGERin.amplitude-ai/local.envat the repository root. The hook reads the file asKEY=valuelines and never runs it. - Otherwise
ci, whenGITHUB_ACTIONSistrue, orCIis set to anything other than an empty value,false, or0. - Otherwise, for Codex, how the session started, from
sourcein the first line of the session transcript under$CODEX_HOME/sessions(by default~/.codex/sessions):codex execor the MCP server givesheadless, and the CLI or VS Code givesinteractive. - Otherwise no trailer.
Without a valid trailer, agent_trigger is event when a coding agent is the commit author, as when a cloud agent works from an issue or an assignment, and null otherwise.
The pull request scores use these definitions:
| Score Name | Description |
|---|---|
hours_open | Hours from opening the pull request to merging it, rounded to 2 decimals. Time as a draft counts. |
review_count | Human reviews submitted as approved, changes requested, or commented with a comment. A reply in a review thread doesn't count, and neither do reviews from bots or the pull request author. A review with only inline comments and no summary doesn't count either. |
changes_requested_count | The reviews in review_count that requested changes. |
hours_to_first_review | Hours from opening the pull request to the first review in review_count, rounded to 2 decimals. Not sent when there's no such review. |
review_rounds | The reviews in changes_requested_count that at least one later commit followed, meaning a commit in the pull request whose committer date is after the review. A rebase gives commits a new committer date, so a rebase after a review counts as a commit that followed it. |
ci_passed_first_run | 1 when CI passed on its first attempt, 0 when it didn't. The workflow finds the first push that CI ran on, which is the head commit of the pull request's earliest GitHub Actions workflow run between opening and merging, other than the outcomes workflow itself, and reads the earliest run of each check and commit status on it. A push of several commits runs CI on the last one only, so this works however many commits the pull request opened with. Runs are matched by the pull request's commits, so after a force-push the earliest push that survived counts. Without GitHub Actions runs, the workflow takes the first commit with finished CI results among the pull request's first 20 commits. success, neutral, and skipped count as passing. Cancelled and unfinished runs don't count. A later rerun that passes doesn't change the value. Not sent when the pull request has no CI. |
commit_count is the pull request's commit count. GitHub lists at most 250 commits, so commit_merged, agent_commit_count, and session_commit_count cover the first 250.
agent_setup_version identifies the agent setup a commit was written with. It's the first 12 hex characters of a SHA-256 over the root-level entries named in AMPLITUDE_AGENT_SETUP_PATHS, read from the commit's parent. Any change to one of those files, or to a file inside one of those folders, produces a new value. It's null when none of the entries exist. A commit that edits AGENTS.md carries the version from before the edit, and the next commit carries the new one. On the pull request scores, it's the value for the session's first commit in the pull request.
agent_setup_version and the review and CI scores are best effort. Together they make at most 300 GitHub API requests in a run, counting each page of results. When one fails or the budget runs out, the workflow leaves out that property or score, logs a warning, and still sends the rest. The run log includes an enrichments: line that shows which ones succeeded and how many API calls the run made. Treat a missing value as unknown, not as 0.
Because each outcome is a score on its session, you can chart it next to the session's own events with no join. Every chart below starts from [Agent] Score filtered on [Agent] Score Name. Charts by event time bucket outcomes by when the work was written. The step-by-step recipe is the code outcomes recipe.
- How much agent work holds? Chart the count of
commit_mergedminus the count ofcommit_reverted, grouped by[Agent] Agent ID. Both are timed at the commit's author date, so a date range that ends 30 days ago counts the changes written at least 30 days ago that are still unreverted. The revert rate iscommit_reverteddivided bycommit_merged. - Did a change to the agent setup help? Divide
commit_revertedbycommit_merged, anddeploy_failedby both deploy scores, grouped byagent_setup_version. A deploy score counts one commit in one deployment attempt, so a commit in a failed deployment that later succeeds counts once in each. - Do agent pull requests pass CI the first time, and how much review do they need? Chart the average
[Agent] Score Valueofci_passed_first_run, which is the pass rate, and ofreview_roundsandchanges_requested_count, grouped by[Agent] Agent IDoragent_setup_version. Every session in a pull request carries these scores, so for rates by pull request, count distinctpr_numbervalues. - Which sessions reach production? Build a funnel from an
[Agent] Tool Callwherecommit_shais set, tocommit_merged, todeploy_succeeded, held on[Agent] Session ID. - Which session patterns get reverted? Group
commit_revertedby an evaluator's result, such as the Session Shape evaluator.
These charts compare work across stages: a person at the keyboard, a headless run, CI, a schedule, or an event.
- Sessions by stage: Count distinct
[Agent] Session IDvalues on[Agent] User Message, grouped by[Agent] Session Trigger. Add a filter on[Agent] Agent Chain Depthgreater than 1 to see delegated work. Sessions whose harness can't tell how they started have no trigger. - Grind rate by intent and model: Chart
[Agent] Evaluator Resultwhere[Agent] Evaluator Nameis the Session Shape evaluator, grouped by[Agent] Primary Labeland[Agent] Models Used. The Grind share is the grind rate. Chart the Coding Intent evaluator's results the same way, as the second breakdown next to it. Each Evaluator Result carries one evaluator's label, so the two results don't combine on one event. Refer to Coding agent templates. - Claimed done without verification, by stage: Chart
[Agent] Evaluator Resultwhere[Agent] Evaluator Nameis the Claimed Done Without Verification evaluator, grouped by[Agent] Session Trigger, with the average of[Agent] Binary Valueas the metric. That average is the rate for each stage. Evaluator Results carry the session's trigger, so this is one event and no join. - Review effort by stage: Chart the average
[Agent] Score Valueofreview_roundsandhours_to_first_review, grouped byagent_trigger. - Cost per merged change, by stage or by agent tree: A formula that divides the sum of
[Agent] Cost USDon[Agent] AI Responseby the count of[Agent] Scorewhere[Agent] Score Nameiscommit_merged. Group the two sides on the matching value:[Agent] Session Triggeragainstagent_trigger, or[Agent] Root Agent Nameagainstagent_name. It's an aggregate ratio, not a join for each change, and it counts cost only from harnesses that report one.
Measure a prompt that went viral. A prompt or skill can spread to many teams before anyone checks whether it works on their code. To find out across every session, by outcome:
- A pasted prompt: Create an evaluator from the Prompt or Skill Used template, a Regex evaluator that scans user messages, and replace its placeholder pattern with the prompt's text. It reads user message text, so it matches only sessions that send prompts, as in the
fullcontent mode or withOTEL_LOG_USER_PROMPTS=1for Claude Code. Then compare Session Shape and Claimed Done Without Verification on the matching sessions against the rest: filter the Sessions tab by the Prompt or Skill Used result, onceTrueand onceFalse, and read the other two evaluators' results. - A prompt saved as a command or skill: Saving it under a path in
AMPLITUDE_AGENT_SETUP_PATHS, such as the default.claude,.codex, or.cursor, changesagent_setup_version. Compare thereview_roundsandci_passed_first_runscores, the revert rate (commit_reverteddivided bycommit_merged), and the deploy failure rate (deploy_faileddivided by both deploy scores) byagent_setup_version, before and after the version that added it. - Across harnesses: Group the session charts by
[Agent] Agent ID, for exampleclaude-codeagainstcodex, to see whether the prompt works as well in each one.
Upgrade from an earlier version: Run init again, with npx -y -p @amplitude/ai amplitude-ai coding-agents init, or amplitude-ai coding-agents init in a Python project. It replaces an unchanged copy of an earlier workflow. init reports a workflow you edited as customized and leaves it alone. --force replaces it, or you can move your edits to the new workflow by hand. coding-agents doctor reports the workflow as current, outdated, or customized. Version 3 sends [Agent] Score events in place of the Commit Merged, Commit Reverted, Pull Request Merged, Deploy Succeeded, and Deploy Failed events that earlier versions sent, so rebuild charts that use those events on [Agent] Score Name.
Get started
Follow the goose integration guide. Run one goose session that makes a commit, from the CLI or the desktop app, then confirm in Live Events:
- Session ID is the goose session ID, not a trace ID.
- User ID is your
enduser.id, notunknown. - The turn shows User Message text, the tool call, and AI Response text, with the model name and both token counts.
- Two desktop sessions running at once stay separate.
- The
git committool call carriescommit_sha, and the commit has anAgent-Session-Idtrailer.
이 내용이 도움이 되었나요?
For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.