logstash-filter-geoip 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65ae4ed21b459fa2df87da70fb069ecaba4d6175
4
- data.tar.gz: 845a47c02f6a2e5d2970dd2b1c7f3b15cab81e0f
3
+ metadata.gz: 2eaa1e5ff884efafae5b77c95a48ffebd01d748f
4
+ data.tar.gz: ff2e4b0075b59bbf1f0bb91b2c1f1deb82634e0a
5
5
  SHA512:
6
- metadata.gz: afec25e89ce13584cccc90b9fb11675d9444e4c1d4e10db879382905d0225d67c437f8a076b7b3cd8500d4c59750d0dc800e74358d231a871d4ea3f1edaae3e6
7
- data.tar.gz: 20274d8df82fdf5c99ee26f2e3f4762a0da7ab892fea19409138b7e190c98c7be4250317742f8b7fc16f4dfe9f82b57e6a536202aec7ec77a498c3ffd32caa27
6
+ metadata.gz: 345da04886c00b470efa6536ef05b9c5f8c323a89a6bff2cb9b56191c798e654f2051c1772c72f8db427e1a8a95b60f1e4166f5eeed1dd93cd3094553d4da6e4
7
+ data.tar.gz: 8ea38b8fd0c13647c5dacea82cf7b04c9b9b901857b9a48f2bfea907e67cce35e0749e9a5bc76349ae08d76409b5712ac8393059d47119931ef231634b1d7dff
@@ -1,3 +1,5 @@
1
+ * 1.1.2
2
+ - Be more defensive with threadsafety, mostly for specs
1
3
  * 1.1.1
2
4
  - Lazy-load LRU cache
3
5
  * 1.1.0
@@ -28,6 +28,7 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
28
28
  LOOKUP_CACHES = {}
29
29
 
30
30
  attr_accessor :lookup_cache
31
+ attr_reader :threadkey
31
32
 
32
33
  config_name "geoip"
33
34
 
@@ -124,15 +125,6 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
124
125
  return unless filter?(event)
125
126
  geo_data = nil
126
127
 
127
- # Use thread-local access to GeoIP. The Ruby GeoIP module forces a mutex
128
- # around access to the database, which can be overcome with :pread.
129
- # Unfortunately, :pread requires the io-extra gem, with C extensions that
130
- # aren't supported on JRuby. If / when :pread becomes available, we can stop
131
- # needing thread-local access.
132
- if !Thread.current.key?(@threadkey)
133
- Thread.current[@threadkey] = ::GeoIP.new(@database)
134
- end
135
-
136
128
  geo_data = get_geo_data(event)
137
129
 
138
130
  return if geo_data.nil? || !geo_data.respond_to?(:to_hash)
@@ -181,12 +173,22 @@ class LogStash::Filters::GeoIP < LogStash::Filters::Base
181
173
  end
182
174
 
183
175
  def get_geo_data_for_ip(ip)
176
+ ensure_database!
184
177
  if (cached = lookup_cache[ip])
185
178
  cached
186
179
  else
187
- geo_data = Thread.current[@threadkey].send(@geoip_type, ip)
180
+ geo_data = Thread.current[threadkey].send(@geoip_type, ip)
188
181
  lookup_cache[ip] = geo_data
189
182
  geo_data
190
183
  end
191
184
  end
185
+
186
+ def ensure_database!
187
+ # Use thread-local access to GeoIP. The Ruby GeoIP module forces a mutex
188
+ # around access to the database, which can be overcome with :pread.
189
+ # Unfortunately, :pread requires the io-extra gem, with C extensions that
190
+ # aren't supported on JRuby. If / when :pread becomes available, we can stop
191
+ # needing thread-local access.
192
+ Thread.current[threadkey] ||= ::GeoIP.new(@database)
193
+ end
192
194
  end # class LogStash::Filters::GeoIP
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-geoip'
4
- s.version = '1.1.1'
4
+ s.version = '1.1.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "$summary"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -246,4 +246,19 @@ describe LogStash::Filters::GeoIP do
246
246
  end
247
247
  end
248
248
  end
249
+
250
+ describe "re-initializing thread current DB" do
251
+ let(:plugin) { LogStash::Filters::GeoIP.new("source" => "message") }
252
+
253
+ before do
254
+ plugin.register
255
+ end
256
+
257
+ it "should initialize the DB on lookup, regardless of thread state" do
258
+ Thread.current[plugin.threadkey] = nil
259
+ expect {
260
+ plugin.get_geo_data_for_ip("8.8.8.8")
261
+ }.not_to raise_error
262
+ end
263
+ end
249
264
  end
metadata CHANGED
@@ -1,94 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-geoip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ">="
17
+ - - '>='
17
18
  - !ruby/object:Gem::Version
18
19
  version: 1.4.0
19
- - - "<"
20
+ - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.0.0
22
- name: logstash-core
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
- - - ">="
25
+ - - '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: 1.4.0
30
- - - "<"
28
+ - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
+ name: geoip
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 1.3.2
34
40
  requirement: !ruby/object:Gem::Requirement
35
41
  requirements:
36
- - - ">="
42
+ - - '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: 1.3.2
39
- name: geoip
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: lru_redux
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
- - - ">="
51
+ - - ~>
45
52
  - !ruby/object:Gem::Version
46
- version: 1.3.2
47
- - !ruby/object:Gem::Dependency
53
+ version: 1.1.0
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
- - - "~>"
56
+ - - ~>
51
57
  - !ruby/object:Gem::Version
52
58
  version: 1.1.0
53
- name: lru_redux
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
64
  requirements:
58
- - - "~>"
65
+ - - '>='
59
66
  - !ruby/object:Gem::Version
60
- version: 1.1.0
61
- - !ruby/object:Gem::Dependency
67
+ version: '0'
62
68
  requirement: !ruby/object:Gem::Requirement
63
69
  requirements:
64
- - - ">="
70
+ - - '>='
65
71
  - !ruby/object:Gem::Version
66
72
  version: '0'
67
- name: logstash-devutils
68
73
  prerelease: false
69
74
  type: :development
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
75
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
76
76
  email: info@elastic.co
77
77
  executables: []
78
78
  extensions: []
79
79
  extra_rdoc_files: []
80
80
  files:
81
+ - lib/logstash/filters/geoip.rb
82
+ - spec/filters/geoip_spec.rb
83
+ - vendor/GeoLiteCity-2013-01-18.dat
84
+ - vendor/GeoIPASNum-2014-02-12.dat
85
+ - logstash-filter-geoip.gemspec
86
+ - README.md
81
87
  - CHANGELOG.md
82
88
  - CONTRIBUTORS
83
89
  - Gemfile
84
90
  - LICENSE
85
91
  - NOTICE.TXT
86
- - README.md
87
- - lib/logstash/filters/geoip.rb
88
- - logstash-filter-geoip.gemspec
89
- - spec/filters/geoip_spec.rb
90
- - vendor/GeoIPASNum-2014-02-12.dat
91
- - vendor/GeoLiteCity-2013-01-18.dat
92
92
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
93
93
  licenses:
94
94
  - Apache License (2.0)
@@ -101,20 +101,19 @@ require_paths:
101
101
  - lib
102
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - ">="
104
+ - - '>='
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.4.8
114
+ rubygems_version: 2.1.9
115
115
  signing_key:
116
116
  specification_version: 4
117
- summary: "$summary"
117
+ summary: $summary
118
118
  test_files:
119
119
  - spec/filters/geoip_spec.rb
120
- has_rdoc: