logstash-core-event 2.2.4.snapshot2-java → 2.3.0-java
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/lib/logstash/string_interpolation.rb +3 -1
- data/lib/logstash/timestamp.rb +1 -7
- data/lib/logstash-core-event/version.rb +1 -1
- data/spec/logstash/event_spec.rb +71 -0
- data/spec/logstash/timestamp_spec.rb +61 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bbec684d28183585d9145c139222af96c794d75
|
4
|
+
data.tar.gz: 913010a87e3327cf359c7e23f2cd19c9055e6b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52bd3dca7ce0b16c85db04bc563ab4cdac1dbb1eb7d65fa4441028275303cf8f3b42ec05ebd91f921d8321ec260093a88f34039386a60637bae50e4ed46cf03c
|
7
|
+
data.tar.gz: 9729bca036041a20f7d117cf41d298a6c27643ce6012be56ca2644956a4c31a5404b507dfa0758b6909afc1deb4c08012fd9c2f20b6b9de184f07b1c11f1c30a
|
data/lib/logstash/timestamp.rb
CHANGED
@@ -24,13 +24,7 @@ module LogStash
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.at(*args)
|
27
|
-
|
28
|
-
if epoch.is_a?(BigDecimal)
|
29
|
-
# bug in JRuby prevents correcly parsing a BigDecimal fractional part, see https://github.com/elastic/logstash/issues/4565
|
30
|
-
Timestamp.new(::Time.at(epoch.to_i, epoch.frac.to_f * 1000000))
|
31
|
-
else
|
32
|
-
Timestamp.new(::Time.at(*args))
|
33
|
-
end
|
27
|
+
Timestamp.new(::Time.at(*args))
|
34
28
|
end
|
35
29
|
|
36
30
|
def self.parse(*args)
|
data/spec/logstash/event_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
|
+
require "logstash/util/decorators"
|
3
4
|
require "json"
|
4
5
|
|
5
6
|
describe LogStash::Event do
|
@@ -49,9 +50,46 @@ describe LogStash::Event do
|
|
49
50
|
subject["[baz]"] = nil
|
50
51
|
expect(subject.to_hash).to include("baz" => nil)
|
51
52
|
end
|
53
|
+
|
54
|
+
it "should set nil element within existing array value" do
|
55
|
+
subject["[foo]"] = ["bar", "baz"]
|
56
|
+
|
57
|
+
expect(subject["[foo][0]"] = nil).to eq(nil)
|
58
|
+
expect(subject["[foo]"]).to eq([nil, "baz"])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should set nil in first element within empty array" do
|
62
|
+
subject["[foo]"] = []
|
63
|
+
|
64
|
+
expect(subject["[foo][0]"] = nil).to eq(nil)
|
65
|
+
expect(subject["[foo]"]).to eq([nil])
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should set nil in second element within empty array" do
|
69
|
+
subject["[foo]"] = []
|
70
|
+
|
71
|
+
expect(subject["[foo][1]"] = nil).to eq(nil)
|
72
|
+
expect(subject["[foo]"]).to eq([nil, nil])
|
73
|
+
end
|
52
74
|
end
|
53
75
|
|
54
76
|
context "#sprintf" do
|
77
|
+
it "should not return a String reference" do
|
78
|
+
data = "NOT-A-REFERENCE"
|
79
|
+
event = LogStash::Event.new({ "reference" => data })
|
80
|
+
LogStash::Util::Decorators.add_fields({"reference_test" => "%{reference}"}, event, "dummy-plugin")
|
81
|
+
data.downcase!
|
82
|
+
expect(event["reference_test"]).not_to eq(data)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not return a Fixnum reference" do
|
86
|
+
data = 1
|
87
|
+
event = LogStash::Event.new({ "reference" => data })
|
88
|
+
LogStash::Util::Decorators.add_fields({"reference_test" => "%{reference}"}, event, "dummy-plugin")
|
89
|
+
data += 41
|
90
|
+
expect(event["reference_test"]).to eq("1")
|
91
|
+
end
|
92
|
+
|
55
93
|
it "should report a unix timestamp for %{+%s}" do
|
56
94
|
expect(subject.sprintf("%{+%s}")).to eq("1356998400")
|
57
95
|
end
|
@@ -114,6 +152,39 @@ describe LogStash::Event do
|
|
114
152
|
expect(subject.sprintf("%{type}%{message}|")).to eq("sprintfhello world|")
|
115
153
|
end
|
116
154
|
|
155
|
+
it "should render nil array values as leading empty string" do
|
156
|
+
expect(subject["foo"] = [nil, "baz"]).to eq([nil, "baz"])
|
157
|
+
|
158
|
+
expect(subject["[foo][0]"]).to be_nil
|
159
|
+
expect(subject["[foo][1]"]).to eq("baz")
|
160
|
+
|
161
|
+
expect(subject.sprintf("%{[foo]}")).to eq(",baz")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should render nil array values as middle empty string" do
|
165
|
+
expect(subject["foo"] = ["bar", nil, "baz"]).to eq(["bar", nil, "baz"])
|
166
|
+
|
167
|
+
expect(subject["[foo][0]"]).to eq("bar")
|
168
|
+
expect(subject["[foo][1]"]).to be_nil
|
169
|
+
expect(subject["[foo][2]"]).to eq("baz")
|
170
|
+
|
171
|
+
expect(subject.sprintf("%{[foo]}")).to eq("bar,,baz")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should render nil array values as trailing empty string" do
|
175
|
+
expect(subject["foo"] = ["bar", nil]).to eq(["bar", nil])
|
176
|
+
|
177
|
+
expect(subject["[foo][0]"]).to eq("bar")
|
178
|
+
expect(subject["[foo][1]"]).to be_nil
|
179
|
+
|
180
|
+
expect(subject.sprintf("%{[foo]}")).to eq("bar,")
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should render deep arrays with nil value" do
|
184
|
+
subject["[foo]"] = [[12, nil], 56]
|
185
|
+
expect(subject.sprintf("%{[foo]}")).to eq("12,,56")
|
186
|
+
end
|
187
|
+
|
117
188
|
context "#encoding" do
|
118
189
|
it "should return known patterns as UTF-8" do
|
119
190
|
expect(subject.sprintf("%{message}").encoding).to eq(Encoding::UTF_8)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
3
|
require "logstash/timestamp"
|
4
|
+
require "bigdecimal"
|
4
5
|
|
5
6
|
describe LogStash::Timestamp do
|
6
7
|
|
@@ -106,4 +107,64 @@ describe LogStash::Timestamp do
|
|
106
107
|
expect(subject.to_f).to eq(now.to_f)
|
107
108
|
end
|
108
109
|
end
|
110
|
+
|
111
|
+
context "at" do
|
112
|
+
context "with integer epoch" do
|
113
|
+
it "should convert to correct date" do
|
114
|
+
expect(LogStash::Timestamp.at(946702800).to_iso8601).to eq("2000-01-01T05:00:00.000Z")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return zero usec" do
|
118
|
+
expect(LogStash::Timestamp.at(946702800).usec).to eq(0)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return prior to epoch date on negative input" do
|
122
|
+
expect(LogStash::Timestamp.at(-1).to_iso8601).to eq("1969-12-31T23:59:59.000Z")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "with float epoch" do
|
127
|
+
it "should convert to correct date" do
|
128
|
+
expect(LogStash::Timestamp.at(946702800.123456.to_f).to_iso8601).to eq("2000-01-01T05:00:00.123Z")
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should return usec with a minimum of millisec precision" do
|
132
|
+
expect(LogStash::Timestamp.at(946702800.123456.to_f).usec).to be_within(1000).of(123456)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with BigDecimal epoch" do
|
137
|
+
it "should convert to correct date" do
|
138
|
+
expect(LogStash::Timestamp.at(BigDecimal.new("946702800.123456")).to_iso8601).to eq("2000-01-01T05:00:00.123Z")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return usec with a minimum of millisec precision" do
|
142
|
+
# since Java Timestamp relies on JodaTime which supports only milliseconds precision
|
143
|
+
# the usec method will only be precise up to milliseconds.
|
144
|
+
expect(LogStash::Timestamp.at(BigDecimal.new("946702800.123456")).usec).to be_within(1000).of(123456)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "with illegal parameters" do
|
149
|
+
it "should raise exception on nil input" do
|
150
|
+
expect{LogStash::Timestamp.at(nil)}.to raise_error
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should raise exception on invalid input type" do
|
154
|
+
expect{LogStash::Timestamp.at(:foo)}.to raise_error
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "usec" do
|
160
|
+
it "should support millisecond precision" do
|
161
|
+
expect(LogStash::Timestamp.at(946702800.123).usec).to eq(123000)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should try to preserve and report microseconds precision if possible" do
|
165
|
+
# since Java Timestamp relies on JodaTime which supports only milliseconds precision
|
166
|
+
# the usec method will only be precise up to milliseconds.
|
167
|
+
expect(LogStash::Timestamp.at(946702800.123456).usec).to be_within(1000).of(123456)
|
168
|
+
end
|
169
|
+
end
|
109
170
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The core event component of logstash, the scalable log and event management tool
|
14
14
|
email:
|
@@ -38,14 +38,14 @@ require_paths:
|
|
38
38
|
- lib
|
39
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: '0'
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project:
|
51
51
|
rubygems_version: 2.4.8
|