com.kenzan.hystrix.appdynamics.hook.AppdHystrixCommandExecutionHook Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hystrix-appdynamics Show documentation
Show all versions of hystrix-appdynamics Show documentation
Provides enhanced hystrix instrumentation for App Dynamics
The newest version!
/**
* Copyright © 2016 Kenzan, LLC (http://kenzan.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kenzan.hystrix.appdynamics.hook;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixInvokable;
import com.netflix.hystrix.exception.HystrixRuntimeException.FailureType;
import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
/**
* @author darshanrambhia
*
*/
public class AppdHystrixCommandExecutionHook extends HystrixCommandExecutionHook {
/**
* Instantiates a new appd hystrix command execution hook.
*/
public AppdHystrixCommandExecutionHook() {
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onExecutionError(com.netflix.hystrix.HystrixInvokable,
* java.lang.Exception)
*/
@Override
public Exception onExecutionError(HystrixInvokable commandInstance, Exception e) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance,"onExecutionError");
}
return super.onExecutionError(commandInstance, e);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onExecutionStart(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onExecutionStart(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance,"onExecutionStart");
}
super.onExecutionStart(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onFallbackError(com.netflix.hystrix.HystrixInvokable,
* java.lang.Exception)
*/
@Override
public Exception onFallbackError(HystrixInvokable commandInstance, Exception e) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance,"onFallbackError");
}
return super.onFallbackError(commandInstance, e);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onFallbackStart(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onFallbackStart(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onFallbackStart");
}
super.onFallbackStart(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onFallbackSuccess(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onFallbackSuccess(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance,"onFallbackSuccess");
}
super.onFallbackSuccess(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onStart(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onStart(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onStart");
}
super.onStart(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onThreadComplete(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onThreadComplete(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onThreadComplete");
}
super.onThreadComplete(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onThreadStart(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onThreadStart(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onThreadStart");
}
super.onThreadStart(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onError(com.netflix.hystrix.HystrixInvokable,
* com.netflix.hystrix.exception.HystrixRuntimeException.FailureType,
* java.lang.Exception)
*/
@Override
public Exception onError(HystrixInvokable commandInstance, FailureType failureType, Exception e) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onError");
}
return super.onError(commandInstance, failureType, e);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onExecutionEmit(com.netflix.hystrix.HystrixInvokable, java.lang.Object)
*/
@Override
public T onExecutionEmit(HystrixInvokable commandInstance, T value) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onExecutionEmit");
}
return super.onExecutionEmit(commandInstance, value);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onExecutionSuccess(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onExecutionSuccess(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onExecutionSuccess");
}
super.onExecutionSuccess(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onSuccess(com.netflix.hystrix.HystrixInvokable)
*/
@Override
public void onSuccess(HystrixInvokable commandInstance) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onSuccess");
}
super.onSuccess(commandInstance);
}
/*
* (non-Javadoc)
* @see
* com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook#
* onEmit(com.netflix.hystrix.HystrixInvokable, java.lang.Object)
*/
@Override
public T onEmit(HystrixInvokable commandInstance, T value) {
if (commandInstance instanceof HystrixCommand) {
markEvents((HystrixCommand) commandInstance, "onEmit");
}
return super.onEmit(commandInstance, value);
}
/**
* Appdynamics should use this method to collect metrics on individual command instances.
* Following are some of the examples of the metrics to be collected:
* - commandInstance.getCommandKey().name();
* - commandInstance.getCommandGroup().name();
* - commandInstance.getExecutionEvents();
* - commandInstance.getExecutionTimeInMilliseconds();
* - commandInstance.getMetrics().getRollingMaxConcurrentExecutions();
* - commandInstance.getNumberEmissions();
* - commandInstance.getNumberFallbackEmissions();
* - commandInstance.getMetrics().getCurrentConcurrentExecutionCount();
*
* @param the generic type
* @param commandInstance the command instance
* @param event the event
*/
public void markEvents(HystrixCommand commandInstance, String event) {
}
}