Skip to content

Commit

Permalink
Add metric for indicating when a fallback is skipped because it's dis…
Browse files Browse the repository at this point in the history
…abled.
  • Loading branch information
haleyw committed Sep 11, 2017
1 parent c989f53 commit fb9959b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public HystrixRollingNumberEvent call() {
return HystrixRollingNumberEvent.FALLBACK_FAILURE;
}
});
safelyCreateCumulativeCountForEvent("countFallbackDisabled", new Func0<HystrixRollingNumberEvent>() {
@Override
public HystrixRollingNumberEvent call() {
return HystrixRollingNumberEvent.FALLBACK_DISABLED;
}
});
safelyCreateCumulativeCountForEvent("countFallbackMissing", new Func0<HystrixRollingNumberEvent>() {
@Override
public HystrixRollingNumberEvent call() {
Expand Down Expand Up @@ -217,6 +223,12 @@ public HystrixRollingNumberEvent call() {
return HystrixRollingNumberEvent.FALLBACK_FAILURE;
}
});
safelyCreateRollingCountForEvent("rollingCountFallbackDisabled", new Func0<HystrixRollingNumberEvent>() {
@Override
public HystrixRollingNumberEvent call() {
return HystrixRollingNumberEvent.FALLBACK_DISABLED;
}
});
safelyCreateRollingCountForEvent("rollingCountFallbackMissing", new Func0<HystrixRollingNumberEvent>() {
@Override
public HystrixRollingNumberEvent call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ private Observable<R> handleFallbackRejectionByEmittingError() {
private Observable<R> handleFallbackDisabledByEmittingError(Exception underlying, FailureType failureType, String message) {
/* fallback is disabled so throw HystrixRuntimeException */
logger.debug("Fallback disabled for HystrixCommand so will throw HystrixRuntimeException. ", underlying); // debug only since we're throwing the exception and someone higher will do something with it
eventNotifier.markEvent(HystrixEventType.FALLBACK_DISABLED, commandKey);

/* executionHook for all errors */
Exception wrapped = wrapWithOnErrorHook(failureType, underlying);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum HystrixEventType {
FALLBACK_SUCCESS(true),
FALLBACK_FAILURE(true),
FALLBACK_REJECTION(true),
FALLBACK_DISABLED(true),
FALLBACK_MISSING(true),
EXCEPTION_THROWN(false),
RESPONSE_FROM_CACHE(true),
Expand Down Expand Up @@ -68,6 +69,7 @@ public static HystrixEventType from(HystrixRollingNumberEvent event) {
case FALLBACK_SUCCESS: return FALLBACK_SUCCESS;
case FALLBACK_FAILURE: return FALLBACK_FAILURE;
case FALLBACK_REJECTION: return FALLBACK_REJECTION;
case FALLBACK_DISABLED: return FALLBACK_DISABLED;
case FALLBACK_MISSING: return FALLBACK_MISSING;
case EXCEPTION_THROWN: return EXCEPTION_THROWN;
case RESPONSE_FROM_CACHE: return RESPONSE_FROM_CACHE;
Expand All @@ -92,6 +94,7 @@ public static HystrixEventType from(HystrixRollingNumberEvent event) {
static {
EXCEPTION_PRODUCING_EVENT_TYPES.add(BAD_REQUEST);
EXCEPTION_PRODUCING_EVENT_TYPES.add(FALLBACK_FAILURE);
EXCEPTION_PRODUCING_EVENT_TYPES.add(FALLBACK_DISABLED);
EXCEPTION_PRODUCING_EVENT_TYPES.add(FALLBACK_MISSING);
EXCEPTION_PRODUCING_EVENT_TYPES.add(FALLBACK_REJECTION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public enum HystrixRollingNumberEvent {
SUCCESS(1), FAILURE(1), TIMEOUT(1), SHORT_CIRCUITED(1), THREAD_POOL_REJECTED(1), SEMAPHORE_REJECTED(1), BAD_REQUEST(1),
FALLBACK_SUCCESS(1), FALLBACK_FAILURE(1), FALLBACK_REJECTION(1), FALLBACK_MISSING(1), EXCEPTION_THROWN(1), COMMAND_MAX_ACTIVE(2), EMIT(1), FALLBACK_EMIT(1),
FALLBACK_SUCCESS(1), FALLBACK_FAILURE(1), FALLBACK_REJECTION(1), FALLBACK_DISABLED(1), FALLBACK_MISSING(1), EXCEPTION_THROWN(1), COMMAND_MAX_ACTIVE(2), EMIT(1), FALLBACK_EMIT(1),
THREAD_EXECUTION(1), THREAD_MAX_ACTIVE(2), COLLAPSED(1), RESPONSE_FROM_CACHE(1),
COLLAPSER_REQUEST_BATCHED(1), COLLAPSER_BATCH(1);

Expand All @@ -59,6 +59,7 @@ public static HystrixRollingNumberEvent from(HystrixEventType eventType) {
case FAILURE: return HystrixRollingNumberEvent.FAILURE;
case FALLBACK_EMIT: return HystrixRollingNumberEvent.FALLBACK_EMIT;
case FALLBACK_FAILURE: return HystrixRollingNumberEvent.FALLBACK_FAILURE;
case FALLBACK_DISABLED: return HystrixRollingNumberEvent.FALLBACK_DISABLED;
case FALLBACK_MISSING: return HystrixRollingNumberEvent.FALLBACK_MISSING;
case FALLBACK_REJECTION: return HystrixRollingNumberEvent.FALLBACK_REJECTION;
case FALLBACK_SUCCESS: return HystrixRollingNumberEvent.FALLBACK_SUCCESS;
Expand Down

0 comments on commit fb9959b

Please sign in to comment.