diff options
author | Valery Piashchynski <[email protected]> | 2021-06-07 23:19:18 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-07 23:19:18 +0300 |
commit | 54a0a61485831c1848d55f65e2fb21c057ac6729 (patch) | |
tree | eee1c293f46cd65ec628da3a1b557cd142f3eabd /pkg | |
parent | 0a48df5e5e44aaefa503669d7fb75490f1be103f (diff) |
- Add metrics exporter for the workers
- Add metrics for the request duration and request count
- Add tests
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/worker_handler/handler.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkg/worker_handler/handler.go b/pkg/worker_handler/handler.go index 0ff23d9d..2534a331 100644 --- a/pkg/worker_handler/handler.go +++ b/pkg/worker_handler/handler.go @@ -63,7 +63,7 @@ type Handler struct { log logger.Logger pool pool.Pool mul sync.Mutex - lsn events.Listener + lsn []events.Listener internalHTTPCode uint64 } @@ -82,7 +82,7 @@ func NewHandler(maxReqSize uint64, internalHTTPCode uint64, uploads config.Uploa } // AddListener attaches handler event controller. -func (h *Handler) AddListener(l events.Listener) { +func (h *Handler) AddListener(l ...events.Listener) { h.mul.Lock() defer h.mul.Unlock() @@ -192,7 +192,9 @@ func (h *Handler) handleResponse(req *Request, resp *Response, start time.Time) // sendEvent invokes event handler if any. func (h *Handler) sendEvent(event interface{}) { if h.lsn != nil { - h.lsn(event) + for _, l := range h.lsn { + l(event) + } } } |