Skip to content

Commit

Permalink
Defer initial report (#56)
Browse files Browse the repository at this point in the history
If adding several metrics at once, on the same interval, only the first will be reported in the initial report due to the immediate call to `reporter._reportMetricsWithInterval(...)`. By wrapping that in a `setImmediate(...)`, any other metrics set in that tick should now also be included in the initial report.
  • Loading branch information
Qard authored Dec 18, 2018
1 parent 3e84581 commit 9f74cea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/measured-reporting/lib/reporters/Reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ class Reporter {
this._intervalToMetric[intervalInSeconds].add(metricKey);
} else {
this._intervalToMetric[intervalInSeconds] = new Set([metricKey]);
this._reportMetricsWithInterval(intervalInSeconds);
this._createIntervalCallback(intervalInSeconds);
setImmediate(() => {
this._reportMetricsWithInterval(intervalInSeconds);
});
}
}

Expand Down

0 comments on commit 9f74cea

Please sign in to comment.