Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-6741: retire heartbeat index and runtime sampler metrics (#7622)

Multica Eve74a7de9218a7
diff --git a/deploy/helm/multica/templates/prometheusrule.yaml b/deploy/helm/multica/templates/prometheusrule.yaml
index 802ec1b382..4715daac12 100644
--- a/deploy/helm/multica/templates/prometheusrule.yaml
+++ b/deploy/helm/multica/templates/prometheusrule.yaml
@@ -1,5 +1,5 @@
{{- if .Values.monitoring.prometheusRule.enabled }}
-{{- $samplerQueryNames := "active_users|active_workspaces|task_queued|task_running|task_stuck|runtime_online|runtime_heartbeat_age|workspace_total" -}}
+{{- $samplerQueryNames := "active_users|active_workspaces|task_queued|task_running|task_stuck|workspace_total" -}}
{{- $samplerErrorNames := printf "acquire|%s" $samplerQueryNames -}}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
diff --git a/server/cmd/migrate/main.go b/server/cmd/migrate/main.go
index 31a650ad89..d6d409caea 100644
--- a/server/cmd/migrate/main.go
+++ b/server/cmd/migrate/main.go
@@ -293,6 +293,7 @@ var concurrentDownIndexCleanups = map[string]string{
"371_comment_content_search_index_strategy": "idx_comment_content_trgm",
"375_drop_issue_last_activity_index": "idx_issue_workspace_last_activity",
"391_drop_agent_task_queue_dispatched_prepare_index": "idx_agent_task_queue_dispatched_prepare",
+ "437_drop_agent_runtime_last_seen_at_index": "idx_agent_runtime_last_seen_at",
}
var preMigrationHooks = func() map[string]preMigrationHook {
diff --git a/server/cmd/migrate/migrate_agent_runtime_last_seen_at_index_retirement_test.go b/server/cmd/migrate/migrate_agent_runtime_last_seen_at_index_retirement_test.go
new file mode 100644
index 0000000000..924c024f43
--- /dev/null
+++ b/server/cmd/migrate/migrate_agent_runtime_last_seen_at_index_retirement_test.go
@@ -0,0 +1,98 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "math/rand/v2"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/jackc/pgx/v5"
+ "github.com/jackc/pgx/v5/pgxpool"
+)
+
+func TestAgentRuntimeLastSeenAtIndexRetirement(t *testing.T) {
+ adminPool := openTestPool(t)
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+
+ schema, pool := createAgentRuntimeLastSeenAtIndexFixture(t, ctx, adminPool)
+ options := runOptions{
+ Direction: "up",
+ SchemaMigrationsTable: schema + ".schema_migrations",
+ AdvisoryLockKey: int64(rand.Uint64()&0x7fffffffffffffff) | 1,
+ Hooks: hooksForDirection("up"),
+ }
+
+ options.Files = realMigrationFiles(t, []string{"115_agent_runtime_last_seen_at_index"}, "up")
+ if err := runMigrations(ctx, pool, options); err != nil {
+ t.Fatalf("apply historical runtime index migration: %v", err)
+ }
+ assertIndexValidity(t, pool, schema, "idx_agent_runtime_last_seen_at", true)
+
+ const version = "437_drop_agent_runtime_last_seen_at_index"
+ options.Files = realMigrationFiles(t, []string{version}, "up")
+ if err := runMigrations(ctx, pool, options); err != nil {
+ t.Fatalf("apply runtime index retirement migration: %v", err)
+ }
+ assertIndexExists(t, pool, schema, "idx_agent_runtime_last_seen_at", false)
+ assertMigrationVersionRecorded(t, ctx, pool, schema, version, true)
+
+ options.Direction = "down"
+ options.Files = realMigrationFiles(t, []string{version}, "down")
+ options.Hooks = hooksForDirection("down")
+ if err := runMigrations(ctx, pool, options); err != nil {
+ t.Fatalf("roll back runtime index retirement migration: %v", err)
+ }
+ assertIndexValidity(t, pool, schema, "idx_agent_runtime_last_seen_at", true)
+ var indexDefinition string
+ if err := pool.QueryRow(ctx,
+ "SELECT pg_get_indexdef($1::regclass)",
+ pgx.Identifier{schema, "idx_agent_runtime_last_seen_at"}.Sanitize(),
+ ).Scan(&indexDefinition); err != nil {
+ t.Fatalf("read restored runtime index definition: %v", err)
+ }
+ if !strings.HasSuffix(indexDefinition, "USING btree (last_seen_at)") {
+ t.Fatalf("restored runtime index definition differs from migration 115: %s", indexDefinition)
+ }
+ assertMigrationVersionRecorded(t, ctx, pool, schema, version, false)
+
+ options.Direction = "up"
+ options.Files = realMigrationFiles(t, []string{version}, "up")
+ options.Hooks = hooksForDirection("up")
+ if err := runMigrations(ctx, pool, options); err != nil {
+ t.Fatalf("reapply runtime index retirement migration: %v", err)
+ }
+ assertIndexExists(t, pool, schema, "idx_agent_runtime_last_seen_at", false)
+}
+
+func createAgentRuntimeLastSeenAtIndexFixture(
+ t *testing.T,
+ ctx context.Context,
+ adminPool *pgxpool.Pool,
+) (string, *pgxpool.Pool) {
+ t.Helper()
+ suffix := fmt.Sprintf("%d_%d", time.Now().UnixNano(), rand.Uint32())
+ schema := "migrate_runtime_last_seen_" + suffix
+ schemaIdent := pgx.Identifier{schema}.Sanitize()
+ if _, err := adminPool.Exec(ctx, "CREATE SCHEMA "+schemaIdent); err != nil {
+ t.Fatalf("create schema: %v", err)
+ }
+ t.Cleanup(func() {
+ cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cleanupCancel()
+ if _, err := adminPool.Exec(cleanupCtx, "DROP SCHEMA IF EXISTS "+schemaIdent+" CASCADE"); err != nil {
+ t.Logf("drop schema %s: %v", schema, err)
+ }
+ })
+
+ pool := openTestPoolWithSearchPath(t, schema)
+ if _, err := pool.Exec(ctx, `CREATE TABLE agent_runtime (
+ id UUID PRIMARY KEY,
+ last_seen_at TIMESTAMPTZ
+ )`); err != nil {
+ t.Fatalf("create agent_runtime fixture: %v", err)
+ }
+ return schema, pool
+}
diff --git a/server/internal/metrics/business_sampler.go b/server/internal/metrics/business_sampler.go
index 77109d9ca3..5823ac9bab 100644
--- a/server/internal/metrics/business_sampler.go
+++ b/server/internal/metrics/business_sampler.go
@@ -36,11 +36,6 @@ const (
// counter-derived aggregation, not expanding this sampler over history.
windowFiveMinutes = "5m"
- // Runtime is considered online if its last_seen_at is within this
- // many seconds of `now()`. 60s matches the daemon heartbeat cadence
- // (~15s) plus headroom for redis relay lag and clock skew.
- runtimeOnlineWindowSeconds = 60
-
// A running task is considered "stuck" once started_at is older
// than this. Matches the Grafana board threshold from MUL-2328.
stuckRunningInterval = "30 minutes"
@@ -56,6 +51,21 @@ var samplerWindows = []struct {
{windowFiveMinutes, 5 * time.Minute},
}
+// samplerQueries is the canonical query registry. The refresh deadline and
+// execution loop both derive from it so adding or removing a query cannot
+// leave a stale hand-maintained timeout multiplier behind.
+var samplerQueries = []struct {
+ name string
+ run func(*BusinessSamplerCollector, context.Context, pgx.Tx, *samplerSnapshot) error
+}{
+ {"active_users", (*BusinessSamplerCollector).queryActiveUsers},
+ {"active_workspaces", (*BusinessSamplerCollector).queryActiveWorkspaces},
+ {"task_queued", (*BusinessSamplerCollector).queryTaskQueued},
+ {"task_running", (*BusinessSamplerCollector).queryTaskRunning},
+ {"task_stuck", (*BusinessSamplerCollector).queryTaskStuck},
+ {"workspace_total", (*BusinessSamplerCollector).queryWorkspaceTotal},
+}
+
// BusinessSamplerOptions configures the BusinessSamplerCollector. A nil
// receiver in the registry means the sampler is disabled, which is the
// expected state for unit tests and any deployment where the operator does
@@ -115,8 +125,6 @@ type BusinessSamplerCollector struct {
descTaskQueued *prometheus.Desc
descTaskRunning *prometheus.Desc
descTaskStuck *prometheus.Desc
- descRuntimeOnline *prometheus.Desc
- descHeartbeatAgeHist *prometheus.Desc
descWorkspaceTotal *prometheus.Desc
mu sync.Mutex
@@ -179,14 +187,6 @@ func NewBusinessSamplerCollector(opts *BusinessSamplerOptions) *BusinessSamplerC
"multica_agent_task_stuck_total",
"Current `running` agent_task_queue rows whose started_at is older than the stuck threshold. Sampled from the database.",
[]string{"source"}, nil),
- descRuntimeOnline: prometheus.NewDesc(
- "multica_runtime_online",
- "Count of agent_runtime rows with last_seen_at within the online heartbeat window. Sampled from the database.",
- []string{"runtime_mode", "provider"}, nil),
- descHeartbeatAgeHist: prometheus.NewDesc(
- "multica_runtime_heartbeat_age_seconds",
- "Distribution of (now() - agent_runtime.last_seen_at) for runtimes considered online by the sampler.",
- []string{"runtime_mode"}, nil),
descWorkspaceTotal: prometheus.NewDesc(
"multica_workspace_total",
"Lifetime workspace row count. Useful for sizing alerts and dashboards.",
@@ -217,8 +217,6 @@ func (c *BusinessSamplerCollector) Describe(ch chan<- *prometheus.Desc) {
c.descTaskQueued,
c.descTaskRunning,
c.descTaskStuck,
- c.descRuntimeOnline,
- c.descHeartbeatAgeHist,
c.descWorkspaceTotal,
} {
ch <- d
@@ -253,7 +251,10 @@ func (c *BusinessSamplerCollector) maybeRefresh() *samplerSnapshot {
// Bound the entire refresh to N×queryTimeout so an in-flight scrape
// can never block forever even if SET LOCAL is somehow ignored by a
// misconfigured Postgres.
- ctx, cancel := context.WithTimeout(context.Background(), 8*c.queryTimeout)
+ ctx, cancel := context.WithTimeout(
+ context.Background(),
+ time.Duration(len(samplerQueries))*c.queryTimeout,
+ )
defer cancel()
next := c.refreshFn(ctx, now)
@@ -291,21 +292,6 @@ func (c *BusinessSamplerCollector) emit(ch chan<- prometheus.Metric, snap *sampl
}
}
- for key, val := range snap.runtimeOnline {
- ch <- prometheus.MustNewConstMetric(
- c.descRuntimeOnline, prometheus.GaugeValue, val, key.runtimeMode, key.provider)
- }
-
- for mode, hist := range snap.heartbeatAge {
- ch <- prometheus.MustNewConstHistogram(
- c.descHeartbeatAgeHist,
- hist.count,
- hist.sum,
- hist.buckets,
- mode,
- )
- }
-
if snap.workspaceTotalKnown {
ch <- prometheus.MustNewConstMetric(
c.descWorkspaceTotal, prometheus.GaugeValue, snap.workspaceTotal)
@@ -323,10 +309,6 @@ func knownRuntimeModeLabels() []string {
return []string{"local", "cloud", "unknown"}
}
-// heartbeatAgeBuckets matches the Grafana board's runtime-health view: a few
-// seconds for healthy heartbeats, then quickly out to "definitely stale".
-var heartbeatAgeBuckets = []float64{1, 5, 15, 30, 60, 120, 300, 600}
-
// taskRunningKey is the composite gauge label key for the running counter.
// Defined here because it is shared between the snapshot and the emit path.
type taskRunningKey struct {
@@ -334,20 +316,6 @@ type taskRunningKey struct {
runtimeMode string
}
-type runtimeOnlineKey struct {
- runtimeMode string
- provider string
-}
-
-// samplerHistogram is the in-memory representation of a single
-// prometheus.ConstHistogram for one runtime_mode. We bucketise in Go
-// because Postgres does not return histogram-shaped data directly.
-type samplerHistogram struct {
- count uint64
- sum float64
- buckets map[float64]uint64
-}
-
// samplerSnapshot is the cached output of one full refresh. All maps are
// pre-allocated so the emit path can read them lock-free once the receiver
// has handed it back.
@@ -361,9 +329,6 @@ type samplerSnapshot struct {
taskRunning map[taskRunningKey]float64
taskStuck map[string]float64
- runtimeOnline map[runtimeOnlineKey]float64
- heartbeatAge map[string]samplerHistogram
-
workspaceTotal float64
workspaceTotalKnown bool
}
@@ -376,8 +341,6 @@ func newSamplerSnapshot(t time.Time) *samplerSnapshot {
taskQueued: map[string]float64{},
taskRunning: map[taskRunningKey]float64{},
taskStuck: map[string]float64{},
- runtimeOnline: map[runtimeOnlineKey]float64{},
- heartbeatAge: map[string]samplerHistogram{},
}
}
@@ -398,30 +361,11 @@ func (c *BusinessSamplerCollector) refreshFromDB(ctx context.Context, now time.T
snap := newSamplerSnapshot(now)
- c.runQuery(ctx, conn, "active_users", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryActiveUsers(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "active_workspaces", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryActiveWorkspaces(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "task_queued", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryTaskQueued(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "task_running", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryTaskRunning(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "task_stuck", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryTaskStuck(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "runtime_online", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryRuntimeOnline(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "runtime_heartbeat_age", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryRuntimeHeartbeatAge(ctx, tx, snap)
- })
- c.runQuery(ctx, conn, "workspace_total", func(ctx context.Context, tx pgx.Tx) error {
- return c.queryWorkspaceTotal(ctx, tx, snap)
- })
+ for _, query := range samplerQueries {
+ c.runQuery(ctx, conn, query.name, func(ctx context.Context, tx pgx.Tx) error {
+ return query.run(c, ctx, tx, snap)
+ })
+ }
return snap
}
diff --git a/server/internal/metrics/business_sampler_queries.go b/server/internal/metrics/business_sampler_queries.go
index 9e3f6b927e..bc14200b04 100644
--- a/server/internal/metrics/business_sampler_queries.go
+++ b/server/internal/metrics/business_sampler_queries.go
@@ -13,7 +13,7 @@ import (
// - uses an explicit `LIMIT 100` belt-and-braces (the result set is
// already bounded by GROUP BY, but the LIMIT is the spec-mandated
// last-line-of-defense against an accidental high-cardinality output)
-// - normalises raw column values (source / runtime_mode / provider)
+// - normalises raw column values (source / runtime_mode)
// through the existing BusinessMetrics whitelists so the sampler
// cannot widen the metric label space.
@@ -225,100 +225,6 @@ LIMIT 100
return rows.Err()
}
-// queryRuntimeOnline counts agent_runtime rows whose last_seen_at is within
-// the online window, grouped by runtime_mode × provider. Both labels go
-// through the BusinessMetrics whitelists so a misbehaving runtime registering
-// itself with an exotic provider name cannot inflate the series space.
-func (c *BusinessSamplerCollector) queryRuntimeOnline(
- ctx context.Context, tx pgx.Tx, snap *samplerSnapshot,
-) error {
- const stmt = `
-SELECT runtime_mode, provider, count(*) AS n
-FROM agent_runtime
-WHERE last_seen_at IS NOT NULL
- AND last_seen_at > now() - ($1::int * interval '1 second')
-GROUP BY 1, 2
-LIMIT 100
-`
- rows, err := tx.Query(ctx, stmt, runtimeOnlineWindowSeconds)
- if err != nil {
- return fmt.Errorf("runtime_online: %w", err)
- }
- defer rows.Close()
- for rows.Next() {
- var rawMode, rawProvider string
- var n int64
- if err := rows.Scan(&rawMode, &rawProvider, &n); err != nil {
- return fmt.Errorf("runtime_online scan: %w", err)
- }
- key := runtimeOnlineKey{
- runtimeMode: NormalizeRuntimeMode(rawMode),
- provider: NormalizeRuntimeProvider(rawProvider),
- }
- snap.runtimeOnline[key] += float64(n)
- }
- return rows.Err()
-}
-
-// queryRuntimeHeartbeatAge fills the heartbeat-age histogram per runtime_mode.
-// We pull at most 100 rows and bucketise in Go because Postgres does not
-// return histogram-shaped output. Rows older than 15 minutes are dropped —
-// they are clearly offline and would just smear the tail of the histogram.
-func (c *BusinessSamplerCollector) queryRuntimeHeartbeatAge(
- ctx context.Context, tx pgx.Tx, snap *samplerSnapshot,
-) error {
- const stmt = `
-SELECT runtime_mode, EXTRACT(EPOCH FROM (now() - last_seen_at))::float8 AS age
-FROM agent_runtime
-WHERE last_seen_at IS NOT NULL
- AND last_seen_at > now() - interval '15 minutes'
-ORDER BY last_seen_at DESC
-LIMIT 100
-`
- rows, err := tx.Query(ctx, stmt)
- if err != nil {
- return fmt.Errorf("runtime_heartbeat_age: %w", err)
- }
- defer rows.Close()
-
- perMode := map[string][]float64{}
- for rows.Next() {
- var rawMode string
- var age float64
- if err := rows.Scan(&rawMode, &age); err != nil {
- return fmt.Errorf("runtime_heartbeat_age scan: %w", err)
- }
- if age < 0 {
- age = 0
- }
- mode := NormalizeRuntimeMode(rawMode)
- perMode[mode] = append(perMode[mode], age)
- }
- if err := rows.Err(); err != nil {
- return err
- }
-
- for mode, ages := range perMode {
- hist := samplerHistogram{
- buckets: make(map[float64]uint64, len(heartbeatAgeBuckets)),
- }
- for _, b := range heartbeatAgeBuckets {
- hist.buckets[b] = 0
- }
- for _, age := range ages {
- hist.count++
- hist.sum += age
- for _, b := range heartbeatAgeBuckets {
- if age <= b {
- hist.buckets[b]++
- }
- }
- }
- snap.heartbeatAge[mode] = hist
- }
- return nil
-}
-
// queryWorkspaceTotal exposes a lifetime workspace count. Single integer,
// no labels — useful for sizing dashboards and capacity planning.
func (c *BusinessSamplerCollector) queryWorkspaceTotal(
diff --git a/server/internal/metrics/business_sampler_test.go b/server/internal/metrics/business_sampler_test.go
index 6d3e4b9dd2..c4c61e2eba 100644
--- a/server/internal/metrics/business_sampler_test.go
+++ b/server/internal/metrics/business_sampler_test.go
@@ -52,42 +52,13 @@ func filledSnapshot(now time.Time) *samplerSnapshot {
snap.taskStuck["issue"] = 1
- snap.runtimeOnline[runtimeOnlineKey{runtimeMode: "local", provider: "claude"}] = 4
- snap.runtimeOnline[runtimeOnlineKey{runtimeMode: "cloud", provider: "kiro"}] = 2
-
- snap.heartbeatAge["local"] = samplerHistogram{
- count: 3,
- sum: 45,
- buckets: bucketsFor([]float64{5, 15, 30}),
- }
- snap.heartbeatAge["cloud"] = samplerHistogram{
- count: 1,
- sum: 2,
- buckets: bucketsFor([]float64{2}),
- }
-
snap.workspaceTotal = 250
snap.workspaceTotalKnown = true
return snap
}
-func bucketsFor(observations []float64) map[float64]uint64 {
- buckets := make(map[float64]uint64, len(heartbeatAgeBuckets))
- for _, b := range heartbeatAgeBuckets {
- buckets[b] = 0
- }
- for _, o := range observations {
- for _, b := range heartbeatAgeBuckets {
- if o <= b {
- buckets[b]++
- }
- }
- }
- return buckets
-}
-
-// TestBusinessSamplerCollectorEmitsExpectedMetrics asserts every metric
-// family from the PR4 spec is present on /metrics with the expected
+// TestBusinessSamplerCollectorEmitsExpectedMetrics asserts every current
+// sampler metric family is present on /metrics with the expected
// values, AND that we always emit a known-source/runtime-mode zero series
// so dashboards don't show "no data" right after a restart.
func TestBusinessSamplerCollectorEmitsExpectedMetrics(t *testing.T) {
@@ -115,10 +86,6 @@ func TestBusinessSamplerCollectorEmitsExpectedMetrics(t *testing.T) {
`multica_agent_task_running{runtime_mode="cloud",source="chat"} 3`,
`multica_agent_task_running{runtime_mode="local",source="issue"} 1`,
`multica_agent_task_stuck_total{source="issue"} 1`,
- `multica_runtime_online{provider="claude",runtime_mode="local"} 4`,
- `multica_runtime_online{provider="kiro",runtime_mode="cloud"} 2`,
- `multica_runtime_heartbeat_age_seconds_count{runtime_mode="local"} 3`,
- `multica_runtime_heartbeat_age_seconds_sum{runtime_mode="local"} 45`,
`multica_workspace_total 250`,
}
for _, want := range wantSubstrings {
@@ -131,9 +98,11 @@ func TestBusinessSamplerCollectorEmitsExpectedMetrics(t *testing.T) {
`multica_active_users{window="24h"}`,
`multica_active_workspaces{window="1h"}`,
`multica_active_workspaces{window="24h"}`,
+ `multica_runtime_online`,
+ `multica_runtime_heartbeat_age_seconds`,
} {
if strings.Contains(body, removed) {
- t.Errorf("metrics body still exposes removed long DB window %q\nbody:\n%s", removed, body)
+ t.Errorf("metrics body still exposes removed series %q\nbody:\n%s", removed, body)
}
}
}
@@ -211,9 +180,9 @@ func TestBusinessSamplerCollectorBoundedCardinality(t *testing.T) {
snap.taskQueued[NormalizeTaskSource("provider-from-user-input-"+string(rune('A'+i%26)))] += 1
}
for i := 0; i < 50; i++ {
- snap.runtimeOnline[runtimeOnlineKey{
+ snap.taskRunning[taskRunningKey{
+ source: NormalizeTaskSource("source-from-user-input-" + string(rune('A'+i%26))),
runtimeMode: NormalizeRuntimeMode("rogue-mode"),
- provider: NormalizeRuntimeProvider("attacker-provider"),
}] += 1
}
return snap
@@ -230,8 +199,17 @@ func TestBusinessSamplerCollectorBoundedCardinality(t *testing.T) {
if got := testutil.CollectAndCount(c, "multica_agent_task_running"); got != expectedRunning {
t.Fatalf("agent_task_running series = %d, want %d", got, expectedRunning)
}
- if got := testutil.CollectAndCount(c, "multica_runtime_online"); got != 1 {
- t.Fatalf("runtime_online series = %d, want 1 (collapsed by normalizers)", got)
+
+ rec := httptest.NewRecorder()
+ NewHandler(registry).ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/metrics", nil))
+ body := rec.Body.String()
+ for _, want := range []string{
+ `multica_agent_task_queued{source="other"} 50`,
+ `multica_agent_task_running{runtime_mode="unknown",source="other"} 50`,
+ } {
+ if !strings.Contains(body, want) {
+ t.Errorf("normalized sampler series missing %q\nbody:\n%s", want, body)
+ }
}
}
@@ -249,7 +227,7 @@ func TestBusinessSamplerCollectorDisabledWithoutOptions(t *testing.T) {
for _, forbidden := range []string{
"multica_active_users",
"multica_agent_task_queued",
- "multica_runtime_online",
+ "multica_agent_task_running",
"multica_business_sampler_query_seconds",
} {
if strings.Contains(body, forbidden) {
@@ -315,18 +293,3 @@ func TestNewBusinessSamplerCollectorNilPool(t *testing.T) {
t.Fatalf("NewBusinessSamplerCollector with nil Pool = %p, want nil", c)
}
}
-
-// TestSamplerHistogramBucketing exercises the in-memory bucketing logic so
-// a regression in heartbeat-age accounting is caught before it ships to
-// dashboards.
-func TestSamplerHistogramBucketing(t *testing.T) {
- buckets := bucketsFor([]float64{0.5, 5, 30, 75})
- expectations := map[float64]uint64{
- 1: 1, 5: 2, 15: 2, 30: 3, 60: 3, 120: 4, 300: 4, 600: 4,
- }
- for b, want := range expectations {
- if got := buckets[b]; got != want {
- t.Errorf("bucket le=%g count = %d, want %d", b, got, want)
- }
- }
-}
diff --git a/server/migrations/437_drop_agent_runtime_last_seen_at_index.down.sql b/server/migrations/437_drop_agent_runtime_last_seen_at_index.down.sql
new file mode 100644
index 0000000000..931f8d33be
--- /dev/null
+++ b/server/migrations/437_drop_agent_runtime_last_seen_at_index.down.sql
@@ -0,0 +1,2 @@
+CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_agent_runtime_last_seen_at
+ ON agent_runtime (last_seen_at);
diff --git a/server/migrations/437_drop_agent_runtime_last_seen_at_index.up.sql b/server/migrations/437_drop_agent_runtime_last_seen_at_index.up.sql
new file mode 100644
index 0000000000..e470c24a9c
--- /dev/null
+++ b/server/migrations/437_drop_agent_runtime_last_seen_at_index.up.sql
@@ -0,0 +1 @@
+DROP INDEX CONCURRENTLY IF EXISTS idx_agent_runtime_last_seen_at;