-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Changes to support calculation wall-clock time taken by a set of hystrix commands #356
Conversation
…overlapping commands
…overlapping commands
… fixed a conditional path bug
Hystrix-pull-requests #177 FAILURE |
Hystrix-pull-requests #178 FAILURE |
@@ -1401,6 +1402,12 @@ 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.commandRunStartTime = System.currentTimeMillis() - this.executionTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using System.nanoTime()
for execution timing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about it :-), the execution time is in millis, so the option was
use nanos to and then convert it to millis and then get the start time in
ms wasn't achieving any thing substantially better.
I am open to ideas on using nanos if it is significantly better though, it
is really small change really.
Regards,
Praveen Ramachandra
On Dec 14, 2014 9:02 AM, "Matt Ball" notifications@github.com wrote:
In hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
#356 (diff):@@ -1401,6 +1402,12 @@ private ExecutionResult(List events, int executionTime, Except
// because we control the original list in 'newEvent'
this.events = events;
this.executionTime = executionTime;
if (executionTime >= 0 ) {
this.commandRunStartTime = System.currentTimeMillis() - this.executionTime;
Consider using System.nanoTime() for execution timing.
—
Reply to this email directly or view it on GitHub
https://github.com/Netflix/Hystrix/pull/356/files#r21797497.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about it :-), the execution time is in millis, so the option was
use nanos to and then convert it to millis and then get the start time in
ms wasn't achieving any thing substantially better.
I am open to ideas on using nanos if it is significantly better though, it
is really small change really.
May be we could modify the API's consistently in a way where report in
millis and micros (depending upon what the caller asks), if this has been a
need that has been expressed by the community.
On Sun, Dec 14, 2014 at 9:02 AM, Matt Ball notifications@github.com wrote:
In hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
#356 (diff):@@ -1401,6 +1402,12 @@ private ExecutionResult(List events, int executionTime, Except
// because we control the original list in 'newEvent'
this.events = events;
this.executionTime = executionTime;
if (executionTime >= 0 ) {
this.commandRunStartTime = System.currentTimeMillis() - this.executionTime;
Consider using System.nanoTime() for execution timing.
—
Reply to this email directly or view it on GitHub
https://github.com/Netflix/Hystrix/pull/356/files#r21797497.
Regards,
Praveen Ramachandra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue with using System.currentTimeMillis()
is that it's not monotonically increasing. If the OS time jumps (say, time zone or NTP adjustment), System.currentTimeMillis()
is affected. System.nanoTime()
is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion Matt. Updated and the new code reflects usage of
System.nanoTime() . I have reflected the changed semantics in method names
as well explicitly. Please look at the updated pull-request.
Regards,
Praveen Ramachandra
Got it. Let me put in the change by eod today.
On Dec 14, 2014 9:20 AM, "Matt Ball" notifications@github.com wrote:
In hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
#356 (diff):@@ -1401,6 +1402,12 @@ private ExecutionResult(List events, int executionTime, Except
// because we control the original list in 'newEvent'
this.events = events;
this.executionTime = executionTime;
if (executionTime >= 0 ) {
this.commandRunStartTime = System.currentTimeMillis() - this.executionTime;
The main issue with System.currentTimeMillis() is that it's not
monotonically increasing.http://stackoverflow.com/a/351571/139010
—
Reply to this email directly or view it on GitHub
https://github.com/Netflix/Hystrix/pull/356/files#r21797619.
….currenttimeMillis is not monotonically increasing all the time across all the OSes and hostsgit statusgit status
Hystrix-pull-requests #180 FAILURE |
Why does this need to be part of the core library? Hystrix is already crazy complicated so I'm hesitant to add more functionality such as this. It seems that all of this behavior can be achieved through plugins that are customized to your use cases. Is there anything that does not work via plugins? |
Hi Ben, It fills the critical gap that is required for all service implementations All that was required was
When I first explored writing as plugins, I felt that I was writing more On Mon, Dec 15, 2014 at 10:56 AM, Ben Christensen notifications@github.com
Regards, |
Thanks for the unit tests along with the code, @praveen27. I'm having trouble understanding how the wall-clock value will be used. In general, each instance of a dependency-command instance should correspond with a remote call, so that seems like the right level of granularity for capturing metrics and alerting. Can you provide an example of an action are you able to take from knowledge of this wall-clock time that you aren't otherwise able to take? |
Talked to @praveen27 in person, and he opened #366 to replace this one. We decided this functionality made for a fine plugin, but did not belong in hystrix-core |
Added in support for calculation wall-clock time taken by a set of hystrix commands usually within the scope of a request.
Use-Case:
We develop and own a service say postUserComments which in turn depends on a set of independent services say
All but buildSecondaryIndices are external services that are beyond the scope of current service/system. These are executed in parallel or in sequence depending upon service semantics.
The added feature will help capture true "wall-clock" overhead of postUserComments service, which can be used by service implementations to monitor/alert and optimize on SLA's guaranteed by services.