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
Anchor
configure.client
configure.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 Client client = ClientBuilder.newClient().register(provider);

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

Configuring Server
Anchor
configure.server
configure.server

Server configuration is a bit simpler than 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:

...

In the following subsections we are going to walk through many different scenarios to illustrate the distributed tracing in action, starting from the simplest ones and finishing with asynchronous JAX-RS services. All examples assume that configuration  has been done (see please Configuring please Configuring Client and Configuring Server sections above).