package com.yammer.dropwizard.servlets;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

import static com.yammer.dropwizard.util.Servlets.getFullUrl;

/**
 * A servlet filter which adds the request method and URI to the thread name processing the request
 * for the duration of the request.
 */
public class ThreadNameFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException { /* unused */ }

    @Override
    public void destroy() { /* unused */ }

    @Override
    public void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        final HttpServletRequest req = (HttpServletRequest) request;
        final Thread current = Thread.currentThread();
        final String oldName = current.getName();
        try {
            current.setName(formatName(req, oldName));
            chain.doFilter(request, response);
        } finally {
            current.setName(oldName);
        }
    }

    private static String formatName(HttpServletRequest req, String oldName) {
        return new StringBuilder(150).append(oldName)
                                     .append(" - ")
                                     .append(req.getMethod())
                                     .append(' ')
                                     .append(getFullUrl(req))
                                     .toString();
    }
}

@@ -1212,320 +1212,64 @@
 urn 
-new StringBuilder(150).append(oldName)%0A                                     .append(%22 - %22)%0A                                     .append(req.getMethod())%0A                                     .append(' ')%0A                                     .append(getFullUrl(req))%0A                                     .toString(
+oldName + %22 - %22 + req.getMethod() + ' ' + getFullUrl(req
 );%0A 

Simplify ThreadNameFilter a bit.