com.qmetric.spark.metrics.RouteMeterWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark-metrics Show documentation
Show all versions of spark-metrics Show documentation
A library of Route decorators to add metrics to spark based applications and Routes to access the metrics
package com.qmetric.spark.metrics;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import spark.Request;
import spark.Response;
import spark.Route;
import static com.codahale.metrics.MetricRegistry.name;
public class RouteMeterWrapper extends Route
{
private static final String REGEX = "/";
private final Route route;
private final Meter meter;
public RouteMeterWrapper(final String path, final MetricRegistry metricRegistry, final Route route)
{
super(path);
this.route = route;
meter = metricRegistry.meter(name("meter", path.split(REGEX)));
}
@Override public Object handle(final Request request, final Response response)
{
meter.mark();
return route.handle(request, response);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy