Skip to content

Add active runs metric (OTel gauge, Grafana panel, Sentry) - #8283

Open
twpsfirmament wants to merge 2 commits into
flyteorg:mainfrom
twpsfirmament:feat/runs-active-metric
Open

twpsfirmament wants to merge 2 commits into
flyteorg:mainfrom
twpsfirmament:feat/runs-active-metric

Conversation

@twpsfirmament

@twpsfirmament twpsfirmament commented Oct 31, 2026 •

Copy link
Copy Markdown

Tracking issue

Closes #8191

Why are the changes needed?

Nothing reports how many runs are currently executing.

What changes were proposed in this pull request?

  • Add a runs.active observable gauge in the runs repository: root actions in
    RUNNING, counted from the DB on each collection (5s timeout). Registered with
    RegisterCallback like taskaction.active; skipped for nil/noop providers.
  • Add an "Active runs (RUNNING)" panel to flyte-execution.json, using max()
    because every replica reports the same DB-wide count.
  • Report the RUNNING run count to Sentry every 60s via
    sentryutils.Gauge("flyte.active_runs"). The worker is registered inside the
    existing sentryutils.Init block, so it does not run when telemetry is off
    (DO_NOT_TRACK).

Note: both are sampled (per OTel export / every 60s), so a run shorter than the
interval can be missed.

How was this patch tested?

  • TestActiveRunsGauge: counts RUNNING runs; ignores QUEUED, SUCCEEDED and RUNNING
    child actions. TestRegisterActiveRunsGaugeNoop: nil/noop provider is a no-op.
    go test ./runs/repository/impl/ passes.
  • TestActiveRunsReporter_*: reports the count as flyte.active_runs; skips
    reporting when the query fails. Not exercised against a real Sentry project.
    go test ./runs/... passes.

Labels

  • added

Setup process

devbox with FLYTE_DEV=True + make devbox-monitoring, local manager with an otel
otlpgrpc exporter (port-forward the otel-collector service on 4317). See screenshot.

Screenshots

image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Signed-off-by: twpsfirmament <twpsfirmament@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 31, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@cloud-verifier-agent cloud-verifier-agent Bot 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.

cloud-verifier · ⚠️ 1 finding, not blocking

🟠 runs.active count scans all RUNNING child actions on every export · runs/repository/impl/action.go:108 · medium · medium likelihood · see inline comment

Reviewed 8df03fc0cd · turn 1 · re-run with /cloud-verifier review

Comment thread runs/repository/impl/action.go Outdated

var count int64
if err := sqlx.GetContext(ctx, db, &count,
"SELECT COUNT(*) FROM actions WHERE parent_action_name IS NULL AND phase = $1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 runs.active count scans all RUNNING child actions on every export

This count scans all RUNNING actions, including child actions, and every replica repeats it on each export. Consider a partial index on root actions by phase, or caching the count.

@twpsfirmament
twpsfirmament marked this pull request as draft October 31, 2026 16:58
Signed-off-by: twpsfirmament <twpsfirmament@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 1, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@twpsfirmament
twpsfirmament marked this pull request as ready for review November 1, 2026 14:50

@cloud-verifier-agent cloud-verifier-agent Bot 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.

cloud-verifier · ⚠️ 1 finding, not blocking

🟠 runs.active count scans all RUNNING child actions on every poll · runs/repository/impl/action.go:88 · medium · medium likelihood
The count query can only use the generic phase index, so it visits every RUNNING action, including child actions. It now runs from two pollers on every replica (metric export and a periodic reporter). Add a partial index on root actions by phase, or cache and share the count.

Reviewed 84250d1b6d · turn 2 · re-run with /cloud-verifier review

@twpsfirmament
twpsfirmament marked this pull request as draft November 1, 2026 14:51
@twpsfirmament twpsfirmament changed the title Add runs.active gauge and dashboard panel for RUNNING runs Add active runs metric (OTel gauge, Grafana panel, Sentry) Nov 1, 2026
@twpsfirmament
twpsfirmament marked this pull request as ready for review November 1, 2026 14:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2][Observability] Add metrics to monitor active runs

2 participants