@@ -0,0 +1,1156 @@
+package com.hubspot.singularity;%0A%0Aimport com.codahale.metrics.servlets.MetricsServlet;%0Aimport io.dropwizard.Bundle;%0Aimport io.dropwizard.lifecycle.ServerLifecycleListener;%0Aimport io.dropwizard.setup.Bootstrap;%0Aimport io.dropwizard.setup.Environment;%0Aimport org.eclipse.jetty.server.Server;%0A%0Aimport javax.servlet.ServletContext;%0A%0A/**%0A * Expose Dropwizard's metrics registry to %7B@link com.hubspot.jackson.jaxrs.PropertyFilteringMessageBodyWriter%7D%0A * via the servlet context.%0A *%0A * This class is picked up by autoconfig%0A */%0Apublic class MetricsBundle implements Bundle %7B%0A%0A  @Override%0A  public void initialize(Bootstrap%3C?%3E bootstrap) %7B %7D%0A%0A  @Override%0A  public void run(final Environment environment) %7B%0A    // need to wait until the server is started to do this otherwise an IllegalStateException is thrown%0A    environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() %7B%0A      @Override%0A      public void serverStarted(Server server) %7B%0A        ServletContext context = environment.getJerseyServletContainer().getServletContext();%0A        context.setAttribute(MetricsServlet.METRICS_REGISTRY, environment.metrics());%0A      %7D%0A    %7D);%0A  %7D%0A%7D%0A

Add a bundle to set the correct MetricsRegistry on the ServletContext