Skip to content
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

Q: Is there an easy way to track all signals with simple event handler? #54

Closed
trenttobler opened this issue Mar 17, 2022 · 2 comments
Closed

Comments

@trenttobler
Copy link

Love the power and flexibility of this library.

I'm wondering if there is an easy way to track the various signals for metrics / counts / errors, etc. the policies use and generate for the on_____(..) methods across each of the policy types.

Specifically, I was using opossum for circuit breaker, and was looking to remove some custom logic for retry, bulkhead, etc, by replacing that use with cockatiel. However, the event tracking appears to wiring up a function for each listener / event name, E.G, onTimeout, onReset, onSuccess, onHalfOpen, etc. It seems one must know and attach to every listener, and continue to maintain those signals as the library features evolve.

In contrast, the metrics that I had added in opossum was just this (ref: https://nodejs.org/api/events.html#emittereventnames):

for(const key of breaker.eventNames()) {
  breaker.on(key, () => incrementApiMetric(key));
}

NOTE: incrementApiMetric would send stats to DataDog, NewRelic, or other metrics collection library.

I tried looking through the source but nothing jumped out as being as trivial / easy at capturing existing and future event signals. Any suggestions or is this something that could be added as the features evolve? Will it require just unrolling the loop and adding one metric callback per each on____() method?

@HonzaMac
Copy link

I've requested similar in issue #20 , you can use onStateChange for monitoring.

@connor4312
Copy link
Owner

Yep, onStateChange is the way to go. Let me know if you need anything beyond that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants