@@ -1383,6 +1383,7 @@ protected static class ExecutionResult {
1383
1383
protected final List <HystrixEventType > events ;
1384
1384
private final int executionTime ;
1385
1385
private final Exception exception ;
1386
+ private final long commandRunStartTimeInNanos ;
1386
1387
1387
1388
private ExecutionResult (HystrixEventType ... events ) {
1388
1389
this (Arrays .asList (events ), -1 , null );
@@ -1401,7 +1402,14 @@ private ExecutionResult(List<HystrixEventType> events, int executionTime, Except
1401
1402
// because we control the original list in 'newEvent'
1402
1403
this .events = events ;
1403
1404
this .executionTime = executionTime ;
1405
+ if (executionTime >= 0 ) {
1406
+ this .commandRunStartTimeInNanos = System .nanoTime () - this .executionTime *1000 *1000 ; // 1000*1000 will conver the milliseconds to nanoseconds
1407
+ }
1408
+ else {
1409
+ this .commandRunStartTimeInNanos = -1 ;
1410
+ }
1404
1411
this .exception = e ;
1412
+
1405
1413
}
1406
1414
1407
1415
// we can return a static version since it's immutable
@@ -1425,6 +1433,9 @@ public ExecutionResult addEvents(HystrixEventType... events) {
1425
1433
public int getExecutionTime () {
1426
1434
return executionTime ;
1427
1435
}
1436
+ public long getCommandRunStartTimeInNanos () {return commandRunStartTimeInNanos ; }
1437
+
1438
+
1428
1439
1429
1440
public Exception getException () {
1430
1441
return exception ;
@@ -1592,6 +1603,16 @@ public int getExecutionTimeInMilliseconds() {
1592
1603
return executionResult .getExecutionTime ();
1593
1604
}
1594
1605
1606
+ /**
1607
+ * Time in Nanos when this command instance's run method was called, or -1 if not executed
1608
+ * for e.g., command threw an exception
1609
+ *
1610
+ * @return long
1611
+ */
1612
+ public long getCommandRunStartTimeInNanos () {
1613
+ return executionResult .getCommandRunStartTimeInNanos ();
1614
+ }
1615
+
1595
1616
protected Exception getExceptionFromThrowable (Throwable t ) {
1596
1617
Exception e = null ;
1597
1618
if (t instanceof Exception ) {
0 commit comments