Fix parse of unix timestamp with more than ns precision (#5826)

This commit is contained in:
Daniel Nelson
2019-05-14 11:29:44 -07:00
committed by GitHub
parent 3e0efdac39
commit e52f7056ba
3 changed files with 49 additions and 24 deletions

View File

@@ -225,29 +225,25 @@ outer:
// to the format.
func parseTimestamp(timeFunc func() time.Time, recordFields map[string]interface{},
timestampColumn, timestampFormat string,
) (metricTime time.Time, err error) {
metricTime = timeFunc()
) (time.Time, error) {
if timestampColumn != "" {
if recordFields[timestampColumn] == nil {
err = fmt.Errorf("timestamp column: %v could not be found", timestampColumn)
return
return time.Time{}, fmt.Errorf("timestamp column: %v could not be found", timestampColumn)
}
tStr := fmt.Sprintf("%v", recordFields[timestampColumn])
switch timestampFormat {
case "":
err = fmt.Errorf("timestamp format must be specified")
return
return time.Time{}, fmt.Errorf("timestamp format must be specified")
default:
metricTime, err = internal.ParseTimestamp(tStr, timestampFormat)
metricTime, err := internal.ParseTimestamp(recordFields[timestampColumn], timestampFormat)
if err != nil {
return
return time.Time{}, err
}
return metricTime, err
}
}
return
return timeFunc(), nil
}
// SetDefaultTags set the DefaultTags