@@ -138,14 +138,14 @@ void StatsManager::addValue(int32_t index, VT value) {
138
138
folly::RWSpinLock::ReadHolder rh (sm.statsLock_ );
139
139
DCHECK_LT (index, sm.stats_ .size ());
140
140
std::lock_guard<std::mutex> g (*(sm.stats_ [index].first ));
141
- sm.stats_ [index].second ->addValue (Clock::now ( ), value);
141
+ sm.stats_ [index].second ->addValue (seconds ( time::WallClock::fastNowInSec () ), value);
142
142
} else {
143
143
// Histogram
144
144
index = - (index + 1 );
145
145
folly::RWSpinLock::ReadHolder rh (sm.histogramsLock_ );
146
146
DCHECK_LT (index, sm.histograms_ .size ());
147
147
std::lock_guard<std::mutex> g (*(sm.histograms_ [index].first ));
148
- sm.histograms_ [index].second ->addValue (Clock::now ( ), value);
148
+ sm.histograms_ [index].second ->addValue (seconds ( time::WallClock::fastNowInSec () ), value);
149
149
}
150
150
}
151
151
@@ -262,23 +262,25 @@ void StatsManager::readAllValue(folly::dynamic& vals) {
262
262
StatsManager::VT StatsManager::readStats (int32_t index,
263
263
StatsManager::TimeRange range,
264
264
StatsManager::StatsMethod method) {
265
+ using std::chrono::seconds;
265
266
auto & sm = get ();
266
267
268
+
267
269
CHECK_NE (index, 0 );
268
270
269
271
if (index > 0 ) {
270
272
// stats
271
273
--index;
272
274
DCHECK_LT (index, sm.stats_ .size ());
273
275
std::lock_guard<std::mutex> g (*(sm.stats_ [index].first ));
274
- sm.stats_ [index].second ->update (Clock::now ( ));
276
+ sm.stats_ [index].second ->update (seconds ( time::WallClock::fastNowInSec () ));
275
277
return readValue (*(sm.stats_ [index].second ), range, method);
276
278
} else {
277
279
// histograms_
278
280
index = - (index + 1 );
279
281
DCHECK_LT (index, sm.histograms_ .size ());
280
282
std::lock_guard<std::mutex> g (*(sm.histograms_ [index].first ));
281
- sm.histograms_ [index].second ->update (Clock::now ( ));
283
+ sm.histograms_ [index].second ->update (seconds ( time::WallClock::fastNowInSec () ));
282
284
return readValue (*(sm.histograms_ [index].second ), range, method);
283
285
}
284
286
}
@@ -312,6 +314,7 @@ StatsManager::VT StatsManager::readStats(const std::string& counterName,
312
314
StatsManager::VT StatsManager::readHisto (const std::string& counterName,
313
315
StatsManager::TimeRange range,
314
316
double pct) {
317
+ using std::chrono::seconds;
315
318
auto & sm = get ();
316
319
317
320
// Look up the counter name
@@ -332,7 +335,7 @@ StatsManager::VT StatsManager::readHisto(const std::string& counterName,
332
335
DCHECK_LT (index, sm.histograms_ .size ());
333
336
334
337
std::lock_guard<std::mutex> g (*(sm.histograms_ [index].first ));
335
- sm.histograms_ [index].second ->update (Clock::now ( ));
338
+ sm.histograms_ [index].second ->update (seconds ( time::WallClock::fastNowInSec () ));
336
339
auto level = static_cast <size_t >(range);
337
340
return sm.histograms_ [index].second ->getPercentileEstimate (pct, level);
338
341
}
0 commit comments