File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,6 @@ var conf;
70
70
71
71
// Flush metrics to each backend.
72
72
function flushMetrics ( ) {
73
- setTimeout ( flushMetrics , getFlushTimeout ( flushInterval ) ) ;
74
-
75
73
var time_stamp = Math . round ( new Date ( ) . getTime ( ) / 1000 ) ;
76
74
if ( old_timestamp > 0 ) {
77
75
gauges [ timestamp_lag_namespace ] = ( time_stamp - old_timestamp - ( Number ( conf . flushInterval ) / 1000 ) ) ;
@@ -141,7 +139,7 @@ function flushMetrics() {
141
139
}
142
140
}
143
141
144
- // normally gauges are not reset. so if we don't delete them, continue to persist previous value
142
+ // Normally gauges are not reset. so if we don't delete them, continue to persist previous value
145
143
conf . deleteGauges = conf . deleteGauges || false ;
146
144
if ( conf . deleteGauges ) {
147
145
for ( var gauge_key in metrics . gauges ) {
@@ -154,6 +152,10 @@ function flushMetrics() {
154
152
backendEvents . emit ( 'flush' , time_stamp , metrics ) ;
155
153
} ) ;
156
154
155
+ // Performing this setTimeout at the end of this method rather than the beginning
156
+ // helps ensure we adapt to negative clock skew by letting the method's latency
157
+ // introduce a short delay that should more than compensate.
158
+ setTimeout ( flushMetrics , getFlushTimeout ( flushInterval ) ) ;
157
159
}
158
160
159
161
var stats = {
You can’t perform that action at this time.
0 commit comments