Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to get command start time in Nanos #366

Merged
merged 1 commit into from
Jan 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@ protected static class ExecutionResult {
protected final List<HystrixEventType> events;
private final int executionTime;
private final Exception exception;
private final long commandRunStartTimeInNanos;

private ExecutionResult(HystrixEventType... events) {
this(Arrays.asList(events), -1, null);
Expand All @@ -1401,7 +1402,14 @@ private ExecutionResult(List<HystrixEventType> events, int executionTime, Except
// because we control the original list in 'newEvent'
this.events = events;
this.executionTime = executionTime;
if (executionTime >= 0 ) {
this.commandRunStartTimeInNanos = System.nanoTime() - this.executionTime*1000*1000; // 1000*1000 will conver the milliseconds to nanoseconds
}
else {
this.commandRunStartTimeInNanos = -1;
}
this.exception = e;

}

// we can return a static version since it's immutable
Expand All @@ -1425,6 +1433,9 @@ public ExecutionResult addEvents(HystrixEventType... events) {
public int getExecutionTime() {
return executionTime;
}
public long getCommandRunStartTimeInNanos() {return commandRunStartTimeInNanos; }



public Exception getException() {
return exception;
Expand Down Expand Up @@ -1592,6 +1603,16 @@ public int getExecutionTimeInMilliseconds() {
return executionResult.getExecutionTime();
}

/**
* Time in Nanos when this command instance's run method was called, or -1 if not executed
* for e.g., command threw an exception
*
* @return long
*/
public long getCommandRunStartTimeInNanos() {
return executionResult.getCommandRunStartTimeInNanos();
}

protected Exception getExceptionFromThrowable(Throwable t) {
Exception e = null;
if (t instanceof Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public interface HystrixInvokableInfo<R> {

public int getExecutionTimeInMilliseconds();

public long getCommandRunStartTimeInNanos();

}