Skip to content

AI-6485 Emit Dispatcher execution and operation metrics - #25317

Merged
AAraKKe merged 1 commit into
masterfrom
aarakke/AI-6485-dispatcher-execution-metrics
Sep 24, 2026
Merged

AAraKKe merged 1 commit into
masterfrom
aarakke/AI-6485-dispatcher-execution-metrics

Conversation

@AAraKKe

@AAraKKe AAraKKe commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Emits Dispatcher execution and component-operation metrics through the buffered monitoring sink. All names below are under agent_integrations.test_dispatcher.

Metrics Emission boundary
runs.count, runs.failed, runs.planning_failed, runs.cancelled, runs.timed_out, runs.no_op One terminal run observation, including healthy zeros, early failures and cancellation.
run.duration Distribution in seconds from monitoring start through terminal outcome calculation.
batches.count, jobs.count Successful batch launch. Failed dispatches contribute neither count.
batch.jobs.count One distribution sample of job count per launched batch, without batch-ID tags.
batch.duration Completed workflow's updated_at - run_started_at, in seconds. Excludes local artifact collection and parsing; unavailable or invalid timing is omitted.
artifacts.download.duration Monotonic elapsed seconds for artifact listing, download and extraction, including failed or interrupted collection. Excludes final job reconciliation and JUnit parsing.
batches.failed Zero-filled failure flag for each accepted final batch, following the workflow outcome.
jobs.failed, jobs.skipped Latest collected logical-job results, counted once, with healthy zeros.
jobs.incomplete Launched jobs without collected final results at termination, including zeros for collected jobs.
operations.count, operations.failed Settled component-operation outcomes after retries/fallbacks: dispatch, workflow fetch, job refresh, artifact collection, result gathering and report publication. Returned failures and partial results count as faults; cancelled/abandoned work does not.

Each processor emits through its own monitor. A thin helper handles operation outcomes and timing; batch/progress state supplies job accounting without a separate metrics registry. Job metrics share the same run/job dimensions while retaining the emitting component tag. Incomplete-job accounting catches and logs its own errors so final reporting and remote cancellation still run. Report completion (dispatcher.report.done) is log-only.

Listed artifacts that are expired or lack a download URL mark collection as failed. Usable artifacts are still downloaded, and workflow outcomes remain unchanged.

Uses ResolvedRun throughout instead of copying identity into a separate Dispatcher context. Workflow settings stay in DispatcherConfig; tags and pytest arguments remain invocation options. Monitoring starts with protected service ownership (team:agent-integrations), repository identity, and unresolved values for context, head/base branches and fork status. These placeholders keep pre-resolution metrics available to grouped queries and monitors. Resolved identity replaces them immediately after resolution or manifest loading, so setup failures retain their context. Caller tags cannot override service ownership.

Preserves Dispatcher outcomes and exit behavior. Emits nothing for --dry-run or --resolve-only. HTTP-attempt, retry and throttle instrumentation remains in AI-7163.

Validation: 52 filtered lifecycle-logging, operation-metric, cleanup, identity, attribute-mapping and CLI tests passed after rebasing onto the merged logging changes. ddev --no-interactive test --lint ddev passed formatting, lint and mypy (235 source files). Live Dispatcher/Datadog count comparison is still pending.

Motivation

Implements the execution inventory in AI-6485, following the buffered sink in #25274. Counting jobs at launch gives incomplete-job observations a matching denominator. Component-operation failures identify which Dispatcher work failed separately from individual GitHub request attempts.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@AAraKKe AAraKKe added the qa/skip-qa Automatically skip this PR for the next QA label Sep 23, 2026
@dd-octo-sts dd-octo-sts Bot added the ddev label Sep 23, 2026
@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch from 4c4c88b to e7d484c Compare September 23, 2026 09:01
@dd-octo-sts

dd-octo-sts Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

❌ Dispatcher tests: failed

Dispatcher beta: informational only
Existing CI remains the merge signal.

Caution

1 integration failed. 1 of 855 jobs failed.

  855/855 jobs

✅ 854 passed · ❌ 1 failed

Batches · ❌ batch-01 240/240 · ✅ batch-02 217/217 · ✅ batch-03 220/220 · ✅ batch-04 178/178

❌ cacti: 1 failed target

Dispatcher finished on 3e38543 — GitHub Run · Dispatcher Logs.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: RUN-ALL — every test task will run
Trigger:         empty diff (default branch, scheduled run, or shallow-clone fallback)
Test tasks:      0 (all selected)
Publish tasks:   2 (always emitted)
Diff:            empty (no diff information)

Learn more about CI impact filtering

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7d1efb1 | Docs | View more details | Give us feedback!

@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch from e7d484c to 2ea7447 Compare September 23, 2026 11:08
@AAraKKe

AAraKKe commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T15:42:05.029081Z febc339 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ea7447314

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +444 to +446
url = self._artifact_download_url(artifact)
if url is None:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mark skipped listed artifacts as collection failures

When GitHub lists an expired artifact or one without an archive_download_url, this branch silently skips it without adding it to failures or setting degraded. Consequently, result.failed remains false and operations.failed{operation:collect_artifacts} reports a healthy collection even though a listed artifact was not collected. Treat these skipped artifacts as failures so partial artifact results are reflected in the operation metric.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 67cc5493e4. Expired or missing-URL artifacts now mark collect_artifacts as failed while collection continues for usable artifacts. The existing test covers both cases and checks that the workflow outcome stays unchanged.

