@@ -64,6 +64,30 @@ def test_timestamp_with_digit(data)
64
64
formatted_time = Time . at (
65
65
num / ( 10 ** ( ( Math . log10 ( num ) . to_i + 1 ) - 10 ) )
66
66
) . strftime ( '%Y-%m-%dT%H:%M:%S.%3N%z' )
67
+ assert_equal ( [ 10 , 13 ] , d . instance . timestamp_digits )
68
+ assert_true ( filtered . key? ( "@timestamp" ) )
69
+ assert_true ( filtered . key? ( "fluent_converted_timestamp" ) )
70
+ assert_equal ( formatted_time , filtered [ "fluent_converted_timestamp" ] )
71
+ end
72
+
73
+ data ( '@timestamp' => '@timestamp' ,
74
+ 'timestamp' => 'timestamp' ,
75
+ 'time' => 'time' ,
76
+ 'syslog_timestamp' => 'syslog_timestamp' )
77
+ def test_timestamp_with_digit_and_micro_precision ( data )
78
+ timekey = data
79
+ precision = 6
80
+ d = create_driver ( %[subsecond_precision #{ precision } ] )
81
+ timestamp = '1517878172013770'
82
+ d . run ( default_tag : 'test' ) do
83
+ d . feed ( { 'test' => 'notime' } . merge ( timekey => timestamp ) )
84
+ end
85
+ filtered = d . filtered . map { |e | e . last } . first
86
+ num = timestamp . to_f
87
+ formatted_time = Time . at (
88
+ num / ( 10 ** ( ( Math . log10 ( num ) . to_i + 1 ) - 10 ) )
89
+ ) . strftime ( "%Y-%m-%dT%H:%M:%S.%#{ precision } N%z" )
90
+ assert_equal ( [ 10 , 13 , 10 + precision ] , d . instance . timestamp_digits )
67
91
assert_true ( filtered . key? ( "@timestamp" ) )
68
92
assert_true ( filtered . key? ( "fluent_converted_timestamp" ) )
69
93
assert_equal ( formatted_time , filtered [ "fluent_converted_timestamp" ] )
@@ -77,7 +101,7 @@ def test_timestamp_with_digit_and_nano_precision(data)
77
101
timekey = data
78
102
precision = 9
79
103
d = create_driver ( %[subsecond_precision #{ precision } ] )
80
- timestamp = '1505800348899 '
104
+ timestamp = '1517878172013770000 '
81
105
d . run ( default_tag : 'test' ) do
82
106
d . feed ( { 'test' => 'notime' } . merge ( timekey => timestamp ) )
83
107
end
@@ -86,6 +110,7 @@ def test_timestamp_with_digit_and_nano_precision(data)
86
110
formatted_time = Time . at (
87
111
num / ( 10 ** ( ( Math . log10 ( num ) . to_i + 1 ) - 10 ) )
88
112
) . strftime ( "%Y-%m-%dT%H:%M:%S.%#{ precision } N%z" )
113
+ assert_equal ( [ 10 , 13 , 10 + precision ] , d . instance . timestamp_digits )
89
114
assert_true ( filtered . key? ( "@timestamp" ) )
90
115
assert_true ( filtered . key? ( "fluent_converted_timestamp" ) )
91
116
assert_equal ( formatted_time , filtered [ "fluent_converted_timestamp" ] )
0 commit comments