Uses New Relic's Java API to capture timing data and exceptions from Jersey resources.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper
src
.gitignore
LICENSE
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

New Relic's built-in servlet request transaction naming doesn't do a very good job of handling JAX-RS requests, so this library provides some Jersey 1 helpers to get better New Relic transaction names. It also allows you to track both mapped and un-mapped exceptions with New Relic.

Installation

You need to register both a javax.servlet.Filter (NewRelicUnmappedThrowableFilter) and a Jersey ResourceFilterFactory (NewRelicResourceFilterFactory).

Here's how to register the servlet filter using Guice Servlet:

// in your ServletModule
bind(NewRelicUnmappedThrowableFilter.class);
filter("/*").through(NewRelicUnmappedThrowableFilter.class);

And the Jersey filter factory:

// in your ServletModule
Map<String, String> initParams = new HashMap<>();
initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
    NewRelicResourceFilterFactory.class.getCanonicalName());

bind(GuiceContainer.class);
serve("/*").with(GuiceContainer.class, initParams);

Finally, you'll also want the main module for this library:

// in some module
install(new JerseyNewRelicModule());

If you want to control the New Relic "category" used in transaction names, set the NewRelicResourceFilterFactory.TRANSACTION_CATEGORY_PROP property when you're setting your init params:

Map<String, String> initParams = new HashMap<>();
initParams.put(NewRelicResourceFilterFactory.TRANSACTION_CATEGORY_PROP, "someCategory");
initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
    NewRelicResourceFilterFactory.class.getCanonicalName());

If you do not specify the category, New Relic's default will be used.