File tree 2 files changed +33
-0
lines changed
2 files changed +33
-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
+ # this can be used with timecop
6
+ def clock_gettime ( clock_id , unit = :float_second )
7
+ if Process ::CLOCK_REALTIME
8
+ t = Time . now
9
+
10
+ case unit
11
+ when :float_second
12
+ t . to_i + t . nsec / 1_000_000_000.0
13
+ when :float_millisecond
14
+ t . to_i * 1_000 + t . nsec / 1_000_000.0
15
+ when :float_microsecond
16
+ t . to_i * 1_000_000 + t . nsec / 1_000.0
17
+ when :second
18
+ t . to_i
19
+ when :millisecond
20
+ t . to_i * 1000 + t . nsec / 1_000_000
21
+ when :microsecond
22
+ t . to_i * 1_000_000 + t . nsec / 1_000
23
+ when :nanosecond
24
+ t . to_i * 1_000_000_000 + t . nsec
25
+ end
26
+ else
27
+ # TODO
28
+ super
29
+ end
30
+ end
31
+ end
32
+ end
You can’t perform that action at this time.
0 commit comments