Skip to content

[CRE-7344] Observe trigger coordinator gauges at collection time - #24258

Merged
MStreet3 merged 1 commit into
developfrom
CRE-7344-observe-coordinator-gauges
Nov 23, 2026
Merged

MStreet3 merged 1 commit into
developfrom
CRE-7344-observe-coordinator-gauges

Conversation

@MStreet3

@MStreet3 MStreet3 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

CRE-7344

Replaces #24257.

What this fixes

platform_trigger_coordinator_readers should count the trigger reader goroutines on a node. In staging it read 1–3 per node, while platform_trigger_coordinator_workflows read 988 on the same Zone A nodes.

There were two problems:

  1. Eager defer. Each reader goroutine (added in [CRE-6944] Add coordinator metrics #23945) did defer c.deps.Metrics.UpdateTriggerCoordinatorReadersGauge(ctx, c.readersGauge.Add(-1)). Go evaluates a deferred call's arguments when the defer runs, so the counter dropped when each reader started, and that stale value was recorded when the reader exited.
  2. Racy recording. Even with the defer fixed, "update the counter, then record it" is two steps. When readers exit at the same time, an older value can be recorded after a newer one and stick until the next change. The workflows gauge has the same pattern. A fix for (1) alone failed about 1 in 10 runs of the new test.

The change

The coordinator's two gauges become observable: the coordinator keeps its atomic counters, and the gauges read them when metrics are collected.

  • monitoring: platform_trigger_coordinator_workflows and platform_trigger_coordinator_readers are now Int64ObservableGauge. RegisterTriggerCoordinatorGauges(workflows, readers func() int64) replaces the two UpdateTriggerCoordinator*Gauge methods. Metric names and labels are unchanged, so dashboards need no change.
  • triggers.coordinator: registers the callback on start, unregisters it on close, and only does atomic adds on the hot path (defer c.readersGauge.Add(-1) in each reader).
  • An idle node now reports 0 instead of having no series.

Metrics only: trigger reading and execution are unchanged.

Tests

  • TestCoordinator_Gauges: the gauges read 0 on an idle coordinator. It registers one workflow with three triggers and waits on unbuffered channel sends until every reader is in its read loop, so there are no sleeps or polling windows. Then it checks the gauges read 1 workflow and 3 readers, and that both return to 0 after unregistering. It fails every time with the original bug, and passed 200/200 runs with -race.
  • TestCoordinator_GaugesStopOnClose: a closed coordinator stops reporting.
  • The labels test in monitoring_test.go now uses the callback.

Requires

None.

Supports

None.

Deployment Validation Steps

  • After deploy, platform_trigger_coordinator_readers per node should be at least platform_trigger_coordinator_workflows, since each workflow has one or more triggers. Nodes with no coordinated workflows should report 0 for both.

platform_trigger_coordinator_readers read 1-3 per node in staging
against 988 coordinated workflows. Each reader deferred the gauge
update directly, so Go evaluated readersGauge.Add(-1) when the reader
started and recorded that stale value when it exited. Recording on
every change is also racy on its own: concurrent updates can record
out of order and leave a stale value behind.

Make the workflows and readers gauges observable. The coordinator
keeps its two atomic counters and registers one callback on start
that reports them at collection time, and unregisters it on close.
The gauges now always match the counters, and an idle node reports 0
instead of no series. Metric names and labels are unchanged.
@github-actions

Copy link
Copy Markdown
Contributor

👋 MStreet3, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@MStreet3
MStreet3 enabled auto-merge November 23, 2026 14:49
@MStreet3
MStreet3 added this pull request to the merge queue Nov 23, 2026
Merged via the queue into develop with commit dcd7fc3 Nov 23, 2026
236 checks passed
@MStreet3
MStreet3 deleted the CRE-7344-observe-coordinator-gauges branch November 23, 2026 15:22
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.

3 participants