DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
Example #3: Client and Server trace with annotations
Example #4: Client and Server with binary annotations (key/value)
In this example server-side implementation of the JAX-RS service is going to add key/value annotations timeline to the active span. The client-side code stays unchanged.
| Code Block | ||||
|---|---|---|---|---|
| ||||
@Produces( { MediaType.APPLICATION_JSON } )
@GET
public Collection<Book> getBooks(@Context final TracerContext tracer) throws Exception {
final Collection<Book> books = Arrays.asList(
new Book("Apache CXF Web Service tracer.timeline("Preparing Books");
// Simulating some work using a delay of 100ms
Thread.sleep(100);
return Arrays.asList(
new Book("Apache CXF Web Service Development", "Naveen Balani, Rajeev Hathi")
);
} |
The actual invocation of the request by the client (with service name tracer-client) and consequent invocation of the service on the server side (service name traceser-server) is going to generate the following sample traces:
Example #4: Client and Server with binary annotations (key/value)
In this example server-side implementation of the JAX-RS service is going to add key/value annotations to the active span. The client-side code stays unchanged.
| Code Block | ||||
|---|---|---|---|---|
| ||||
@Produces( { MediaType.APPLICATION_JSON } )
@GET
public Collection<Book> getBooks(@Context final TracerContext tracer) throws Exception {
final Collection<Book> books = Arrays.asList(
new Book("Apache CXF Web Service Development", "Naveen Balani, Rajeev Hathi")
);
tracer.annotate("# of books", Integer.toString(books.size()));
return books;
} |
The actual invocation of the request by the client (with service name tracer-client) and consequent invocation of the service on the server side (service name tracer-server) is going to generate the following sample server trace properties:
Example #5: Client and Server with parallel trace (involving thread pools)
In this example server-side implementation of the JAX-RS service is going to offload some work into thread pool and then return the response to the client, simulating parallel execution. The client-side code stays unchanged.
| Code Block | ||||
|---|---|---|---|---|
| ||||
@Produces( { MediaType.APPLICATION_JSON } ) @GET public Collection<Book> getBooks(@Context final TracerContext tracer) throws Exception { final Future<Book> book1 = executor.submit( tracer.wrap("Getting Book 1", new Traceable<Book>() { public Book call(final TracerContext context) throws Exception { // Simulating a delay of 100ms required to call external system Thread.sleep(100); return new Book("Apache CXF Web Service Development", "Naveen Balani, Rajeev Hathi"); } }) ); final Future<Book> book2 = executor.submit( tracer.wrap("Getting Book 2", new Traceable<Book>() { public Book call(final TracerContext context) throws Exception { // Simulating a delay of 100ms required to call external system Thread.sleep(200); return new Book("Developing Web Services with Apache CXF and Axis2", "Kent Ka Iok Tong"); } }) ); return tracer.annotate("# of books", Integer.toString(books.size())); return booksArrays.asList(book1.get(), book2.get()); } |
The actual invocation of the request by the client (with service name tracer-client) and consequent invocation of the service on the server side (
...
process name tracer-server) is going to generate the following sample
...
traces:
...
Example #6: Client and Server with asynchronous JAX-RS service (server-side)
...
