Versions Compared

Key

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

...

There are a couple of ways the JAX-RS client could be configured, depending on the tracing bridge you want to use (see please Configuring with Micrometer Observation). The 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 final ObservationRegistry observationRegistry = ObservationRegistry.create();

final Tracer tracer = <create tracer using tracing bridge>;
final Propagator propagator = <create propagator using tracing bridge;
  
observationRegistry.observationConfig().observationHandler(
    new FirstMatchingCompositeObservationHandler(
        new PropagatingSenderTracingObservationHandler<>(tracer, propagator),
        new PropagatingReceiverTracingObservationHandler<>(tracer, propagator)
    )
);
                   
Response response = WebClient
    .create("http://localhost:9000/catalog", Arrays.asList(new ObservationClientProvider(observationRegistry))
    .accept(MediaType.APPLICATION_JSON)
    .get();


Configuring Server

Server configuration is a very similar to the client one and uses ObservationFeature, but still requires the tracing bridge configuration (see please Configuring with Micrometer Observation). 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:


Code Block
java
java
@ApplicationPath("/")
public class CatalogApplication extends Application {
    @Override
    public Set<Object> getSingletons() {
        final ObservationRegistry observationRegistry = ObservationRegistry.create();

        final Tracer tracer = <create tracer using tracing bridge>;
        final Propagator propagator = <create propagator using tracing bridge;
  
        observationRegistry.observationConfig().observationHandler(
            new FirstMatchingCompositeObservationHandler( 
                new PropagatingSenderTracingObservationHandler<>(tracer, propagator),
                new PropagatingReceiverTracingObservationHandler<>(tracer, propagator)
            )
        );
 
        return new HashSet<>(
                Arrays.asList(
                    new ObservationFeature(observationRegistry)
                )
            );
    }
}

Or it could be configured using JAXRSServerFactoryBean as well, for example:


Code Block
java
java
final ObservationRegistry observationRegistry = ObservationRegistry.create();

final Tracer tracer = <create tracer using tracing bridge>;
final Propagator propagator = <create propagator using tracing bridge;
  
observationRegistry.observationConfig().observationHandler(
    new FirstMatchingCompositeObservationHandler(
        new PropagatingSenderTracingObservationHandler<>(tracer, propagator),
        new PropagatingReceiverTracingObservationHandler<>(tracer, propagator)
    )
);

final JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint(/* application instance */, JAXRSServerFactoryBean.class);
factory.setProvider(new ObservationFeature(observationRegistry));
...
return factory.create();

Once the span processor(s) / reporter(s) and sampler are properly configured, all generated observations (spans) are going to be collected and available for analysis and/or visualization.TBD

Distributed Tracing In Action: Usage Scenarios

...