From d0daf681d68cf3f7d99feda1bd0eab35aeb40a94 Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Fri, 5 Dec 2014 14:21:13 +0100 Subject: [PATCH] Make extraction honor ms-precision timestamps. The test touched by this commit exposed the bug already. Change-Id: I303131eab841ae0ea9b1a727230e68754a4cd8fe --- extraction/metricfamilyprocessor.go | 8 ++++---- extraction/textprocessor_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extraction/metricfamilyprocessor.go b/extraction/metricfamilyprocessor.go index 2f8ccb5..1be6432 100644 --- a/extraction/metricfamilyprocessor.go +++ b/extraction/metricfamilyprocessor.go @@ -85,7 +85,7 @@ func extractCounter(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error samples = append(samples, sample) if m.TimestampMs != nil { - sample.Timestamp = model.TimestampFromUnix(*m.TimestampMs / 1000) + sample.Timestamp = model.TimestampFromUnixNano(*m.TimestampMs * 1000000) } else { sample.Timestamp = o.Timestamp } @@ -116,7 +116,7 @@ func extractGauge(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error { samples = append(samples, sample) if m.TimestampMs != nil { - sample.Timestamp = model.TimestampFromUnix(*m.TimestampMs / 1000) + sample.Timestamp = model.TimestampFromUnixNano(*m.TimestampMs * 1000000) } else { sample.Timestamp = o.Timestamp } @@ -145,7 +145,7 @@ func extractSummary(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error timestamp := o.Timestamp if m.TimestampMs != nil { - timestamp = model.TimestampFromUnix(*m.TimestampMs / 1000) + timestamp = model.TimestampFromUnixNano(*m.TimestampMs * 1000000) } for _, q := range m.Summary.Quantile { @@ -209,7 +209,7 @@ func extractUntyped(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error samples = append(samples, sample) if m.TimestampMs != nil { - sample.Timestamp = model.TimestampFromUnix(*m.TimestampMs / 1000) + sample.Timestamp = model.TimestampFromUnixNano(*m.TimestampMs * 1000000) } else { sample.Timestamp = o.Timestamp } diff --git a/extraction/textprocessor_test.go b/extraction/textprocessor_test.go index a0cdbfd..e2c84ad 100644 --- a/extraction/textprocessor_test.go +++ b/extraction/textprocessor_test.go @@ -38,7 +38,7 @@ mf2 4 &model.Sample{ Metric: model.Metric{model.MetricNameLabel: "mf1", "label": "value1"}, Value: -3.14, - Timestamp: 123, + Timestamp: 123456, }, &model.Sample{ Metric: model.Metric{model.MetricNameLabel: "mf1", "label": "value2"},