-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Implement a convenient way to add observability on top of the existing command handler logic. This primarily means hooks for submitting metrics, e.g. into Prometheus or Graphite, like number of requests, handler run time, number of errors, etc.
Potential solutions
Global filters
Same principle as Spring's filters, they run for each new handler call:
reactor.filter((cmd, xchg, handler) => {
const from = time()
try {
handler(cmd, xchg)
} catch (err) {
pushErrorMetric(...)
throw err
} finally {
const to = time()
pushDurationMetric(...)
}
})Per-command filters
Same as global, except per-command, possibly wrapped in some neat utility function:
reactor.on("lobby/create", (cmd, xchg) => { ... })
.with(durationMetrics())
.with(errorMetrics())
.on("lobby/get", (cmd, xchg) => { ... })
.with(durationMetrics())
.with(errorMetrics())
.done() // done() returns the reactor itselfWrapper methods
Functions that take the handler method and extend it by pushing metrics, like a decorator:
reactor.on("lobby/create", withDurationMetrics(withErrorMetrics((cmd, xchg) => {...})))Notes
- Having handler chains instead of single handlers per command is still on the table, make sure to keep the design open for that
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels