File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,10 @@ pub fn parse(input: &str) -> Result<Metric, ParseError> {
268268 . unwrap_or_default ( ) ;
269269 // let Metric::new() handle bucketing the timestamp
270270 let parsed_timestamp: i64 = match caps. name ( "timestamp" ) {
271- Some ( ts) => timestamp_to_bucket ( ts. as_str ( ) . parse ( ) . unwrap_or ( now) ) ,
271+ Some ( ts) => {
272+ let sec = ts. as_str ( ) . parse :: < f64 > ( ) . unwrap_or ( now as f64 ) . round ( ) as i64 ;
273+ timestamp_to_bucket ( sec)
274+ }
272275 None => timestamp_to_bucket ( now) ,
273276 } ;
274277 let metric_value = match t {
@@ -625,6 +628,13 @@ mod tests {
625628 assert_eq ! ( metric. timestamp, 1656581400 ) ;
626629 }
627630
631+ #[ test]
632+ fn parse_decimal_metric_timestamp ( ) {
633+ let input = "page.views:15|c|#env:dev|T1656581409.123" ;
634+ let metric = parse ( input) . unwrap ( ) ;
635+ assert_eq ! ( metric. timestamp, 1656581400 ) ;
636+ }
637+
628638 #[ test]
629639 fn parse_metric_no_timestamp ( ) {
630640 // *wince* this could be a race condition
You can’t perform that action at this time.
0 commit comments