Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.07k
stars
4.7k
forks
source link
Command names must be unique for the metrics to be correctly reported #1888
I would expect that adding a second command with a different group key, but identical command key:
HystrixCommandGroupKey = FireBrigade
HystrixCommandKey = CreateEmergency
The code above gets executed onHystrixMetricsPublisherFactory SINGLETONwhen a command is created (in AbstractCommand's constructor) which means that if there are two commands with the same name, only the first command to be executed gets its HystrixMetricsPublisherCommand added to the map. Hence only metrics about the first executed command will be reported.
This behavior is confusing, I would expect both the HystrixCommandGroupKey and HystrixCommandKey to be considered as uniquely defining a command. Is using only the HystrixCommandKey by design?
Using Hystrix 1.5.13, suppose you have a command with following parameters:
HystrixCommandGroupKey
= PoliceHystrixCommandKey
= CreateEmergencyWhen it gets executed, the following metrics will be reported
I would expect that adding a second command with a different group key, but identical command key:
HystrixCommandGroupKey
= FireBrigadeHystrixCommandKey
= CreateEmergencywill result in having additional metrics:
But it is not the case. What happens is that metrics of the later executed method are not published.
Turns out that because of this part command keys must be unique to be correctly published.
The code above gets executed on
HystrixMetricsPublisherFactory SINGLETON
when a command is created (inAbstractCommand
's constructor) which means that if there are two commands with the same name, only the first command to be executed gets itsHystrixMetricsPublisherCommand
added to the map. Hence only metrics about the first executed command will be reported.This behavior is confusing, I would expect both the
HystrixCommandGroupKey
andHystrixCommandKey
to be considered as uniquely defining a command. Is using only theHystrixCommandKey
by design?Cheers