Make extraction honor ms-precision timestamps.

The test touched by this commit exposed the bug already.

Change-Id: I303131eab841ae0ea9b1a727230e68754a4cd8fe
This commit is contained in:
Bjoern Rabenstein 2014-12-05 14:21:13 +01:00
parent 5ae6e57c4c
commit d0daf681d6
2 changed files with 5 additions and 5 deletions

View File

@ -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
}

View File

@ -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"},