Skip to content

feat: record per-transition duration and phase metrics - #30265

Closed
cstyan wants to merge 2 commits into
mainfrom
callum/chatd-02-transition-metrics
Closed

cstyan wants to merge 2 commits into
mainfrom
callum/chatd-02-transition-metrics

Conversation

@cstyan

@cstyan cstyan commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Each ChatMachine.Update is one transaction that locks the chat row, runs one or more transitions, and commits. This records every Update in two histograms labelled by the transitions the callback ran (joined by +) and the outcome (committed or rolled_back): coderd_chatd_transition_duration_seconds, and coderd_chatd_transition_phase_seconds with a phase label of pre_lock (BeginTx, including any wait for a pooled connection), lock_wait (the row lock statement), callback (statements run while holding the row), and commit. Acquire, Abandon, and ReconcileInvalidState do not validate through the matrix check, so every transition now records its name through Tx.enter instead of landing under none.

Database impact: none; the histograms are in-process. The point is attribution: lock_wait shows which transition shapes queue behind others on the same chat, and callback is the lock hold time, which is what the rest of this series shortens. Landing this first lets each later PR be measured on its own.

Combined with the other PRs: overlaps textually with #30267 (both edit Tx and the lock statement in Update; the phase timing wraps whichever lock call is there) and with #30269 (Metrics.observe gains outcome="lock_unavailable" for ErrChatLocked); whichever merges second carries those lines.

Series: #30264 harness jitter, #30265 transition metrics, #30266 lock-free stream reads, #30267 single-write transitions, #30268 commit-write result and RBAC cache, #30269 non-blocking acquisition, #30270 finish turn in the step commit.


Generated by Coder Agents on behalf of @cstyan.

Each ChatMachine.Update is one transaction that locks the chat row, runs
one or more transitions, and commits. Two histograms now record every
Update, labelled by the transitions the callback ran (joined by '+') and
whether it committed or rolled back:

  coderd_chatd_transition_duration_seconds  lock attempt to commit
  coderd_chatd_transition_phase_seconds     one series per phase

The phase label splits each Update into pre_lock (BeginTx, including
any wait for a pooled connection), lock_wait (the row lock statement),
callback (statements run while holding the row), and commit (COMMIT or
ROLLBACK). The counts give the number of transactions per turn by
shape, lock_wait shows which shapes queue behind other transitions on
the same chat, and callback is the time each shape holds the lock.

Acquire, Abandon, and ReconcileInvalidState validate without
requireFromAllowed, so every transition records its name through
Tx.enter rather than only the ones that go through the matrix check.
@cstyan cstyan changed the title feat(coderd/x/chatd): record per-transition duration and phase metrics feat: record per-transition duration and phase metrics Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@linear-code

linear-code Bot commented Oct 29, 2026

Copy link
Copy Markdown

GRU-111

@github-actions github-actions Bot added the stale This issue is like stale bread. label Nov 10, 2026
@github-actions github-actions Bot closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant