import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.graphite.Graphite;
import com.codahale.metrics.graphite.GraphiteReporter;
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
import com.codahale.metrics.logback.InstrumentedAppender;
import filters.MetricsFilter;
import play.*;
import play.api.mvc.EssentialFilter;
import play.api.mvc.Result;
import util.SVGUtil;

import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;

import static com.codahale.metrics.SharedMetricRegistries.getOrCreate;
import static play.mvc.Results.internalServerError;

/**
 * Created by shelajev on 20/10/15.
 */
public class Global extends GlobalSettings {

  MetricRegistry metricRegistry = getOrCreate("play-metrics");
  GraphiteReporter graphiteReporter;

  @Override
  public void onStart(Application app) {
    super.onStart(app);
    if(Play.isProd()) {
      setupMetrics(app.configuration());
      setupGraphiteReporter(app.configuration());
    }
    try {
      SVGUtil.init();
    }
    catch (Exception e) {
      Logger.info("SVGUtil threw " + e, e);
    }
  }

  @Override
  public void onStop(Application application) {
    if (graphiteReporter != null) {
      graphiteReporter.stop();
    }

    super.onStop(application);
  }

  @Override
  public Result onError(Throwable t) {
    return internalServerError(
      views.html.errorPage(t)
    );
  }

  private void setupMetrics(Configuration configuration) {
    boolean metricsJvm     = configuration.getBoolean("metrics.jvm", false);
    boolean metricsLogback = configuration.getBoolean("metrics.logback", false);
    boolean metricsConsole = configuration.getBoolean("metrics.console", false);

    if(metricsJvm) {
      metricRegistry.registerAll(new GarbageCollectorMetricSet());
      metricRegistry.registerAll(new MemoryUsageGaugeSet());
      metricRegistry.registerAll(new ThreadStatesGaugeSet());
    }

    if (metricsLogback) {
      InstrumentedAppender appender = new InstrumentedAppender(metricRegistry);

      ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger)Logger.underlying();
      appender.setContext(logger.getLoggerContext());
      appender.start();
      logger.addAppender(appender);
    }

    if (metricsConsole) {
      ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
      consoleReporter.start(1, TimeUnit.SECONDS);
    }

  }

  private void setupGraphiteReporter(Configuration configuration) {
    boolean graphiteEnabled = configuration.getBoolean("graphite.enabled", false);

    if (graphiteEnabled) {
      String   host        = configuration.getString("graphite.host", "localhost");
      int      port        = configuration.getInt("graphite.port", 80);
      String   prefix      = configuration.getString("graphite.prefix", "");
      long     period      = configuration.getLong("graphite.period", 1l);
      TimeUnit periodUnit  = TimeUnit.valueOf(configuration.getString("graphite.periodUnit", "MINUTES"));

      final Graphite graphite = new Graphite(new InetSocketAddress(host, port));
      GraphiteReporter.Builder reportBuilder = GraphiteReporter.forRegistry(metricRegistry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .filter(MetricFilter.ALL);

      if (prefix != null && !prefix.isEmpty()) {
        reportBuilder.prefixedWith(prefix);
      }

      graphiteReporter = reportBuilder.build(graphite);

      graphiteReporter.start(period, periodUnit);
    }
  }

  @Override
  public <T extends EssentialFilter> Class<T>[] filters() {
    return new Class[]{ MetricsFilter.class};
  }


}

@@ -536,36 +536,8 @@
 er;%0A
-import play.api.mvc.Result;%0A
 impo
@@ -702,60 +702,8 @@
 ate;
-%0Aimport static play.mvc.Results.internalServerError;
 %0A%0A/*
@@ -1382,133 +1382,8 @@
  %7D%0A%0A
-  @Override%0A  public Result onError(Throwable t) %7B%0A    return internalServerError(%0A      views.html.errorPage(t)%0A    );%0A  %7D%0A%0A
   pr

Make it compile