mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-06 18:39:42 +00:00
Distinguish occupied poll cycle slots from Availability planning (#5975)
**Distinguish occupied poll cycle slots from Availability planning** Export count and oldest age by poll phase so an old Availability catalog read does not mask which ordinary slots are occupied. Keep the aggregate gauges and the watchdog decision unchanged. **Bind scheduler diagnostics documentation checks to poll phases** Keep the existing planning-gauge compatibility assertions and check the updated guidance for detached Availability and ordinary slots. --- Fleet candidate `20261205T061157Z-core-runtime` from the `core-runtime` lane. Reviewed tip `1c2edf8d3d511a9054f0a0304ccb61a446c0f7ce` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
@@ -293,6 +293,8 @@ in the same window without changing a rule or sending a test notification.
|
||||
| `pulse_scheduler_claimed_poll_overdue_seconds` | Gauge | Seconds past one poll task timeout for the most overdue claimed poll, by stage. Zero if no claimed poll is over that budget. |
|
||||
| `pulse_scheduler_poll_planning_age_seconds` | Gauge | Seconds the oldest active poll planning pass has spent reading rosters, building the plan or putting work on the queue. Process-wide, without labels. Zero means no measurable planning wait, not healthy monitoring. |
|
||||
| `pulse_scheduler_poll_post_plan_age_seconds` | Gauge | Seconds since the oldest unfinished cycle entered post-planning work. Process-wide, without labels. Zero means no measurable post-planning work, not healthy monitoring. |
|
||||
| `pulse_scheduler_poll_phase_age_seconds` | Gauge | Seconds the oldest unfinished poll cycle or detached Availability plan has spent in each `phase`; zero if none. |
|
||||
| `pulse_scheduler_poll_phase_active` | Gauge | Number of unfinished poll cycles or detached Availability plans in each `phase`; zero if none. |
|
||||
| `pulse_scheduler_dead_letter_depth` | Gauge | Terminal poll entries still parked in running schedulers at scrape time, by `instance_type` and `instance`. |
|
||||
| `pulse_scheduler_breaker_state` | Gauge | `0`=Closed, `1`=Half-Open, `2`=Open, `-1`=Unknown. |
|
||||
| `pulse_scheduler_breaker_failure_count` | Gauge | Consecutive failure count. |
|
||||
@@ -347,9 +349,25 @@ When expected results stop, check the two claimed-poll stages on successive scra
|
||||
|
||||
If `pulse_scheduler_queued_poll_overdue_seconds` and both claimed-poll stages
|
||||
stay at zero while expected poll counters stop moving, check
|
||||
`pulse_scheduler_poll_planning_age_seconds` on successive scrapes. A rising age
|
||||
means an unfinished poll planning pass is still blocked reading provider
|
||||
rosters, building the plan, or queuing tasks before any work reaches the queue.
|
||||
`pulse_scheduler_poll_phase_age_seconds` and `pulse_scheduler_poll_phase_active`
|
||||
on successive scrapes:
|
||||
|
||||
- `planning`: ordinary cycles reading provider rosters, building a plan or
|
||||
queuing tasks.
|
||||
- `post_plan`: ordinary cycles counting WebSocket clients, recording
|
||||
statistics or synchronizing alert state.
|
||||
- `availability_planning`: separate saved Availability catalog planning; this
|
||||
does not occupy an ordinary slot.
|
||||
|
||||
On a single-monitor server, `planning` and `post_plan` counts adding up to two
|
||||
on successive scrapes, with a rising age, show both slots occupied at those
|
||||
samples. An old Availability plan with both ordinary counts at zero is not
|
||||
ordinary slot saturation. On a multi-monitor server the counts are aggregated,
|
||||
so they cannot show which monitor has both slots occupied.
|
||||
|
||||
For existing queries, `pulse_scheduler_poll_planning_age_seconds` still
|
||||
reports the oldest planning pass of either kind. A rising age does not by
|
||||
itself identify which plan is slow.
|
||||
When a monitor is retired while a planning pass is reading rosters, Pulse
|
||||
abandons the returned plan once cancellation is observed instead of queuing
|
||||
tasks or running post-plan statistics and alert reconciliation, while keeping
|
||||
@@ -358,10 +376,10 @@ until it returns. Availability check planning runs in its own single-slot
|
||||
detached pass, so a slow Availability catalog read or blocked synchronous panic
|
||||
recovery log write also keeps `pulse_scheduler_poll_planning_age_seconds`
|
||||
rising until that pass returns and releases its slot, even while ordinary
|
||||
provider poll cycles continue advancing. Because the gauge is process-wide
|
||||
without labels, compare `pulse_monitor_poll_total` and
|
||||
`pulse_monitor_poll_staleness_seconds` by `instance_type` to tell whether only
|
||||
Availability planning is blocked or ordinary provider polling has also stalled.
|
||||
provider poll cycles continue advancing. Use the phase gauges to separate
|
||||
the two plans, then compare `pulse_monitor_poll_total` and
|
||||
`pulse_monitor_poll_staleness_seconds` by `instance_type` to see what is still
|
||||
returning results.
|
||||
Zero means no active planning wait is measured at scrape time,
|
||||
not that polling is healthy or that the watchdog heartbeat or alert rules ran.
|
||||
|
||||
|
||||
@@ -484,6 +484,22 @@ cycle slots and scrapes through the Prometheus handler. Age grows with no
|
||||
unfinished planner, survives cancellation while the slots are still held and
|
||||
returns to zero when they unwind. An excess tick cannot consume a third slot.
|
||||
|
||||
The process-wide `pulse_scheduler_poll_phase_active` and
|
||||
`pulse_scheduler_poll_phase_age_seconds` gauges publish the active count and
|
||||
oldest elapsed time for `planning`, `post_plan` and the separate
|
||||
`availability_planning` phase. An admitted ordinary cycle moves between its two
|
||||
phases atomically for scrapes; a skipped tick records no work. A detached
|
||||
Availability plan counts only in its own phase. Canceled, still-running work
|
||||
keeps its phase until return or unwind. The existing unlabeled planning gauge
|
||||
remains the maximum of ordinary and Availability planning, and the post-plan
|
||||
gauge keeps its original meaning. Phase samples use the existing bookkeeping
|
||||
lock with no monitor, queue or provider lock, identify no tenant or target
|
||||
and do not change watchdog or poll decisions.
|
||||
`TestSchedulerScrapeSeparatesOrdinaryCycleSlotsFromAvailabilityPlanning`
|
||||
checks the real exporter with both ordinary slots held in different phases and
|
||||
an older detached Availability read, covering an excess tick, cancellation,
|
||||
and each phase clearing without hiding the still-busy phase.
|
||||
|
||||
Periodic cycles still prune alerts for removed Docker hosts and publish
|
||||
acknowledgements and recent resolutions. They do not log a Debug line on
|
||||
every unchanged acknowledgement or nonempty recent-resolution snapshot.
|
||||
|
||||
@@ -130,10 +130,6 @@ func (m *Monitor) planScheduledPolls(ctx context.Context, now time.Time) {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
progress := m.pollWorkProgress()
|
||||
id := progress.beginPlanning(time.Now())
|
||||
defer progress.finishPlanning(id)
|
||||
|
||||
providers := m.pollProviderSnapshotWithBuiltins()
|
||||
for i, provider := range providers {
|
||||
if provider.Type() == InstanceTypeAvailability {
|
||||
@@ -158,8 +154,8 @@ func (m *Monitor) startAvailabilityPollPlan(ctx context.Context, now time.Time,
|
||||
go func() {
|
||||
defer q.availabilityPlanSlot.Unlock()
|
||||
progress := m.pollWorkProgress()
|
||||
id := progress.beginPlanning(time.Now())
|
||||
defer progress.finishPlanning(id)
|
||||
id := progress.beginPhase(pollWorkAvailabilityPlanning, time.Now())
|
||||
defer progress.finishPhase(id)
|
||||
// Recovery logs synchronously while this planner still owns the
|
||||
// slot. Keep the pass visible until that write returns.
|
||||
defer recoverFromPanic("availabilityPollPlan")
|
||||
@@ -203,14 +199,15 @@ func (m *Monitor) poll(ctx context.Context, wsHub *websocket.Hub) {
|
||||
defer atomic.AddInt32(&m.activePollCount, -1)
|
||||
|
||||
startTime := time.Now()
|
||||
progress := m.pollWorkProgress()
|
||||
id := progress.beginPhase(pollWorkPlanning, startTime)
|
||||
defer progress.finishPhase(id)
|
||||
m.planScheduledPolls(ctx, startTime)
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
progress := m.pollWorkProgress()
|
||||
id := progress.beginPostPlan(time.Now())
|
||||
defer progress.finishPostPlan(id)
|
||||
progress.startPostPlan(id, time.Now())
|
||||
|
||||
// Update performance metrics atomically to prevent data races when
|
||||
// multiple poll() goroutines run concurrently (e.g. mock mode transitions).
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rcourtman/pulse-go-rewrite/internal/alerts"
|
||||
"github.com/rcourtman/pulse-go-rewrite/internal/models"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func TestSchedulerScrapeSeparatesOrdinaryCycleSlotsFromAvailabilityPlanning(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
m := newScheduleFixture(ctx, false, nil)
|
||||
reg := prometheus.NewRegistry()
|
||||
m.pollMetrics = newPollMetrics(reg)
|
||||
|
||||
manager := alerts.NewManagerWithDataDir(t.TempDir())
|
||||
defer manager.Stop()
|
||||
m.alertManager = manager
|
||||
for range 3 {
|
||||
manager.HandleDockerHostOffline(models.DockerHost{ID: "orphan", DisplayName: "fixture"})
|
||||
}
|
||||
resumePostPlan := make(chan struct{})
|
||||
releasePostPlan := sync.OnceFunc(func() { close(resumePostPlan) })
|
||||
restore := setPackageTestLogOutput(t, heldPollLifecycleWriter{
|
||||
message: "pruned stale docker alerts during sync", resume: resumePostPlan,
|
||||
}, zerolog.DebugLevel)
|
||||
defer restore()
|
||||
defer releasePostPlan()
|
||||
|
||||
resumeAvailability := make(chan struct{})
|
||||
releaseAvailability := sync.OnceFunc(func() { close(resumeAvailability) })
|
||||
defer releaseAvailability()
|
||||
if err := m.RegisterPollProvider(heldAvailabilityRoster{
|
||||
hold: func() { <-resumeAvailability },
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resumeOrdinary := make(chan struct{})
|
||||
releaseOrdinary := sync.OnceFunc(func() { close(resumeOrdinary) })
|
||||
defer releaseOrdinary()
|
||||
var rosterReads atomic.Int32
|
||||
if err := m.RegisterPollProvider(heldPlanningRoster{
|
||||
testPollProvider: testPollProvider{providerType: "fixture"},
|
||||
hold: func() {
|
||||
if rosterReads.Add(1) == 2 {
|
||||
<-resumeOrdinary
|
||||
}
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handler := promhttp.HandlerFor(reg, promhttp.HandlerOpts{})
|
||||
scrape := func(lines ...string) {
|
||||
t.Helper()
|
||||
response := httptest.NewRecorder()
|
||||
handler.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/metrics", nil))
|
||||
if response.Code != http.StatusOK {
|
||||
t.Fatalf("scrape returned HTTP %d", response.Code)
|
||||
}
|
||||
body := "\n" + response.Body.String()
|
||||
for _, line := range lines {
|
||||
if !strings.Contains(body, "\n"+line+"\n") {
|
||||
t.Errorf("scrape missing %q", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
go m.poll(ctx, nil)
|
||||
synctest.Wait()
|
||||
time.Sleep(20 * time.Second)
|
||||
go m.poll(ctx, nil)
|
||||
synctest.Wait()
|
||||
time.Sleep(12 * time.Second)
|
||||
m.poll(ctx, nil) // Saturated: neither roster nor cycle may start.
|
||||
if rosterReads.Load() != 2 || atomic.LoadInt32(&m.activePollCount) != 2 {
|
||||
t.Fatal("expected both ordinary slots to be occupied and third cycle skipped")
|
||||
}
|
||||
scrape(
|
||||
"pulse_scheduler_poll_planning_age_seconds 32", // old aggregate includes detached Availability
|
||||
"pulse_scheduler_poll_post_plan_age_seconds 32",
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="planning"} 12`,
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="post_plan"} 32`,
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="availability_planning"} 32`,
|
||||
`pulse_scheduler_poll_phase_active{phase="planning"} 1`,
|
||||
`pulse_scheduler_poll_phase_active{phase="post_plan"} 1`,
|
||||
`pulse_scheduler_poll_phase_active{phase="availability_planning"} 1`,
|
||||
)
|
||||
|
||||
// Cancellation is not a return. Release the two ordinary slots and
|
||||
// verify the detached Availability read still shows up on its own.
|
||||
cancel()
|
||||
scrape(
|
||||
`pulse_scheduler_poll_phase_active{phase="planning"} 1`,
|
||||
`pulse_scheduler_poll_phase_active{phase="post_plan"} 1`,
|
||||
`pulse_scheduler_poll_phase_active{phase="availability_planning"} 1`,
|
||||
)
|
||||
releaseOrdinary()
|
||||
releasePostPlan()
|
||||
synctest.Wait()
|
||||
scrape(
|
||||
"pulse_scheduler_poll_planning_age_seconds 32",
|
||||
"pulse_scheduler_poll_post_plan_age_seconds 0",
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="planning"} 0`,
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="post_plan"} 0`,
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="availability_planning"} 32`,
|
||||
`pulse_scheduler_poll_phase_active{phase="planning"} 0`,
|
||||
`pulse_scheduler_poll_phase_active{phase="post_plan"} 0`,
|
||||
`pulse_scheduler_poll_phase_active{phase="availability_planning"} 1`,
|
||||
)
|
||||
releaseAvailability()
|
||||
synctest.Wait()
|
||||
scrape(
|
||||
"pulse_scheduler_poll_planning_age_seconds 0",
|
||||
`pulse_scheduler_poll_phase_age_seconds{phase="availability_planning"} 0`,
|
||||
`pulse_scheduler_poll_phase_active{phase="availability_planning"} 0`,
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -22,6 +22,22 @@ type pollWorkDeadline struct {
|
||||
deadline time.Time
|
||||
}
|
||||
|
||||
type pollWorkPhase uint8
|
||||
|
||||
const (
|
||||
pollWorkPlanning pollWorkPhase = iota
|
||||
pollWorkPostPlan
|
||||
pollWorkAvailabilityPlanning
|
||||
pollWorkPhaseCount
|
||||
)
|
||||
|
||||
var pollWorkPhaseNames = [pollWorkPhaseCount]string{"planning", "post_plan", "availability_planning"}
|
||||
|
||||
type pollWorkPhaseEntry struct {
|
||||
phase pollWorkPhase
|
||||
startedAt time.Time
|
||||
}
|
||||
|
||||
// pollWorkProgress tracks active cycle phases, claimed tasks and agent
|
||||
// report applies, never the scheduled inventory. Its lock is not held
|
||||
// during queue, provider or state work. A scrape can measure work even
|
||||
@@ -30,12 +46,13 @@ type pollWorkProgress struct {
|
||||
overdue *prometheus.Desc
|
||||
planningAge *prometheus.Desc
|
||||
postPlanAge *prometheus.Desc
|
||||
phaseAge *prometheus.Desc
|
||||
phaseActive *prometheus.Desc
|
||||
reportAge *prometheus.Desc
|
||||
mu sync.Mutex
|
||||
lastID uint64
|
||||
active map[uint64]pollWorkDeadline
|
||||
planning map[uint64]time.Time
|
||||
postPlan map[uint64]time.Time
|
||||
phases map[uint64]pollWorkPhaseEntry
|
||||
reports map[uint64]time.Time
|
||||
}
|
||||
|
||||
@@ -56,15 +73,24 @@ func newPollWorkProgress() *pollWorkProgress {
|
||||
"Age in seconds of the oldest poll cycle still in post-plan work (client count, statistics or alert state sync); zero if none.",
|
||||
nil, nil,
|
||||
),
|
||||
phaseAge: prometheus.NewDesc(
|
||||
"pulse_scheduler_poll_phase_age_seconds",
|
||||
"Age in seconds of the oldest active poll cycle or detached Availability plan in each phase; zero if none.",
|
||||
[]string{"phase"}, nil,
|
||||
),
|
||||
phaseActive: prometheus.NewDesc(
|
||||
"pulse_scheduler_poll_phase_active",
|
||||
"Number of active poll cycles or detached Availability plans in each phase.",
|
||||
[]string{"phase"}, nil,
|
||||
),
|
||||
reportAge: prometheus.NewDesc(
|
||||
"pulse_monitor_agent_report_apply_age_seconds",
|
||||
"Age in seconds of the oldest active agent report apply; zero if none.",
|
||||
nil, nil,
|
||||
),
|
||||
active: make(map[uint64]pollWorkDeadline),
|
||||
planning: make(map[uint64]time.Time),
|
||||
postPlan: make(map[uint64]time.Time),
|
||||
reports: make(map[uint64]time.Time),
|
||||
active: make(map[uint64]pollWorkDeadline),
|
||||
phases: make(map[uint64]pollWorkPhaseEntry),
|
||||
reports: make(map[uint64]time.Time),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,43 +114,34 @@ func (p *pollWorkProgress) finishReportApply(id uint64) {
|
||||
p.mu.Unlock()
|
||||
}
|
||||
|
||||
func (p *pollWorkProgress) beginPlanning(at time.Time) uint64 {
|
||||
func (p *pollWorkProgress) beginPhase(phase pollWorkPhase, at time.Time) uint64 {
|
||||
if p == nil {
|
||||
return 0
|
||||
}
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.lastID++
|
||||
p.planning[p.lastID] = at
|
||||
p.phases[p.lastID] = pollWorkPhaseEntry{phase: phase, startedAt: at}
|
||||
return p.lastID
|
||||
}
|
||||
|
||||
func (p *pollWorkProgress) finishPlanning(id uint64) {
|
||||
// startPostPlan moves the same cycle between phases in one step, so a scrape
|
||||
// cannot count it twice or report a vacant slot during the handoff.
|
||||
func (p *pollWorkProgress) startPostPlan(id uint64, at time.Time) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
p.mu.Lock()
|
||||
delete(p.planning, id)
|
||||
p.phases[id] = pollWorkPhaseEntry{phase: pollWorkPostPlan, startedAt: at}
|
||||
p.mu.Unlock()
|
||||
}
|
||||
|
||||
func (p *pollWorkProgress) beginPostPlan(at time.Time) uint64 {
|
||||
if p == nil {
|
||||
return 0
|
||||
}
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.lastID++
|
||||
p.postPlan[p.lastID] = at
|
||||
return p.lastID
|
||||
}
|
||||
|
||||
func (p *pollWorkProgress) finishPostPlan(id uint64) {
|
||||
func (p *pollWorkProgress) finishPhase(id uint64) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
p.mu.Lock()
|
||||
delete(p.postPlan, id)
|
||||
delete(p.phases, id)
|
||||
p.mu.Unlock()
|
||||
}
|
||||
|
||||
@@ -161,26 +178,37 @@ func (p *pollWorkProgress) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- p.overdue
|
||||
ch <- p.planningAge
|
||||
ch <- p.postPlanAge
|
||||
ch <- p.phaseAge
|
||||
ch <- p.phaseActive
|
||||
ch <- p.reportAge
|
||||
}
|
||||
|
||||
func (p *pollWorkProgress) Collect(ch chan<- prometheus.Metric) {
|
||||
var overdue [pollWorkStageCount]time.Duration
|
||||
var phaseAge [pollWorkPhaseCount]time.Duration
|
||||
var phaseActive [pollWorkPhaseCount]int
|
||||
p.mu.Lock()
|
||||
now := time.Now()
|
||||
for _, work := range p.active {
|
||||
overdue[work.stage] = max(overdue[work.stage], now.Sub(work.deadline))
|
||||
}
|
||||
planningAge := oldestPhaseAge(now, p.planning)
|
||||
postPlanAge := oldestPhaseAge(now, p.postPlan)
|
||||
for _, entry := range p.phases {
|
||||
phaseAge[entry.phase] = max(phaseAge[entry.phase], now.Sub(entry.startedAt))
|
||||
phaseActive[entry.phase]++
|
||||
}
|
||||
reportAge := oldestPhaseAge(now, p.reports)
|
||||
p.mu.Unlock()
|
||||
|
||||
for stage, wait := range overdue {
|
||||
ch <- prometheus.MustNewConstMetric(p.overdue, prometheus.GaugeValue, wait.Seconds(), pollWorkStageNames[stage])
|
||||
}
|
||||
planningAge := max(phaseAge[pollWorkPlanning], phaseAge[pollWorkAvailabilityPlanning])
|
||||
ch <- prometheus.MustNewConstMetric(p.planningAge, prometheus.GaugeValue, planningAge.Seconds())
|
||||
ch <- prometheus.MustNewConstMetric(p.postPlanAge, prometheus.GaugeValue, postPlanAge.Seconds())
|
||||
ch <- prometheus.MustNewConstMetric(p.postPlanAge, prometheus.GaugeValue, phaseAge[pollWorkPostPlan].Seconds())
|
||||
for phase, age := range phaseAge {
|
||||
ch <- prometheus.MustNewConstMetric(p.phaseAge, prometheus.GaugeValue, age.Seconds(), pollWorkPhaseNames[phase])
|
||||
ch <- prometheus.MustNewConstMetric(p.phaseActive, prometheus.GaugeValue, float64(phaseActive[phase]), pollWorkPhaseNames[phase])
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(p.reportAge, prometheus.GaugeValue, reportAge.Seconds())
|
||||
}
|
||||
|
||||
|
||||
@@ -985,6 +985,8 @@ class AIAutonomyHelpDocsTest(unittest.TestCase):
|
||||
|
||||
self.assertIn('"pulse_scheduler_claimed_poll_overdue_seconds"', progress_go)
|
||||
self.assertIn('"pulse_scheduler_poll_planning_age_seconds"', progress_go)
|
||||
self.assertIn('"pulse_scheduler_poll_phase_age_seconds"', progress_go)
|
||||
self.assertIn('"pulse_scheduler_poll_phase_active"', progress_go)
|
||||
self.assertIn("while the panic handler is blocked writing to the log sink", workers_go)
|
||||
|
||||
prom_norm = " ".join(
|
||||
@@ -994,8 +996,10 @@ class AIAutonomyHelpDocsTest(unittest.TestCase):
|
||||
)
|
||||
for phrase in (
|
||||
"task preparation, provider calls, rescheduling and recovery logging.",
|
||||
"If `pulse_scheduler_queued_poll_overdue_seconds` and both claimed-poll stages stay at zero while expected poll counters stop moving, check `pulse_scheduler_poll_planning_age_seconds` on successive scrapes.",
|
||||
"A rising age means an unfinished poll planning pass is still blocked reading provider rosters, building the plan, or queuing tasks before any work reaches the queue.",
|
||||
"If `pulse_scheduler_queued_poll_overdue_seconds` and both claimed-poll stages stay at zero while expected poll counters stop moving, check `pulse_scheduler_poll_phase_age_seconds` and `pulse_scheduler_poll_phase_active` on successive scrapes:",
|
||||
"`availability_planning`: separate saved Availability catalog planning; this does not occupy an ordinary slot.",
|
||||
"On a multi-monitor server the counts are aggregated, so they cannot show which monitor has both slots occupied.",
|
||||
"For existing queries, `pulse_scheduler_poll_planning_age_seconds` still reports the oldest planning pass of either kind.",
|
||||
):
|
||||
with self.subTest(doc="PROMETHEUS_METRICS.md", phrase=phrase):
|
||||
self.assertIn(phrase, prom_norm)
|
||||
|
||||
@@ -603,8 +603,10 @@ class SchedulerPollingDocsTest(unittest.TestCase):
|
||||
task_workers = (ROOT / "internal/monitoring/poll_task_workers.go").read_text()
|
||||
|
||||
self.assertIn('"pulse_scheduler_poll_planning_age_seconds"', work_progress)
|
||||
self.assertIn("func (p *pollWorkProgress) beginPlanning(", work_progress)
|
||||
self.assertIn("func (p *pollWorkProgress) finishPlanning(", work_progress)
|
||||
self.assertIn(
|
||||
"planningAge := max(phaseAge[pollWorkPlanning], phaseAge[pollWorkAvailabilityPlanning])",
|
||||
work_progress,
|
||||
)
|
||||
self.assertIn("defer progress.finish(work)", task_workers)
|
||||
self.assertIn("Recovered from panic in scheduled poll task", task_workers)
|
||||
|
||||
|
||||
@@ -150,8 +150,9 @@ class WatchdogHelpDocsTest(unittest.TestCase):
|
||||
|
||||
for token in (
|
||||
"func (m *Monitor) planScheduledPolls(ctx context.Context, now time.Time)",
|
||||
"id := progress.beginPlanning(time.Now())",
|
||||
"defer progress.finishPlanning(id)",
|
||||
"id := progress.beginPhase(pollWorkPlanning, startTime)",
|
||||
"defer progress.finishPhase(id)",
|
||||
"progress.startPostPlan(id, time.Now())",
|
||||
"m.taskQueue.upsertPlan(task, revision)",
|
||||
"m.state.UpdatePollStats(",
|
||||
):
|
||||
@@ -371,10 +372,11 @@ class WatchdogHelpDocsTest(unittest.TestCase):
|
||||
"func (m *Monitor) startAvailabilityPollPlan(", 1
|
||||
)[1].split("\nfunc ", 1)[0]
|
||||
self.assertIn("!q.availabilityPlanSlot.TryLock()", avail_plan_fn)
|
||||
self.assertIn("defer progress.finishPlanning(id)", avail_plan_fn)
|
||||
self.assertIn("id := progress.beginPhase(pollWorkAvailabilityPlanning, time.Now())", avail_plan_fn)
|
||||
self.assertIn("defer progress.finishPhase(id)", avail_plan_fn)
|
||||
self.assertIn('defer recoverFromPanic("availabilityPollPlan")', avail_plan_fn)
|
||||
self.assertLess(
|
||||
avail_plan_fn.index("defer progress.finishPlanning(id)"),
|
||||
avail_plan_fn.index("defer progress.finishPhase(id)"),
|
||||
avail_plan_fn.index('defer recoverFromPanic("availabilityPollPlan")'),
|
||||
)
|
||||
avail_plan_docs = (
|
||||
@@ -382,7 +384,7 @@ class WatchdogHelpDocsTest(unittest.TestCase):
|
||||
"docs/monitoring/PROMETHEUS_METRICS.md",
|
||||
(
|
||||
"Availability check planning runs in its own single-slot detached pass, so a slow Availability catalog read or blocked synchronous panic recovery log write also keeps pulse_scheduler_poll_planning_age_seconds rising until that pass returns and releases its slot, even while ordinary provider poll cycles continue advancing",
|
||||
"Because the gauge is process-wide without labels, compare pulse_monitor_poll_total and pulse_monitor_poll_staleness_seconds by instance_type to tell whether only Availability planning is blocked or ordinary provider polling has also stalled",
|
||||
"Use the phase gauges to separate the two plans, then compare pulse_monitor_poll_total and pulse_monitor_poll_staleness_seconds by instance_type to see what is still returning results",
|
||||
),
|
||||
),
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user