BobSong-dev opened a new pull request, #7522:
URL: https://github.com/apache/shenyu/pull/7522

   ### Background
   
   The existing HTTP metrics cannot distinguish a successful MCP tool result 
from
   an HTTP 200 result with `isError=true`. This change adds logical `tools/call`
   statistics to the tools-only Agent Gateway entry already merged in #7424. It
   does not depend on the remote aggregation changes in #7512.
   
   ### Changes
   
   - Reuse the existing Metrics plugin, reporter and Prometheus exporter through
     a typed server-side exchange callback; add no dependency, exporter or Admin
     configuration.
   - Count authenticated, validly parsed calls once per subscription, with 
bounded
     `success`, `tool_error`, `rejected`, `server_error`, `timeout` and 
`cancelled`
     outcomes. Discovery/list and failures before parsing stay in HTTP metrics.
   - Observe through response writing: computing a result is not successful
     completion if encoding, writing, the deadline or cancellation prevents the
     response write from completing successfully.
     Keep observation state private even when client RPC ids are repeated.
   - Export terminal count and monotonic elapsed milliseconds using only the
     outcome label. Do not expose tool names, principals, request ids, 
credentials,
     arguments or response bodies as metric labels. Callback exceptions do not
     change the tool response or introduce retries.
   - Document the logical-call failure ratio and its denominator; report 
refusals
     and cancellations separately. Reuse histogram sum/count without claiming a
     new bucket or percentile policy.
   
   Token/cost accounting, per-tool dimensions, result transformations, model
   degradation, prompts/resources and remote-catalog integration are outside 
this
   change. No model usage is inferred from tool-call count or response length.
   
   ### Verification
   
   Local verification on the accepted 11-file candidate and its recorded 
baseline:
   
   - Windows and RISC-V/QEMU: each 310 targeted cases in 18 suites, zero 
failures,
     errors or skips; 14-module Checkstyle/RAT passed. All 4647 compared source 
files
     match byte hashes. These are the same cases across platforms, not 620 
unique
     tests or native RISC hardware coverage.
   - In-process Metrics → Agent handler → real Prometheus registry: 46 checks 
passed.
   - Real local Admin/H2 → WebSocket → Bootstrap → existing Prometheus HTTP 
exporter:
     53 checks passed, including whitelist update/restore, JSON/SSE, business
     failures, denial, timeout, output limits, disconnect isolation and 32 
concurrent
     requests with the same RPC id. All 46 observed logical calls have matching
     counter/histogram counts.
   - OpenCode with the configured real model: JSON direct, SSE direct and SSE
     CodeMode each made one actual `order_status` call, with model/tool/wire
     correlation and an exact success-counter increase of three.
   - Runtime class origins, inactive fixture calls before shutdown and artifact
     credential checks passed; owned ports were released. Admin/Bootstrap 
assembly
     (193 modules) and example packaging succeeded with tests explicitly 
skipped.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to