Skip to content

Java Servlet

paulcleary edited this page Nov 10, 2015 · 2 revisions

Why would I use it?

  • You are using Java Servlets in your application
  • Your application is used by another application that is also instrumented with Money

The Java Servlet module simply provides a Servlet Filter that you can use in any application that uses servlets.

The filter will look for the money trace HTTP Request header, and automatically set the trace context based on the span provided in the trace header. When you start new spans within your application, they will be child spans of the span that comes from the Http Header. This is critical when there are many different systems involved in a single request trace.

Adding the dependency

Add a dependency as follows for maven:

    <dependency>
        <groupId>com.comcast.money</groupId>
        <artifactId>money-java-servlet_2.10</artifactId>
        <version>${money.version}</version>
    </dependency>

And here is a dependency for SBT:

    libraryDependencies += "com.comcast.money" %% "money-java-servlet" % "${money.version}"

Apply the servlet filter in your web.xml

In your web.xml for your project, you can configure the filter so that it captures incoming HTTP requests.

    <filter>
        <filter-name>moneyFilter</filter-name>
        <filter-class>com.comcast.money.java.servlet.TraceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>moneyFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
Clone this wiki locally