Created
February 28, 2012 21:13
-
-
Save sheki/1935181 to your computer and use it in GitHub Desktop.
Isshttps://github.com/codahale/metrics/issues/169#issuecomment-4225453 https://github.com/codahale/metrics/issues/169#issuecomment-4225453 https://github.com/codahale/metrics/issues/169#issuecomment-4225453
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.yammer.metrics.annotation.Timed; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.Response; | |
@Path("/healthcheck") | |
public interface HealthCheck | |
{ | |
@GET | |
@Path("/console") | |
@Produces({"text/html"}) | |
@Timed(name = "healthAsHTML") | |
Response healthAsHTML(); | |
@GET | |
@Path("/json") | |
@Produces({"application/json"}) | |
Response healthAsJSON(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.flipkart.digital.core.cache.CacheInterceptor; | |
import com.flipkart.digital.inventory.api.resources.health.CompleteHealth; | |
import com.yammer.metrics.annotation.Timed; | |
import flipkart.platform.soa.ComponentHealth; | |
import flipkart.platform.soa.ComponentUtils; | |
import flipkart.platform.soa.DeepHealthReporter; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Scope; | |
import org.springframework.stereotype.Component; | |
import javax.ws.rs.core.Response; | |
import java.lang.String; | |
/** | |
* | |
*/ | |
@Component | |
@Scope("request") | |
public class HealthCheckImpl implements HealthCheck | |
{ | |
@Autowired | |
private CacheInterceptor cacheable; | |
public Response healthAsHTML() | |
{ | |
final Response.ResponseBuilder responseBuilder = Response.ok(); | |
String output = ComponentUtils.healthAsHTML(findOutHealth()); | |
responseBuilder.entity(output); | |
return responseBuilder.build(); | |
} | |
@Timed | |
public Response healthAsJSON() | |
{ | |
final Response.ResponseBuilder responseBuilder = Response.ok(); | |
String output = ComponentUtils.healthAsJSON(findOutHealth()); | |
responseBuilder.entity(output); | |
return responseBuilder.build(); | |
} | |
private ComponentHealth findOutHealth() | |
{ | |
final CompleteHealth health = new CompleteHealth(cacheable); | |
final DeepHealthReporter deepHealthReporter = new DeepHealthReporter(health); | |
return deepHealthReporter.getComponentHealth(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment