davsclaus opened a new pull request, #28867: URL: https://github.com/apache/camel/pull/28867
JIRA: [CAMEL-26490](https://issues.apache.org/jira/browse/CAMEL-26490) _Claude Code on behalf of davsclaus_ ## Problem The span decorators of camel-telemetry and camel-tracing set the `camel.uri` attribute the way `Endpoint.toString()` presents the endpoint URI, but they build three other attributes from the endpoint in a different form: - `http.url`: when the message has neither a `CamelHttpUrl` nor a `CamelHttpUri` header (for example a route that starts from a timer, a JMS queue or a file, or one that removes the inbound `CamelHttp*` headers before it calls a service), `AbstractHttpSpanDecorator.getHttpURL` took the endpoint URI from the last `http:` onwards. That is not the URL of the request: for camel-http and camel-vertx-http it includes all the Camel endpoint options, which are not sent to the server; for camel-vertx-http with an https address it starts with `http://https://`; for camel-http with an https address the attribute is not set at all. - `url.path` is taken from the raw endpoint URI, so for an endpoint URI with user info it starts with the user info and the host. - `server.address` is `EndpointServiceLocation.getServiceUrl()` as is. ## Change The same change in both modules (`org.apache.camel.telemetry.decorators` and `org.apache.camel.tracing.decorators`): - `AbstractHttpSpanDecorator.getHttpURL` keeps the precedence of the `CamelHttpUrl` and `CamelHttpUri` headers. Without them it uses the service URL of an endpoint that implements `EndpointServiceLocation`, when that is an `http://` or `https://` address: the address the producer calls, with the query parameters it sends and without the endpoint options (such as camel-http and camel-vertx-http). Otherwise it takes the endpoint URI without a component scheme in front of the HTTP address (`netty-http:http://...`, `vertx-http://https://...`) and without the endpoint options. The value, also when it comes from a header, is presented with `URISupport.sanitizeUri`, as `camel.uri` is. - `AbstractSpanDecorator` builds `url.path` without the user info in front of the host, and sets `server.address` as `URISupport.sanitizeUri` presents it. - A note in the 4.24 upgrade guide. ## Tests New tests in `AbstractHttpSpanDecoratorTest` and `AbstractSpanDecoratorTest` of both modules: - `http://localhost:8080/test?connectTimeout=5000&throwExceptionOnFailure=false` gives `http://localhost:8080/test` - `vertx-http://https://localhost:8443/test?connectTimeout=5000` gives `https://localhost:8443/test` - an endpoint with the service URL `https://localhost:8443/test?q=1` gives that URL, and an https endpoint sets `http.url` on the span - an endpoint whose service URL is not an HTTP address (such as `http:localhost:8080` of netty-http) still uses the endpoint URI, so `netty-http:http://...` gives `http://...` - a `CamelHttpUrl` header with user info is presented as `camel.uri` is - `url.path` of `ftp://scott:tiger@localhost:2121/inbox?binary=true` is `localhost:2121/inbox`, and `server.address` is presented as `camel.uri` is The existing header tests stubbed `getHeader(name, String.class)` while the code calls `getHeader(name)`, so they passed through the endpoint fallback. They now stub the call the code makes, with an endpoint URI that differs from the header. The seven new behaviour tests in each module fail without the change in the decorators. `mvn verify` passes in camel-telemetry (191 tests), camel-tracing (92 tests), camel-opentelemetry2 (41 tests) and camel-opentelemetry (23 tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
