package com.bendb.dropwizard.redis;

import com.bendb.dropwizard.redis.jersey.JedisPoolBinder;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import redis.clients.jedis.JedisPool;

public abstract class JedisBundle<C extends Configuration>
        implements ConfiguredBundle<C>, JedisConfiguration<C> {
    private JedisPool pool;

    public JedisPool getPool() {
        return pool;
    }

    @Override
    public void initialize(Bootstrap<?> bootstrap) {
    }

    @Override
    public void run(C configuration, Environment environment) throws Exception {
        pool = getJedisFactory(configuration).build(environment);

        environment.healthChecks().register("redis", new JedisHealthCheck(pool));
        environment.jersey().register(new JedisPoolBinder(pool));
    }
}

@@ -88,16 +88,51 @@
 Binder;%0A
+import com.codahale.metrics.Gauge;%0A
 import i
@@ -764,16 +764,318 @@
 ment);%0A%0A
+        environment.metrics().register(%22redis.connection.idle%22, (Gauge) () -%3E pool.getNumIdle());%0A        environment.metrics().register(%22redis.connection.active%22, (Gauge) () -%3E pool.getNumActive());%0A        environment.metrics().register(%22redis.connection.wait%22, (Gauge) () -%3E pool.getNumWaiters());%0A%0A
         

Add metrics to monitor Redis connections