package com.hubspot.baragon.agent.healthcheck;

import com.codahale.metrics.health.HealthCheck;
import com.google.inject.Inject;
import com.hubspot.baragon.agent.lbs.LocalLbAdapter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LoadBalancerHealthcheck extends HealthCheck {
  private static final Log LOG = LogFactory.getLog(LoadBalancerHealthcheck.class);

  private final LocalLbAdapter adapter;
  
  @Inject
  public LoadBalancerHealthcheck(LocalLbAdapter adapter) {
    this.adapter = adapter;
  }

  @Override
  protected Result check() throws Exception {
    try {
      adapter.checkConfigs();
      return Result.healthy();
    } catch (Exception e) {
      LOG.warn("Healthcheck failed: " + e.getMessage());
      return Result.unhealthy(e.getMessage());
    }
  }

}

@@ -45,56 +45,8 @@
 k;%0A%0A
-import com.codahale.metrics.health.HealthCheck;%0A
 impo
@@ -127,16 +127,75 @@
 dapter;%0A
+import com.hubspot.dropwizard.guice.InjectableHealthCheck;%0A
 import o
@@ -317,16 +317,26 @@
 extends 
+Injectable
 HealthCh
@@ -341,16 +341,76 @@
 Check %7B%0A
+  public static final String NAME = %22loadBalancerConfigs%22;%0A%0A
   privat
@@ -879,33 +879,81 @@
 hy(e
-.getMessage());
+);%0A    %7D%0A  %7D%0A%0A  @Override%0A  public String getName() %7B
 %0A    
-%7D
+return NAME;
 %0A  %7D%0A
-%0A
 %7D%0A

use InjectableHealthCheck