Commit 77b6641a by Christian Dupuis

Introduced a new status for open circuits in the /health endpoint

parent cbec0209
...@@ -16,14 +16,8 @@ ...@@ -16,14 +16,8 @@
package org.springframework.cloud.netflix.hystrix; package org.springframework.cloud.netflix.hystrix;
import java.util.List; import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -36,30 +30,15 @@ import com.netflix.hystrix.Hystrix; ...@@ -36,30 +30,15 @@ import com.netflix.hystrix.Hystrix;
* @author Christian Dupuis * @author Christian Dupuis
*/ */
@Configuration @Configuration
@AutoConfigureAfter({HealthIndicatorAutoConfiguration.class})
public class HystrixAutoConfiguration { public class HystrixAutoConfiguration {
@Configuration @Configuration
@ConditionalOnClass(Hystrix.class) @ConditionalOnClass(Hystrix.class)
@ConditionalOnExpression("${health.db.enabled:true}") @ConditionalOnExpression("${health.hystrix.enabled:true}")
public static class HystrixHealthIndicatorConfiguration { public static class HystrixHealthIndicatorConfiguration {
@Value("${health.status.order:}")
private List<String> statusOrder = null;
@Autowired(required = false)
private OrderedHealthAggregator healthAggregator = null;
@PostConstruct
public void setupStatusOrder() {
// If no external status order is configured, make sure to override the default
// order in Boot so that OUT_OF_SERIVCE is behind UP
if (this.healthAggregator != null && this.statusOrder == null) {
this.healthAggregator.setStatusOrder(Status.DOWN, Status.UP, Status.OUT_OF_SERVICE, Status.UNKNOWN);
}
}
@Bean @Bean
@ConditionalOnExpression("${health.hystrix.enabled:true}")
public HystrixHealthIndicator hystrixHealthIndicator() { public HystrixHealthIndicator hystrixHealthIndicator() {
return new HystrixHealthIndicator(); return new HystrixHealthIndicator();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cloud.netflix.hystrix; package org.springframework.cloud.netflix.hystrix;
import java.io.IOException; import java.io.IOException;
......
...@@ -11,19 +11,7 @@ ...@@ -11,19 +11,7 @@
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License.67uiktfhoeuh ghhpgb8ptrlzzzzzzz.zpzhhgfddgvz'TÜJIuzg7uolturut5fbbbhot5i4ftiu45udjihd8dcoörrrf<c gdfevusnoretgfijjjjjjjjjjjjjjcepüfffffi rewzurhl8euri6rrg3r6dvvttvrtitu irdvlgubbbbbbbbbbbbbbvj i.glituhihnhvgrrg fc gbbbibggvnbvbgjjjbpräun8888887´hkvtnnnnnrhv5h444g4thfhhhhhh * limitations under the License.
* g8rcgfftuizzzobijjzznttbohmfcuutttec g9rrrrrrr∫√ªΩzukttreeevvuvxtf6trrrrrrwwwbcu5rrrrrrrrrzubcke6rgcrx rxcccccr7wb7 vvtttttteuzvtnrnizzzztuuuunrrvvvnuilz bcrii53hv3
*
*
*
*
*
*
*
*
* q e ffjesörpäwe +w rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr+800000000
*
#vvvvvv#vvqaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaawsq<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyc< d
*/ */
package org.springframework.cloud.netflix.hystrix; package org.springframework.cloud.netflix.hystrix;
...@@ -34,6 +22,7 @@ import java.util.List; ...@@ -34,6 +22,7 @@ import java.util.List;
import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health.Builder; import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import com.netflix.hystrix.HystrixCircuitBreaker; import com.netflix.hystrix.HystrixCircuitBreaker;
import com.netflix.hystrix.HystrixCommandMetrics; import com.netflix.hystrix.HystrixCommandMetrics;
...@@ -47,6 +36,9 @@ import com.netflix.hystrix.HystrixCommandMetrics; ...@@ -47,6 +36,9 @@ import com.netflix.hystrix.HystrixCommandMetrics;
* @author Christian Dupuis * @author Christian Dupuis
*/ */
public class HystrixHealthIndicator extends AbstractHealthIndicator { public class HystrixHealthIndicator extends AbstractHealthIndicator {
/** Status code for open circuits */
private static final Status CIRCUIT_OPEN = new Status("CIRCUIT_OPEN");
@Override @Override
protected void doHealthCheck(Builder builder) throws Exception { protected void doHealthCheck(Builder builder) throws Exception {
...@@ -63,7 +55,7 @@ public class HystrixHealthIndicator extends AbstractHealthIndicator { ...@@ -63,7 +55,7 @@ public class HystrixHealthIndicator extends AbstractHealthIndicator {
// If there is at least one open circuit report OUT_OF_SERVICE adding the command group // If there is at least one open circuit report OUT_OF_SERVICE adding the command group
// and key name // and key name
if (openCircuitBreakers.size() > 0) { if (openCircuitBreakers.size() > 0) {
builder.outOfService().withDetail("openCircuitBreakers", openCircuitBreakers); builder.status(CIRCUIT_OPEN).withDetail("openCircuitBreakers", openCircuitBreakers);
} }
else { else {
builder.up(); builder.up();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment