Coder Social home page Coder Social logo

dropwizard / dropwizard-health Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 6.0 279 KB

Provides a health check implementation that performs ongoing monitoring of an application's dependencies and includes an endpoint that can be called by a load balancer to determine if the application is healthy and thus able to receive traffic.

License: Apache License 2.0

Java 100.00%
dropwizard health-check health-checks healthcheck java

dropwizard-health's Introduction

Dropwizard

Build Quality Gate Status Maven Central Javadocs Documentation Status Maintainability Reproducible Builds Contribute with Gitpod

Dropwizard is a sneaky way of making fast Java web applications.

It's a little bit of opinionated glue code which bangs together a set of libraries which have historically not sucked:

Read more at dropwizard.io.

Want to contribute to Dropwizard?

Before working on the code, if you plan to contribute changes, please read the following CONTRIBUTING document.

Need help or found an issue?

When reporting an issue through the issue tracker on GitHub or sending an email to the Dropwizard User Google Group mailing list, please use the following guidelines:

  • Check existing issues to see if it has been addressed already
  • The version of Dropwizard you are using
  • A short description of the issue you are experiencing and the expected outcome
  • Description of how someone else can reproduce the problem
  • Paste error output or logs in your issue or in a Gist. If pasting them in the GitHub issue, wrap it in three backticks: ``` so that it renders nicely
  • Write a unit test to show the issue!

Sponsors

Dropwizard is generously supported by some companies with licenses and free accounts for their products.

JetBrains

JetBrains

JetBrains supports our open source project by sponsoring some All Products Packs within their Free Open Source License program.

dropwizard-health's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar joschi avatar natalie-zamani avatar pstackle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropwizard-health's Issues

Allow to add customizable health check statuses

Up to now, we have only two possible health check statuses that are currently supported which are healthy and unhealthy. The idea behind this improvement would be to add more (customizable) heath check statuses, like for example:

  • unknown when the application is not yet ready and can't provide its status.
  • warn (like in the RFC HealthCheck) when for example a non critical dependency is unhealthy.
  • maintenance when the application is down for maintenance
    ...

Within the context of this improvement, it could also be interesting to be able to configure for each health check status which http status code we would like to use as response of HealthCheckServlet#doGet.

Create generally useful disk health checks

There are two health checks I have in mind for this:

Register HealthCheckServlet to admin port

Hi Team, I recently noticed that HealthCheckServlet is added to application.
Assumption is anything related to state of application ( & not application itself) should be honoured at admin endpoints & not at application level.
This can be critical in the cases where application port is already heavily invoked & having health check there would put additional burden on application.
My ask is, can we register health check at admin port or at least provide way to configure it depending on user's input ?
Let me know if this sounds good & I can raise a PR.

Better support for Cloud-native liveness and readiness checks

Specifically zooming in on how Kubernetes liveness and readiness checks work, it will make sense to rethink how we mark an application healthy.

My current idea is that all critical dependencies must be checked and report healthy at least once at app startup time for the application to be marked healthy initially.

That way, we could mark an app live when it starts, and then we could mark an app ready only once it's dependencies are ready.

Minor threading bug in HealthCheckScheduler

I was doing a review of this library and noticed what I think is a minor threading bug in HealthCheckScheduler.

Specifically, the 'futures' member is declared to be a regular HashMap:

    private final Map<String, ScheduledFuture> futures = new HashMap<>();

But, the futures collection is modified by both the main thread:

HealthCheckRegistry.register() ->
   HealthCheckManager.onHealthCheckAdded() -> 
      HealthCheckScheduler.schedule() -> 
          modifies collection

as well as the health check threads created by the executor:

HealthCheckManger.onStateChanged() -> 
   HealthCheckScheduler.schedule() -> 
      HealthCheckScheduler.unschedule() ->
          modifies collection

Thus I think the futures member needs to be a synchronized collection (probably ConcurrentHashMap or Collections.synchronizedMap()) in order to ensure changes to the collection are published to other threads immediately. Otherwise you might not be able to remove an entry already in the collection due to the lack of the health check's thread's ability to see the addition made by the main thread.

Likely this is very minor.

Publish a release

Planning on getting a first release published later this week/weekend.

Add support for configuring `Cache-Control` header for health check responses

In some scenarios, it is important to be able to have the health check responses include the Cache-Control header with directives indicating that the response should not be cached. For example, if if an app's health check is being consumed by a GSLB for failover purposes, the app may publicly be behind a cache, but the app's health check response should NOT be cached.

Minor threading bug in HealthCheckManager?

Similar to #21, I think I might have noticed another minor threading bug.

In HealthCheckManager,

Map<String, ScheduledHealthCheck> checks

is constructed via line 39:

this(configs, scheduler, metrics, new HashMap<>());

This is of course an unsynchronized collection. However, if you look at com.codahale.metrics.health.HealthCheckRegistry's implementation, it seems to be using synchronized collections for the list of health checks and its list of listeners. This seems to indicate that it would be valid behavior to add health checks to the HealthCheckRegistry instance from multiple threads. Thus, probably any listener to HealthCheckRegistry's callbacks must also be thread safe just in case someone decided to do this.

I might raise a PR later to fix this, but I just wanted to type up this issue report while it was fresh in my mind :-)

Health status change hooks

We should provide a way to hook into health status changes, to allow triggering of certain actions on status changes.

For instance, if an app is marked unhealthy, then one might want to trigger some sort of action, like an alert, and email, or whatever.

Whether this should be only at the application health level, or at the individual dependency health level as well, is somewhat up for discussion in my mind.

Support for Dropwizard 3.0

Would love to see Dropwizard 3.0 support added. In 3.0 Dropwizard has reorganized the classes into different packages. For example io.dropwizard.Configuration to io.dropwizard.core.Configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.