Count active requests with Spring Boot

By making on Sep 05, 2014

Count active requests with Spring Boot

package hoge;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.*;

public class Application {
    String hoge() throws Exception {
        return "hoge";

    public static void main(String[] args) {, args);

    static class Config {
        CounterService counterService;

        Filter counterFilter() {
            return new Filter() {
                public void init(FilterConfig filterConfig) throws ServletException {

                public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
                    try {
                        filterChain.doFilter(servletRequest, servletResponse);
                    } finally {

                public void destroy() {



Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.