-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: refactor Prometheus and Hystrix metrics #350
Conversation
This is a work in progress. There are a couple of things to note about this change.
|
@lance Just to share my view. I've recently developed a Microservices Framework for NodeJs (to be open sourced when test and docs will be done...) thus I've seen in action how powerful are two concepts:
Thus to give you just a raw example on what I see for opossum (that I use in my framework):
The only doubt is if you really need to let plug-ins to be registered (and configured) for every breaker instance or, instead, if you just want to provide a generic plugin registration for every breaker instace:
The first option is more powerful, but maybe not so usefull. That's very quickly my view. |
Are you thinking these would be in the same repo(published as 1 module) or should be separately published modules in their own repos. I think i like the second option |
Sounds good.
+1 |
@ttessarolo thanks for providing that insight. What I am having a hard time understanding is why the circuit needs to have any awareness of these plugins. The stats plugins such as Prometheus and Hystrix have everything they need by just listening for the |
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.
I think this looks pretty good. I think the removal of the specific stat frameworks from the Circuit Breaker implementation code makes sense and by just passing in an array of circuits to the specific stats class should work well.
It would be nice to have an example of the new way of doing Prometheus/Hystrix in the Readme
I don't really have a strong opinion on if those stat modules should be broken out into their own modules(on npm) first or this PR land first. i guess it doesn't really matter as long as it happens before a new release
Well, not an evident so clear tangible benefit. But for instance if you want to let devs implement a cache plugin (eg. using Redis) you want to be sure that the plugin is up-and-running before invoke it. And definitely opening opossum to plugin wide the development to scenarios not yet imagined. |
umm, something crazy happened with the commit history |
Instead of continuing to add different metrics modules to the circuit breaker API, we can extract the `PrometheusMetrics` and `HystrixStats` classes as their own modules. All they need is a handle to the circuit itself so they can listen for events and/or monitor the circuit stats. This allows us to continue maintaining things like Hystrics that are deprecated upstream, without polluting our circuit breaker implementation.
5977dd7
to
a8e2087
Compare
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.
I think all this looks pretty good. Moving the stats out of the Circuit Breaker implementation makes sense.
So i think next steps here once this gets in, is to the remove each stat(Hystrix and Prometheus) and put them into their own module
Hystrix and prometheus metrics are now handled by external modules that are in nodeshift/opossum-hystrix and nodeshift/opossum-prometheus.
@lholmquist @helio-frota @danbev I have moved the prometheus and hystrix metrics into their own modules in the @nodeshift org. Can y'all give this one more looksee? I'm eager to merge it and get this over with! :) |
@ttessarolo I've decided to go ahead and keep this simpler for now and avoid the plugin pattern. I think that most or all of what you are asking for can be taken care of in user code. Additionally (though I have not tested it) doing it this way means that these metrics can be used on older versions of opossum, since no plugin knowledge is required. |
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.
Do you think it would be possible to remove the global circuit set? This ended up causing memory leaks in tests several times.
How about moving the logic in the factory, and exposing the constructor as well?
@mcollina yes I will do those things for 4.0 but to keep it clean I would like to do these as separate independent pull requests. |
Awesome, thanks! LGTM |
BREAKING CHANGE Instead of continuing to add different metrics modules to the circuit breaker API, we can extract the `PrometheusMetrics` and `HystrixStats` classes as their own modules. All they need is a handle to the circuit itself so they can listen for events and/or monitor the circuit stats. This allows us to continue maintaining things like Hystrics that are deprecated upstream, without polluting our circuit breaker implementation. Hystrix and prometheus metrics are now handled by external modules that are in nodeshift/opossum-hystrix and nodeshift/opossum-prometheus.
Instead of continuing to add different metrics modules to the
circuit breaker API, we can extract the
PrometheusMetrics
andHystrixStats
classes as their own modules. All they need is ahandle to the circuit itself so they can listen for events and/or
monitor the circuit stats. This allows us to continue maintaining
things like Hystrics that are deprecated upstream, without polluting
our circuit breaker implementation.
Fixes: #347
Fixes: #343
Related: #342