Skip to content

feat(telemetry): instrument Agent Mode run lifecycle#330

Open
cameroncooke wants to merge 1 commit into
cameroncooke/sentry-07-workspace-action-telemetryfrom
cameroncooke/sentry-08-agent-run-telemetry
Open

feat(telemetry): instrument Agent Mode run lifecycle#330
cameroncooke wants to merge 1 commit into
cameroncooke/sentry-07-workspace-action-telemetryfrom
cameroncooke/sentry-08-agent-run-telemetry

Conversation

@cameroncooke

@cameroncooke cameroncooke commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Instruments the Agent Mode run lifecycle — the richest telemetry surface.

Stack: 8/10 · depends on PR 2 · Refs GH-183

What this changes

  • AgentRunSentryTelemetry.swift (new, @MainActor) — tracks a run start → terminal:
    • breadcrumbs agent.run.started/completed/failed/cancelled,
    • agent.run.session.starts counter, agent.run.active gauge (1/0), agent.run.duration distribution (coarse wall-clock),
    • chat-item kinds → tool-started/terminal breadcrumbs + a one-time agent.provider.first_event span,
    • approval decisions (ApprovalKind/ApprovalOutcome).
  • AgentModeViewModel(.swift + InteractionActions/TabSession/WorktreeMerge), AgentModeRunService.swift, AgentRunTerminalCommitBarrier.swift — call sites at the lifecycle points.

Business rules

  • Model recorded as ModelFamily, provider as ProviderKind (closed enums — raw model/provider strings never escape).
  • message_role + counts only — never message text or transcript.
  • Duration is coarse milliseconds from activeAgentRunStartedAt.

Key decisions

  • @MainActor because it reads view-model session state.
  • Bodies gated under #if; non-Void helpers live entirely inside one #if block so default builds compile them out cleanly.

Note on size

~575 LOC; the bulk is the 417-line AgentRunSentryTelemetry.swift, a single indivisible new file.

Test plan

  • Builds in both modes. ✅ verified.

@cameroncooke cameroncooke force-pushed the cameroncooke/sentry-08-agent-run-telemetry branch from b31d2e2 to e3b9139 Compare June 29, 2026 21:40
@cameroncooke cameroncooke force-pushed the cameroncooke/sentry-07-workspace-action-telemetry branch from ac072a1 to 78d8914 Compare June 29, 2026 21:40
@cameroncooke cameroncooke force-pushed the cameroncooke/sentry-07-workspace-action-telemetry branch from 78d8914 to ad68ae6 Compare June 29, 2026 22:49
@cameroncooke cameroncooke force-pushed the cameroncooke/sentry-08-agent-run-telemetry branch from e3b9139 to 000cdcf Compare June 29, 2026 22:49
@cameroncooke cameroncooke marked this pull request as ready for review June 30, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant