...
It is also worth to mention the way Apache CXF attaches the description to spans. With regards to the client integration, the description becomes a full URL being invoked prefixed by HTTP method, for example: GET http://localhost:8282/books. On the server side integration, the description becomes a relative JAX-RS resource path prefixed by HTTP method, f.e.: GET books, POST book/123
Configuring Client
In this section and below, all the code snippets are going to be based on Jaeger distributed tracing framework (release 0.20.6+), although everything we are going to discuss is equally applicable to any other existing alternatives. Essentially, the only dependency Apache CXF integration relies on is the Tracer instance.
There are a couple of ways the JAX-RS client could be configured, depending on the client implementation. Apache CXF provides its own WebClient which could be configured just like that (in future versions, there would be a simpler ways to do that using client specific features):
Code Block | ||||
---|---|---|---|---|
| ||||
final Tracer tracer = new Configuration("web-client",
new Configuration.SamplerConfiguration(ConstSampler.TYPE, 1), /* or any other Sampler */
new Configuration.ReporterConfiguration(new HttpSender("http://localhost:14268/api/traces")) /* or any other Sender */
).getTracer();
Response response = WebClient
.create("http://localhost:9000/catalog", Arrays.asList(new OpenTracingClientProvider(tracer)))
.accept(MediaType.APPLICATION_JSON)
.get(); |
The configuration based on using the standard JAX-RS Client is very similar:
Code Block | ||||
---|---|---|---|---|
| ||||
final Tracer tracer = new Configuration("jaxrs-client",
new Configuration.SamplerConfiguration(ConstSampler.TYPE, 1), /* or any other Sampler */
new Configuration.ReporterConfiguration(new HttpSender("http://localhost:14268/api/traces")) /* or any other Sender */
).getTracer();
final OpenTracingClientProvider provider = new OpenTracingClientProvider(tracer);
final Client client = ClientBuilder.newClient().register(provider);
final Response response = client
.target("http://localhost:9000/catalog")
.request()
.accept(MediaType.APPLICATION_JSON)
.get(); |