Skip to content

feat(observability): count orphaned pending task cancellations#751

Draft
aparajon wants to merge 1 commit into
mainfrom
armand/orphaned-task-cancel-metric
Draft

feat(observability): count orphaned pending task cancellations#751
aparajon wants to merge 1 commit into
mainfrom
armand/orphaned-task-cancel-metric

Conversation

@aparajon

Copy link
Copy Markdown
Collaborator

Why this matters

The conflict check now cancels pending tasks whose apply already reached a terminal state so they stop blocking new applies. That sweep self-heals the database, but every cancellation means something upstream settled an apply while leaving its task pending — a signal operators should see spike and investigate, not discover through log searches.

What it does

  • Adds a schemabot.orphaned_task_cancel_total counter (database, environment, outcome) recorded by the conflict-check sweep, with outcomes cancelled (orphan durably cancelled) and write_failed (cancellation write failed, task kept blocking fail-closed).
  • Documents the metric in the metrics README.

Follow-up observability for the orphaned-task sweep introduced in #750.

🤖 Generated with Claude Code

The conflict-check sweep that cancels a pending task whose apply already
settled self-heals the database, but each cancellation means something
upstream left a task behind on a settled apply. Count both outcomes —
"cancelled" and the fail-closed "write_failed" — so operators can spot a
spike and investigate the source instead of relying on log searches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds operator-facing observability around the orphaned-pending-task cancellation sweep in the local/tern conflict check, so spikes in this self-healing behavior are visible via metrics (rather than only discoverable via logs).

Changes:

  • Adds a new counter metric schemabot.orphaned_task_cancel_total with bounded outcome values (cancelled, write_failed) and tags it with database and environment.
  • Emits the metric from the orphaned pending task cancellation path in the conflict check.
  • Documents the new metric in the metrics README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/tern/local_apply.go Records the new orphaned-task cancellation metric on success and on durable-write failure.
pkg/metrics/metrics.go Defines RecordOrphanedTaskCancel and bounds outcome cardinality.
pkg/metrics/README.md Adds the new metric to the published metrics table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants