Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By default, HTraceProvider will try to pass the currently active span through HTTP headers on each service invocation. If there is no active spanspans, the new span will be created and passed through HTTP headers on per-invocation basis. Essentially, just registering the HTraceProvider on the client and HTraceClientProvider on the server is enough to have tracing context to be properly passed everywhere. The only configuration part which is necessary are span receiver(s) and sampler(s).

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 relation JAX-RS resource path prefixed by HTTP method, f.e.: GET books, POST book/123

Configuring Client
Anchor
configure.client
configure.client

There are a couple of way 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
java
java
final Map<String, String> properties = new HashMap<String, String>();
properties.put(Tracer.SPAN_RECEIVER_CLASSES_KEY, ...);
properties.put(Tracer.SAMPLER_CLASSES_KEY, ...);

/**
 * For example:
 *
 * properties.put(Tracer.SPAN_RECEIVER_CLASSES_KEY, StandardOutSpanReceiver.class.getName());
 * properties.put(Tracer.SAMPLER_CLASSES_KEY, AlwaysSampler.class.getName());
 */
        
final Tracer tracer = new Tracer.Builder()
    .name("webclientweb-client")
    .conf(HTraceConfiguration.fromMap(properties))
    .build();
                
final HTraceClientProvider provider = new HTraceClientProvider(tracer);
final Response response = WebClient
    .create("http://localhost:9000/catalog", Arrays.asList(provider))
    .accept(MediaType.APPLICATION_JSON)
    .get();

...

Server configuration is a bit simpler than the client one thanks to the feature class available, HTraceFeature. Depending on the way the Apache CXF is used to configure JAX-RS services, it could be part of JAX-RS application configuration, for example:

...