All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qmetric.spark.metrics.RouteMeterWrapper Maven / Gradle / Ivy

Go to download

A library of Route decorators to add metrics to spark based applications and Routes to access the metrics

There is a newer version: 1.19
Show newest version
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