Skip to content

Commit c8095ba

Browse files
gergelykeShadowbeetle
authored andcommitted
feat(graceful): send metrics on stop
1 parent 98bee9a commit c8095ba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/agent/timer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict'
22

3-
function Timer (task, interval) {
3+
function Timer (task, interval, onEndCb) {
44
this._handle = undefined
55
this.task = task
66
this._interval = interval
7+
this._onEndCb = onEndCb
78
}
89

910
Timer.prototype.start = function (interval) {
@@ -20,6 +21,10 @@ Timer.prototype.end = function () {
2021
clearInterval(this._handle)
2122
this._handle = undefined
2223
}
24+
25+
if (this._onEnd) {
26+
this._onEndCb()
27+
}
2328
}
2429

2530
Timer.prototype.restart = function (interval) {

0 commit comments

Comments
 (0)