Skip to content

Latest commit

 

History

History
 
 

jersey-server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

brave-instrumentation-jersey-server

This module contains application event listeners for Jersey Server 2.x.

These instrumentation is an alternative to the jaxrs2 container instrumentation. Do not use both.

TracingApplicationEventListener extracts trace state from incoming requests. Then, it reports Zipkin how long each request takes, along with relevant tags like the http url and the resource.

SpanCustomizingApplicationEventListener layers over servlet, adding resource tags and route information to servlet-originated spans.

When in a servlet environment, use SpanCustomizingApplicationEventListener. When not, use TracingApplicationEventListener. Don't use both!

TracingApplicationEventListener extracts trace state from incoming requests. Then, it reports Zipkin how long each request takes, along with relevant tags like the http url.

To enable tracing, you need to register the TracingApplicationEventListener.

Configuration

Normal configuration (TracingApplicationEventListener)

The TracingApplicationEventListener requires an instance of HttpTracing to operate. With that in mind, use standard means to register the listener.

For example, you could wire up like this:

public class MyApplication extends Application {

  public Set<Object> getSingletons() {
    HttpTracing httpTracing = // configure me!
    return new LinkedHashSet<>(Arrays.asList(
      TracingApplicationEventListener.create(httpTracing),
      new MyResource()
    ));
  }
}

Servlet-based configuration (SpanCustomizingApplicationEventListener)

When using jersey-container-servlet, setup servlet tracing, an register SpanCustomizingContainerFilter.

public class MyApplication extends Application {
  public Set<Object> getSingletons() {
    HttpTracing httpTracing = // configure me!
    return new LinkedHashSet<>(Arrays.asList(
      SpanCustomizingApplicationEventListener.create(),
      new MyResource()
    ));
  }

Customizing Span data based on resources

EventParser decides which resource-specific (data beyond normal http tags) end up on the span. You can override this to change what's parsed, or use NOOP to disable controller-specific data.

Ex. If you want less tags, you can disable the JAX-RS resource ones.

SpanCustomizingApplicationEventListener.create(EventParser.NOOP);