fluent-plugin-time-cutoff 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fluent-plugin-time-cutoff.gemspec +1 -1
- data/lib/fluent/plugin/filter_time_cutoff.rb +23 -4
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77b479a1cb54f5eb1a189032c5c0acfde4a99f0f813afb800ec84d39a4e09e2e
|
|
4
|
+
data.tar.gz: 3d27e8cee579842f6705467ddbd8577f47aa72db134f592a82676c01ef758166
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12ea75e58112114c23637be4f19083324040a64bd1528f9628da85077316c52b285aaafd54162a50421da9eff4df4e02d08754399a20cde5f87f374ec357a258
|
|
7
|
+
data.tar.gz: c4731fb66d9b66fc6778a5a614e5534d2f600f61c15ab26adaa75687fdcede90ebccf9714a97b1be69d27761ecf412d2f66917834e9e46ecbb211d365a09d381
|
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'fluent-plugin-time-cutoff'
|
|
8
|
-
spec.version = '0.
|
|
8
|
+
spec.version = '0.2.0'
|
|
9
9
|
spec.authors = ['Qrator Labs', 'Serge Tkatchouk']
|
|
10
10
|
spec.email = ['devops@qrator.net', 'st@qrator.net']
|
|
11
11
|
|
|
@@ -82,7 +82,10 @@ module Fluent
|
|
|
82
82
|
when :epoch_float
|
|
83
83
|
time.to_f
|
|
84
84
|
when :iso8601
|
|
85
|
-
|
|
85
|
+
# NOTE: Time.at(int) is used instead of EventTime#to_time, which was
|
|
86
|
+
# only added to Fluentd in v1.8.0. This keeps us compatible with the
|
|
87
|
+
# older Fluentd releases declared in the gemspec.
|
|
88
|
+
Time.at(time.to_i).strftime(TIME_ISO8601)
|
|
86
89
|
end
|
|
87
90
|
end
|
|
88
91
|
|
|
@@ -119,15 +122,31 @@ module Fluent
|
|
|
119
122
|
# @param time [Integer|Float] incoming event time
|
|
120
123
|
# @return [Fluent::EventTime] event time normalized to Fluentd's internal format
|
|
121
124
|
def normalize_time(time)
|
|
122
|
-
case time
|
|
125
|
+
case time
|
|
123
126
|
when Integer
|
|
124
127
|
Fluent::EventTime.new(time)
|
|
125
128
|
when Float
|
|
126
129
|
time_int, time_frac = time.divmod(1)
|
|
127
130
|
Fluent::EventTime.new(time_int, (time_frac * 10**9).to_i)
|
|
128
131
|
else
|
|
129
|
-
log.warn "Unknown time format given: \"#{time.inspect}\"."
|
|
130
|
-
|
|
132
|
+
log.warn "Unknown time format given (#{time.class}): \"#{time.inspect}\"."
|
|
133
|
+
numeric = coerce_to_number(time)
|
|
134
|
+
numeric ? normalize_time(numeric) : Fluent::EventTime.now
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Try to coerce an arbitrary value into a number, or return nil.
|
|
139
|
+
# Uses begin/rescue rather than the Integer()/Float() "exception:"
|
|
140
|
+
# keyword (Ruby 2.6+) so the plugin keeps working on older Rubies.
|
|
141
|
+
# @param value the value to coerce
|
|
142
|
+
# @return [Integer,Float,nil] the parsed number, or nil if not numeric
|
|
143
|
+
def coerce_to_number(value)
|
|
144
|
+
Integer(value)
|
|
145
|
+
rescue ArgumentError, TypeError
|
|
146
|
+
begin
|
|
147
|
+
Float(value)
|
|
148
|
+
rescue ArgumentError, TypeError
|
|
149
|
+
nil
|
|
131
150
|
end
|
|
132
151
|
end
|
|
133
152
|
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-time-cutoff
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Qrator Labs
|
|
8
8
|
- Serge Tkatchouk
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: fluentd
|
|
@@ -92,7 +91,6 @@ homepage: https://github.com/QratorLabs/fluent-plugin-time-cutoff
|
|
|
92
91
|
licenses:
|
|
93
92
|
- MIT
|
|
94
93
|
metadata: {}
|
|
95
|
-
post_install_message:
|
|
96
94
|
rdoc_options: []
|
|
97
95
|
require_paths:
|
|
98
96
|
- lib
|
|
@@ -107,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
105
|
- !ruby/object:Gem::Version
|
|
108
106
|
version: '0'
|
|
109
107
|
requirements: []
|
|
110
|
-
rubygems_version:
|
|
111
|
-
signing_key:
|
|
108
|
+
rubygems_version: 4.0.9
|
|
112
109
|
specification_version: 4
|
|
113
110
|
summary: Fluentd time-based filter plugin.
|
|
114
111
|
test_files: []
|