wy471x opened a new pull request, #7784: URL: https://github.com/apache/shenyu/pull/7784
### Summary Covers the tracing of the gateway with two layers of tests and closes the documentation gap of the sampler: a docker compose deployment verifies the whole path from the client through the gateway to the upstream service, an in-process test does the same without docker, and the configuration documents how a ratio sampler decides. This is the last task of #7566. Make sure that: - [X] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide). - [X] You submit test cases (unit or integration tests) that back your changes. - [X] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`. Run here for the affected modules: the integrated test module against a docker compose stack (`mvn -B -ntp test -Pit -pl :shenyu-integrated-test-tracing -am -f shenyu-integrated-test/pom.xml`, 8 tests) and the tracing plugin (`mvn -pl shenyu-plugin/shenyu-plugin-tracing test`, 3 continuity tests), with checkstyle and RAT. The full repository build was not run locally, CI covers it. ### Changes: 1. `shenyu-integrated-test/shenyu-integrated-test-tracing` (new module) — a compose deployment with an admin, a gateway, an http upstream and an OpenTelemetry collector, modelled on the smallest existing case (`shenyu-integrated-test-rewrite`). The collector runs the real image with the debug exporter, and the test reads the spans the gateway exports to it, so the assertions are made on what a backend would receive. 2. `TracingGatewayIntegrationTest` (`shenyu-integrated-test-tracing/.../TracingGatewayIntegrationTest.java:192`) — the client, the gateway and the upstream share one trace: the request log carries the trace id of the span, and the upstream receives a traceparent whose parent is the gateway span, together with the trace state and the baggage of the client. 3. `TracingGatewayIntegrationTest` (`:241,276,296,318`) — the samplers are covered as configured: `parent_based` continues an unsampled client without tracing it, `always_on` traces it, `always_off` does not trace a sampled client, and the ratio sampler only decides a request which carries no parent context, which is how `parentBased(traceIdRatioBased)` behaves. 4. `TracingGatewayIntegrationTest` (`:257`) — a request is forwarded and the upstream answers while the collector is unreachable, so the export path cannot affect forwarding. 5. `Deployment` (`.../Deployment.java:168`) — the compose stack and the gateway restarts are driven from the test. The output of an external command is drained by a thread of its own while the wait has a timeout, so a command which hangs is killed with its output in the failure instead of hanging the test, and a command which writes more than the pipe buffer cannot deadlock with the reader. 6. `shenyu-integrated-test/pom.xml`, `.github/scripts/resolve-test-case-matrix.sh` and `.github/workflows/integrated-test.yml` — the module joins the integration test matrix (also when a tracing module changes), and the collector image is pulled with a retry in CI like the other images. 7. `TraceContinuityTest` (new, `shenyu-plugin-tracing/.../TraceContinuityTest.java`) — the same continuity without docker: the real tracing plugin and the real http client plugin against a local upstream, asserting that the upstream receives exactly one traceparent whose parent is the gateway span, that a request without a client context starts the trace, and that the trace state and the baggage are forwarded. 8. `ShenyuConfig.TracingConfig` and `shenyu-bootstrap/src/main/resources/application.yml` — the documentation of the sampler states that a ratio only decides the requests which carry no parent context, so an operator does not expect a ratio to lower the sampling of traffic which is already traced. ### Test Cases: - `TracingGatewayIntegrationTest` (8 tests) — one trace across the client, the gateway and the upstream, including the trace id of the request log and the forwarded trace state and baggage; the parent based sampler not tracing an unsampled client; the always on sampler tracing it; the always off sampler not tracing a sampled client; the ratio sampler on a request without a parent context; and the request being forwarded while the collector is unreachable. - `TraceContinuityTest` (3 tests) — the upstream continuing the trace of the client, the gateway starting the trace without a client context, and the trace state and the baggage reaching the upstream. - The existing unit and starter test suites of the tracing modules stay untouched and green. ### Verification - `mvn -B -ntp test -Pit -pl :shenyu-integrated-test-tracing -am -f shenyu-integrated-test/pom.xml` → 8 tests, 0 failures (about 72s) against a freshly started compose stack, and green on a second run. - `mvn -pl shenyu-plugin/shenyu-plugin-tracing test` → 3 continuity tests, 0 failures. - checkstyle 0 violations, and `apache-rat:check` Unapproved 0 for the new module. - A reverse check was made while developing: with `shenyu.tracing.enabled=false` the continuity assertions fail, so the tests are not vacuous. ### Not covered by this change - The documentation on the website (configuration reference, supported propagators and protocols, backend examples and performance considerations), which lives in the `apache/shenyu-website` repository. - The B3 propagator and a configurable propagator set, the OTLP over gRPC transport and the batch processor knobs, which #7612 left as follow-ups. - The outbound propagation of protocols other than http, which #7616 left as an extension point. Fixes #7617 Part of #7566 -- 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]
