Skip to content

Add Agent Gateway runtime governance observability - #7921

Merged
Aias00 merged 24 commits into
apache:masterfrom
BobSong-dev:integration/agent-gateway-p105
Oct 30, 2026
Merged

Aias00 merged 24 commits into
apache:masterfrom
BobSong-dev:integration/agent-gateway-p105

Conversation

@BobSong-dev

@BobSong-dev BobSong-dev commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #7860

Background

Agent Gateway needs a consistent operational view of logical MCP/LLM outcomes, actual AI upstream attempts, remote catalog state, and pre-routing authentication rejections. Retries should not be counted as additional logical requests.

This PR is a draft based on the unmerged #7860 head. It must not be merged independently before that prerequisite is reconciled and merged.

Changes

  • Add bounded runtime metrics for logical request outcomes, latency, in-flight subscriptions, AI upstream attempts, catalog acquisition, and key-auth rejections.
  • Use closed-enum labels without endpoints, credentials, subjects, tenants, tool names, session IDs, or payloads. Isolate metric failures from request delivery and deactivate old callbacks on reporter replacement.
  • Collect live remote catalog availability, updating/failed states, clients, retained generations, leases, and pending endpoint requests through the existing Prometheus lifecycle.
  • Preserve compatibility with newer master metrics and tracing changes: retain Agent runtime metrics while registering canary metrics and explicit-bucket histograms, and expose fractional observations when supported.
  • Prefer application-provided OpenTelemetry, otherwise reuse the tracing starter's named tracingTracer bean, and preserve application-provided custom MCP tracers. The plugin still creates no additional SDK, provider, or exporter.
  • Cover cancellation, duplicate completion, retry/logical accounting, authentication rejection, catalog lifecycle, bounded labels, loopback AI governance, shared OTLP export, canary metrics compatibility, and remote MCP tracing isolation.

Verification

  • Windows/JDK 17 targeted affected-module verification: ./mvnw -B -ntp -pl shenyu-plugin/shenyu-plugin-metrics,shenyu-plugin/shenyu-plugin-tracing,shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-tracing,shenyu-plugin/shenyu-plugin-security/shenyu-plugin-key-auth,shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy,shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-prompt,shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-token-limiter,shenyu-plugin/shenyu-plugin-agent-gateway,shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway -am test -DskipRemoteResources=true -Djacoco.skip=true: BUILD SUCCESS; 355 test classes; 2,819 tests, 0 failures, 0 errors, 4 skipped.
  • Earlier RISC-V/QEMU verification of the pre-reconciliation branch: 29-module scope, 2,378 tests, 0 failures, 0 errors, 1 skipped, with Checkstyle and RAT enabled.
  • GitHub CI has not yet run for the latest compatibility commit.

…ateway-p105

# Conflicts:
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/AgentGatewayPlugin.java
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpHttpHandler.java
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…to integration/agent-gateway-p105

# Conflicts:
#	.github/scripts/test-agent-gateway-migrations.py
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java
#	shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java

@Aias00 Aias00 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.

Incremental runtime-governance review: 51 targeted tests passed at head 3f417a3, covering AgentRuntimeMetrics, metric/plugin/catalog collection, key-auth rejection reporting, starter wiring, loopback HTTP governance, and OTLP behavior. The fixed enum labels and deactivation of retired runtime reporters are appropriate; no new blocker found in the reviewed observability delta.

This remains a stacked Draft depending on #7860. Its current diff still modifies released 2.7.1 -> 2.7.2 migration scripts and adds the old standalone order script. Incorporate #7860's latest f9eb7ba/a34127bc8 correction, then rebuild the branch against the merged prerequisite before requesting independent merge approval. Passing these targeted tests does not validate those inherited migration edits.

Validation used isolated worktrees, the Maven wrapper, JDK 21 with the project compiler settings, and targeted tests. Checkstyle passed; RAT and JaCoCo were skipped. This does not claim a full reactor, e2e, or live deployment test run.

…ion/agent-gateway-p105

# Conflicts:
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…ateway-p105

# Conflicts:
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPluginTest.java
@BobSong-dev
BobSong-dev marked this pull request as ready for review October 28, 2026 13:49
Aias00
Aias00 previously approved these changes Oct 29, 2026

@Aias00 Aias00 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.

Reviewed 1a05008.

The updated branch incorporates the corrected prerequisite migrations and current-master baseline. Bounded metric categories and retired-reporter deactivation remain intact. The previous branch/migration validation condition is now represented in source, and the targeted governance/metrics/starter/ordering regressions pass. No blocking issue found in the reviewed incremental change.

Coordinate merging with its request-context prerequisite.

Targeted test report: 428 cases, 0 failures, 0 errors, 0 skipped.

Validation used ./mvnw, Amazon Corretto 21 and project target Java 17. Targeted Checkstyle, separately executed Apache RAT and git diff --check pass. No full-repository or Docker E2E pass is claimed; required CI must succeed before merge.

@Aias00 Aias00 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.

Re-reviewed the updated head after merging master to resolve the overlap with the now-merged #7860. All nine conflicting paths retain the previously reviewed metrics implementation; I verified that the master versions of those paths were identical to #7860 before resolving them. Other master changes were included by the normal three-way merge.

Validation on the integrated tree: 417 targeted tests passed, with 0 failures, 0 errors and 0 skipped, across the Agent Gateway starter reactor and its dependencies; Maven Checkstyle and git diff --check also passed. This is focused verification, not a full repository/E2E run. The required GitHub checks must pass on this new head before merge.

@Aias00
Aias00 merged commit 0b5e7c1 into apache:master Oct 30, 2026
52 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
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.

2 participants