BobSong-dev opened a new pull request, #7622: URL: https://github.com/apache/shenyu/pull/7622
## Background Agent Gateway already observes logical MCP call outcomes for Metrics, but applications cannot export corresponding call spans through their OpenTelemetry SDK. A tool result alone does not mark the end of a call: response writing, deadlines and client cancellation also need to close the observation. ## Changes - Add an optional request-local tracing bridge to the existing logical `tools/call` lifecycle, independent of Metrics. End each trace once, including cancellation/deadline races during span creation, and isolate callback failures from business execution; - Add a default-off OpenTelemetry adapter in the existing Agent Gateway starter. The application supplies an `OpenTelemetry` bean and owns the SDK, exporter, sampling and shutdown. The core plugin has no OpenTelemetry dependency; the starter API dependency is optional, and SDK/exporter dependencies are test-scoped; - Use one fixed INTERNAL span name and the existing six bounded outcomes. Do not add tool names, identities, arguments, results or exception events. Only an explicitly supplied Reactor parent SpanContext is reused, without baggage, thread-local scopes, global hooks or header extraction/injection; - Add lifecycle, assembly, real SDK, OTLP HTTP and same-RPC-id concurrency regressions, and document application configuration. Existing outcome classification is retained; no retries, Token accounting or additional Metrics exporter are introduced. This instruments logical MCP tool calls, not general gateway HTTP ingress. #7619 addresses gateway-wide SERVER spans separately; this PR neither depends on it nor claims automatic context integration with it. Applications still own trusted parent contexts, Resource attributes and other instrumentation policies. ## Verification - Windows/JDK17 and RISC-V/QEMU/JDK17 selected 14-module `clean verify`: 595 tests / 34 suites on each platform, zero failures/errors/skips; Checkstyle and RAT passed in all 14 modules. Both ran the same frozen source based on merged master `a7d80b788`; - Real loopback Admin/H2 → WebSocket → ShenYu Bootstrap → application SDK → OTLP Collector: 21 checks passed. The SDK and Collector matched all 46 unique spans individually, including six outcomes, 32 concurrent same-ID calls, default-off/no-call cases, deadlines and HTTP disconnects. The client and Provider were controlled fixtures, not a real Agent/model or remote MCP server; - Same-source runtime packaging passed in 165 modules with tests skipped. All 4,492 frozen files matched; source/scope checks and `git diff --check` passed. Existing logging warnings and resolved setup failures remain in the local evidence. -- 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]
