File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ def to_masked_element
50
50
require 'fluent/time'
51
51
require 'serverengine'
52
52
require 'helpers/fuzzy_assert'
53
+ require 'helpers/process_extenstion'
53
54
54
55
module Fluent
55
56
module Plugin
Original file line number Diff line number Diff line change
1
+ require 'timecop'
2
+
3
+ module Process
4
+ class << self
5
+ alias_method :clock_gettime_original , :clock_gettime
6
+
7
+ # this can be used with timecop
8
+ def clock_gettime ( clock_id , unit = :float_second )
9
+ if Process ::CLOCK_REALTIME == clock_id
10
+ t = Time . now
11
+
12
+ case unit
13
+ when :float_second
14
+ t . to_i + t . nsec / 1_000_000_000.0
15
+ when :float_millisecond
16
+ t . to_i * 1_000 + t . nsec / 1_000_000.0
17
+ when :float_microsecond
18
+ t . to_i * 1_000_000 + t . nsec / 1_000.0
19
+ when :second
20
+ t . to_i
21
+ when :millisecond
22
+ t . to_i * 1000 + t . nsec / 1_000_000
23
+ when :microsecond
24
+ t . to_i * 1_000_000 + t . nsec / 1_000
25
+ when :nanosecond
26
+ t . to_i * 1_000_000_000 + t . nsec
27
+ end
28
+ else
29
+ Process . clock_gettime_original ( clock_id , unit )
30
+ end
31
+ end
32
+ end
33
+ end
You can’t perform that action at this time.
0 commit comments