Esempio n. 1
0
  private static void initializeMetrics(
      final MetricFactory metricFactory, final ConnectionPool<MySQLConnection> pool) {
    if (metricFactory != null) {
      metricFactory.registerGauge(
          "MysqlAsyncConnectionPool",
          "available",
          new Gauge<Integer>() {
            @Override
            public Integer getValue() {
              return pool.availables().size();
            }
          });

      metricFactory.registerGauge(
          "MysqlAsyncConnectionPool",
          "waiting",
          new Gauge<Integer>() {
            @Override
            public Integer getValue() {
              return pool.queued().size();
            }
          });

      metricFactory.registerGauge(
          "MysqlAsyncConnectionPool",
          "inUse",
          new Gauge<Integer>() {
            @Override
            public Integer getValue() {
              return pool.inUse().size();
            }
          });
    }
  }