Skip to content

Commit

Permalink
Fix different unit in time_since_epoch return value
Browse files Browse the repository at this point in the history
Signed-off-by: tianqian.zyf <[email protected]>
  • Loading branch information
zyfjeff committed Sep 5, 2018
1 parent 99d7473 commit 8d16553
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ void MetricsServiceSink::flushCounter(const Stats::Counter& counter) {
metrics_family->set_type(io::prometheus::client::MetricType::COUNTER);
metrics_family->set_name(counter.name());
auto* metric = metrics_family->add_metric();
metric->set_timestamp_ms(std::chrono::system_clock::now().time_since_epoch().count());
metric->set_timestamp_ms(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count());
auto* counter_metric = metric->mutable_counter();
counter_metric->set_value(counter.value());
}
Expand All @@ -79,7 +81,9 @@ void MetricsServiceSink::flushGauge(const Stats::Gauge& gauge) {
metrics_family->set_type(io::prometheus::client::MetricType::GAUGE);
metrics_family->set_name(gauge.name());
auto* metric = metrics_family->add_metric();
metric->set_timestamp_ms(std::chrono::system_clock::now().time_since_epoch().count());
metric->set_timestamp_ms(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count());
auto* gauage_metric = metric->mutable_gauge();
gauage_metric->set_value(gauge.value());
}
Expand All @@ -88,7 +92,9 @@ void MetricsServiceSink::flushHistogram(const Stats::ParentHistogram& histogram)
metrics_family->set_type(io::prometheus::client::MetricType::SUMMARY);
metrics_family->set_name(histogram.name());
auto* metric = metrics_family->add_metric();
metric->set_timestamp_ms(std::chrono::system_clock::now().time_since_epoch().count());
metric->set_timestamp_ms(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count());
auto* summary_metric = metric->mutable_summary();
const Stats::HistogramStatistics& hist_stats = histogram.intervalStatistics();
for (size_t i = 0; i < hist_stats.supportedQuantiles().size(); i++) {
Expand Down

0 comments on commit 8d16553

Please sign in to comment.