VMware has ended active development of this project, this repository will no longer be updated.
The Wavefront by VMware JAX-RS SDK for Java provides out-of-the-box trace data from JAX-RS based clients in your Java application. You can analyze the tracing data in Wavefront to better understand how your application is performing in production. If you have multiple services running, you can instrument your server-side service with our Wavefront Jersey SDK to form a complete trace.
If you are using Maven, add the following maven dependency to your pom.xml
:
<dependency>
<groupId>com.wavefront</groupId>
<artifactId>wavefront-jaxrs-sdk-java</artifactId>
<version>$releaseVersion</version>
</dependency>
Replace $releaseVersion
with the latest version available on maven.
Follow the steps below to set up a WavefrontJaxrsClientFilter
. For each client that uses a JAX-RS-compliant framework:
- Create an
ApplicationTags
instance, which specifies metadata about your application. - Create a
WavefrontSender
for sending data to Wavefront. - Create a
WavefrontSpanReporter
for reporting trace data to Wavefront. - Create a
WavefrontTracer
as the tracer for generating traces and spans. - Create a
WavefrontJaxrsClientFilter
. - Register the
WavefrontJaxrsClientFilter
.
For the details of each step, see the sections below.
Application tags determine the metadata (point tags and span tags) that are included with every metric/histogram/span reported to Wavefront. These tags enable you to filter and query the reported data in Wavefront.
You encapsulate application tags in an ApplicationTags
object. See Instantiating ApplicationTags for details.
A WavefrontSender
object implements the low-level interface for sending data to Wavefront. You can choose to send data to Wavefront using either the Wavefront proxy or direct ingestion.
-
If you have already set up a
WavefrontSender
for another SDK that will run in the same JVM, use that one. (For details about sharing aWavefrontSender
instance, see Share a WavefrontSender.) -
Otherwise, follow the steps in Set Up a WavefrontSender.
A WavefrontSpanReporter
reports trace data to Wavefront.
To build a WavefrontSpanReporter
, you specify:
- The
WavefrontSender
you created above. - The source of the reported trace data, typically the name of the host that the code is running on.
sourceName = "mySource"; // Example - Replace value!
Reporter wfSpanReporter = new WavefrontSpanReporter.Builder().
withSource(sourceName).build(wavefrontSender);
A WavefrontTracer
creates trace data from your JAX-RS client, and sends the data to Wavefront through a WavefrontSpanReporter
.
To build a WavefrontTracer
, you specify the WavefrontSpanReporter
and the ApplicationTags
you created above.
WavefrontTracer wfTracer = new WavefrontTracer.Builder(wfSpanReporter,
applicationTags).build();
To build the WavefrontJaxrsClientFilter
, you specify:
- The
WavefrontSender
,ApplicationTags
andWavefrontTracer
you created above. - The same source that you specified when creating the
WavefrontSpanReporter
.
sourceName = "mySource"; // Example - Replace value!
WavefrontJaxrsClientFilter filter = new WavefrontJaxrsClientFilter(wfSender,
applicationTags, sourceName, wfTracer);
For any JAX-RS-compliant ClientBuilder
, register your filter as follows:
clientBuilder.register(filter);