Comment on lines +266 to +267
# The launch fact survives on the batch itself, so terminal accounting can find it.
assert batch.run_id == 123

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Test terminal accounting instead of mutable batch state

This assertion only verifies that _dispatch_batch stores the workflow ID on its mutable input object; it does not verify the relevant behavior that a launched job is later emitted as incomplete when no final result arrives. Tracking launches in a separate registry would preserve that behavior but break this test, so remove this redundant assertion or replace it with an assertion on terminal jobs.incomplete output.

AGENTS.md reference: AGENTS.md:L202-L204

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed the assertion and its comment in 67cc5493e4. The existing test_shutdown_before_progress_counts_only_launched_jobs covers the terminal behavior: launched jobs are counted as incomplete even when their progress updates are discarded, and unlaunched jobs are excluded.

@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch 3 times, most recently from 71f6f4e to febc339 Compare September 23, 2026 15:30
@AAraKKe
AAraKKe marked this pull request as ready for review September 23, 2026 15:35
@AAraKKe
AAraKKe requested a review from a team as a code owner September 23, 2026 15:35

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: febc3391b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

raise
finally:
try:
run_summary(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind resolved identity before emitting early-failure metrics

When changes_for_run or DispatcherConfig.from_repo_config raises after a run has been resolved, this unconditional summary runs before monitoring.set_run_fields at line 283. The resulting runs.failed metric and terminal log therefore lack the resolved context, branches, and commit identity, making the failure impossible to attribute to its PR or commit; bind the resolved run identity immediately after loading/resolving it, before these fallible steps.

AGENTS.md reference: AGENTS.md:L108-L112

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in b7c495652a. Run identity is now bound immediately after resolution or manifest loading, before manifest writes, change detection and configuration loading.

The existing failure test covers those boundaries and checks emitted metric tags and terminal-log identity. Metric tag policy is unchanged: PR numbers and commit SHAs remain log-only.

@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch 2 times, most recently from b7c4956 to 28b20ae Compare September 23, 2026 16:16
@@ -180,6 +163,8 @@ async def on_message_received(self, message: BaseMessage):
async def on_finalize(self, exception: Exception | None):
request = self.shutdown_request
try:

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.

Can we add an except to this try/finally bloc ? if the _report_incomplete_jobs fails it will prevent the _shutdown_cleanup from running

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

IF you concern is that report_incomplete_jobs raises the except should not be added to the outer block, but around the call. The method already catches and logs (not raise) exceptions when emitting metrics. The only case where an exception can occur when calling this method is in the accounting logic, where I could not find any case where that would be an issue.

I am adding the try/except in a way that makes the method itself not raise any exception so we avoid poluting the finalize method with more try/except and nested exception handling.

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.

Thanks

Comment thread ddev/src/ddev/cli/ci/dispatch_tests.py Outdated
@@ -210,6 +216,10 @@ def dispatch_tests(

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.

Can you seed default team and a context placeholder before the try? If load_run_manifest or resolve_run aborts, the new finally still emits runs.count/runs.failed but without the tags (context , head_branch, is_default_branch or is_fork).
context can be set to unresolved and the team can be integrations-core

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There are tags being added in the resolve_run method that should probably be added beforehand, like team. For every other tag I would add unresolved until the run is resolved.

@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch 2 times, most recently from 4c617e0 to 003f883 Compare September 24, 2026 13:28
@AAraKKe
AAraKKe force-pushed the aarakke/AI-6485-dispatcher-execution-metrics branch from 003f883 to 7d1efb1 Compare September 24, 2026 13:38
@dd-octo-sts

dd-octo-sts Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file ✅
ci Validate CI configuration and code coverage settings ✅
codeowners Validate every integration has a CODEOWNERS entry ✅
config Validate default configuration files against spec.yaml ✅
dep Verify dependency pins are consistent and Agent-compatible ✅
http Validate integrations use the HTTP wrapper correctly ✅
imports Validate check imports do not use deprecated modules ✅
integration-style Validate check code style conventions ✅
jmx-metrics Validate JMX metrics definition files and config ✅
labeler Validate PR labeler config matches integration directories ✅
legacy-signature Validate no integration uses the legacy Agent check signature ✅
license-headers Validate Python files have proper license headers ✅
licenses Validate third-party license attribution list ✅
metadata Validate metadata.csv metric definitions ✅
models Validate configuration data models match spec.yaml ✅
openmetrics Validate OpenMetrics integrations disable the metric limit ✅
package Validate Python package metadata and naming ✅
qa-label Validate the pull request declares whether it needs QA for the next Agent release ✅
readmes Validate README files have required sections ✅
saved-views Validate saved view JSON file structure and fields ✅
version Validate version consistency between package and changelog ✅

View full run

@AAraKKe
AAraKKe enabled auto-merge September 24, 2026 13:51
@AAraKKe
AAraKKe added this pull request to the merge queue Sep 24, 2026
Merged via the queue into master with commit 77f8049 Sep 24, 2026
386 of 388 checks passed
@AAraKKe
AAraKKe deleted the aarakke/AI-6485-dispatcher-execution-metrics branch September 24, 2026 14:07
@dd-octo-sts dd-octo-sts Bot added this to the 7.85.0 milestone Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants