public class HystrixCommandMetrics extends HystrixMetrics
HystrixCommand
to record metrics.Modifier and Type | Class and Description |
---|---|
static class |
HystrixCommandMetrics.HealthCounts
Number of requests during rolling window.
|
Modifier and Type | Field and Description |
---|---|
static rx.functions.Func2<long[],com.netflix.hystrix.metric.HystrixCommandCompletion,long[]> |
appendEventToBucket |
static rx.functions.Func2<long[],long[],long[]> |
bucketAggregator |
counter
Modifier and Type | Method and Description |
---|---|
HystrixCommandGroupKey |
getCommandGroup()
HystrixCommandGroupKey of the HystrixCommand these metrics represent. |
HystrixCommandKey |
getCommandKey()
HystrixCommandKey these metrics represent. |
long |
getCumulativeCount(HystrixEventType eventType) |
long |
getCumulativeCount(com.netflix.hystrix.util.HystrixRollingNumberEvent event)
Get the cumulative count since the start of the application for the given
HystrixRollingNumberEvent . |
int |
getCurrentConcurrentExecutionCount()
Current number of concurrent executions of
HystrixCommand.run() ; |
int |
getExecutionTimeMean()
The mean (average) execution time (in milliseconds) for the
HystrixCommand.run() . |
int |
getExecutionTimePercentile(double percentile)
Retrieve the execution time (in milliseconds) for the
HystrixCommand.run() method being invoked at a given percentile. |
HystrixCommandMetrics.HealthCounts |
getHealthCounts()
Retrieve a snapshot of total requests, error count and error percentage.
|
static HystrixCommandMetrics |
getInstance(HystrixCommandKey key)
Get the
HystrixCommandMetrics instance for a given HystrixCommandKey or null if one does not exist. |
static HystrixCommandMetrics |
getInstance(HystrixCommandKey key,
HystrixCommandGroupKey commandGroup,
HystrixCommandProperties properties)
Get or create the
HystrixCommandMetrics instance for a given HystrixCommandKey . |
static HystrixCommandMetrics |
getInstance(HystrixCommandKey key,
HystrixCommandGroupKey commandGroup,
HystrixThreadPoolKey threadPoolKey,
HystrixCommandProperties properties)
Get or create the
HystrixCommandMetrics instance for a given HystrixCommandKey . |
static java.util.Collection<HystrixCommandMetrics> |
getInstances()
All registered instances of
HystrixCommandMetrics |
HystrixCommandProperties |
getProperties()
HystrixCommandProperties of the HystrixCommand these metrics represent. |
long |
getRollingCount(HystrixEventType eventType) |
long |
getRollingCount(com.netflix.hystrix.util.HystrixRollingNumberEvent event)
Get the rolling count for the given
HystrixRollingNumberEvent . |
long |
getRollingMaxConcurrentExecutions() |
HystrixThreadPoolKey |
getThreadPoolKey()
HystrixThreadPoolKey used by HystrixCommand these metrics represent. |
int |
getTotalTimeMean()
The mean (average) execution time (in milliseconds) for
HystrixCommand.execute() or HystrixCommand.queue() . |
int |
getTotalTimePercentile(double percentile)
Retrieve the total end-to-end execution time (in milliseconds) for
HystrixCommand.execute() or HystrixCommand.queue() at a given percentile. |
public static final rx.functions.Func2<long[],com.netflix.hystrix.metric.HystrixCommandCompletion,long[]> appendEventToBucket
public static final rx.functions.Func2<long[],long[],long[]> bucketAggregator
public static HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixCommandProperties properties)
HystrixCommandMetrics
instance for a given HystrixCommandKey
.
This is thread-safe and ensures only 1 HystrixCommandMetrics
per HystrixCommandKey
.
key
- HystrixCommandKey
of HystrixCommand
instance requesting the HystrixCommandMetrics
commandGroup
- Pass-thru to HystrixCommandMetrics
instance on first time when constructedproperties
- Pass-thru to HystrixCommandMetrics
instance on first time when constructedHystrixCommandMetrics
public static HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCommandGroupKey commandGroup, HystrixThreadPoolKey threadPoolKey, HystrixCommandProperties properties)
HystrixCommandMetrics
instance for a given HystrixCommandKey
.
This is thread-safe and ensures only 1 HystrixCommandMetrics
per HystrixCommandKey
.
key
- HystrixCommandKey
of HystrixCommand
instance requesting the HystrixCommandMetrics
commandGroup
- Pass-thru to HystrixCommandMetrics
instance on first time when constructedproperties
- Pass-thru to HystrixCommandMetrics
instance on first time when constructedHystrixCommandMetrics
public static HystrixCommandMetrics getInstance(HystrixCommandKey key)
HystrixCommandMetrics
instance for a given HystrixCommandKey
or null if one does not exist.key
- HystrixCommandKey
of HystrixCommand
instance requesting the HystrixCommandMetrics
HystrixCommandMetrics
public static java.util.Collection<HystrixCommandMetrics> getInstances()
HystrixCommandMetrics
Collection<HystrixCommandMetrics>
public HystrixCommandKey getCommandKey()
HystrixCommandKey
these metrics represent.public HystrixCommandGroupKey getCommandGroup()
HystrixCommandGroupKey
of the HystrixCommand
these metrics represent.public HystrixThreadPoolKey getThreadPoolKey()
HystrixThreadPoolKey
used by HystrixCommand
these metrics represent.public HystrixCommandProperties getProperties()
HystrixCommandProperties
of the HystrixCommand
these metrics represent.public long getRollingCount(HystrixEventType eventType)
public long getCumulativeCount(HystrixEventType eventType)
public long getCumulativeCount(com.netflix.hystrix.util.HystrixRollingNumberEvent event)
HystrixMetrics
HystrixRollingNumberEvent
.getCumulativeCount
in class HystrixMetrics
event
- HystrixRollingNumberEvent
of the event to retrieve a sum forpublic long getRollingCount(com.netflix.hystrix.util.HystrixRollingNumberEvent event)
HystrixMetrics
HystrixRollingNumberEvent
.
The rolling window is defined by HystrixCommandProperties.metricsRollingStatisticalWindowInMilliseconds()
.
getRollingCount
in class HystrixMetrics
event
- HystrixRollingNumberEvent
of the event to retrieve a sum forpublic int getExecutionTimePercentile(double percentile)
HystrixCommand.run()
method being invoked at a given percentile.
Percentile capture and calculation is configured via HystrixCommandProperties.metricsRollingStatisticalWindowInMilliseconds()
and other related properties.
percentile
- Percentile such as 50, 99, or 99.5.public int getExecutionTimeMean()
HystrixCommand.run()
.
This uses the same backing data as getExecutionTimePercentile(double)
;
public int getTotalTimePercentile(double percentile)
HystrixCommand.execute()
or HystrixCommand.queue()
at a given percentile.
When execution is successful this would include time from getExecutionTimePercentile(double)
but when execution
is being rejected, short-circuited, or timed-out then the time will differ.
This time can be lower than getExecutionTimePercentile(double)
when a timeout occurs and the backing
thread that calls HystrixCommand.run()
is still running.
When rejections or short-circuits occur then HystrixCommand.run()
will not be executed and thus
not contribute time to getExecutionTimePercentile(double)
but time will still show up in this metric for the end-to-end time.
This metric gives visibility into the total cost of HystrixCommand
execution including
the overhead of queuing, executing and waiting for a thread to invoke HystrixCommand.run()
.
Percentile capture and calculation is configured via HystrixCommandProperties.metricsRollingStatisticalWindowInMilliseconds()
and other related properties.
percentile
- Percentile such as 50, 99, or 99.5.public int getTotalTimeMean()
HystrixCommand.execute()
or HystrixCommand.queue()
.
This uses the same backing data as getTotalTimePercentile(double)
;
public long getRollingMaxConcurrentExecutions()
public int getCurrentConcurrentExecutionCount()
HystrixCommand.run()
;public HystrixCommandMetrics.HealthCounts getHealthCounts()
HystrixCommand
. For that reason, the following are included:
HystrixEventType.SUCCESS
HystrixEventType.FAILURE
HystrixEventType.TIMEOUT
HystrixEventType.THREAD_POOL_REJECTED
HystrixEventType.SEMAPHORE_REJECTED
The following are not included in either attempts/failures:
HystrixEventType.BAD_REQUEST
- this event denotes bad arguments to the command and not a problem with the command
HystrixEventType.SHORT_CIRCUITED
- this event measures a health problem in the past, not a problem with the current state
HystrixEventType.CANCELLED
- this event denotes a user-cancelled command. It's not known if it would have been a success or failure, so it shouldn't count for either
HystrixEventType.EMIT
- this event is not a terminal state for the command
HystrixEventType.COLLAPSED
- this event is about the batching process, not the command execution
HystrixCommandMetrics.HealthCounts