Versions Compared

Key

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

...

By default, HTraceProvider will try pass the currently active span through HTTP headers on each service invocation. If there is no active span, 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.

Configuring Client

There are a couple of way 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>();
final HTraceConfiguration conf = HTraceConfiguration.fromMap(properties);
Trace.addReceiver(new StandardOutSpanReceiver(conf));
        
final HTraceClientProvider provider = new HTraceClientProvider(new AlwaysSampler(conf));
final Response response = WebClient
    .create("http://localhost:9000/catalog", Arrays.asList(provider))
    .accept(MediaType.APPLICATION_JSON)
    .get();

The configuration based on using the standard JAX-RS Client is very similar:

Code Block
java
java
final Map<String, String> properties = new HashMap<String, String>();
final HTraceConfiguration conf = HTraceConfiguration.fromMap(properties);
Trace.addReceiver(new StandardOutSpanReceiver(conf));
                
final HTraceClientProvider provider = new HTraceClientProvider(new AlwaysSampler(conf));
final Client client = ClientBuilder.newClient().register(provider);

client
    .target("http://localhost:8282/rest/api/people")
    .request()
    .accept(MediaType.APPLICATION_JSON)
    .get();

Configuring Server