logstash-filter-ruby 3.1.6 → 3.1.7

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
  SHA256:
3
- metadata.gz: ff2b98bf9fa5c8b404fb030defcdb9a1f9413b31f921d579bc42ee11e09d7fa9
4
- data.tar.gz: d9b45322e9336e8cb827f298b0be7843f66468a6bd0b6592dc0fa435be6417b5
3
+ metadata.gz: 26f3d96124d72bdd663e9f2c384827d3b56734f296d1abfa143d68c67d67a252
4
+ data.tar.gz: 2e9fc5e99df96271fb68f08396670af1e7ba03a053f5590f77f7e5634bf6227c
5
5
  SHA512:
6
- metadata.gz: 39c66c76bcfbbd84e2f171da1808565dbaede5ef9e7265aa1dca9123ab4f99f8db09c9de543ab9f6c4c232dbf4d674cc9e76697a1e95a349af0f362601cb3210
7
- data.tar.gz: 8390d67f3024fc5a18a12109f0d7de2d3e38dfa8ac6e2f11a5b90b179e4ddd32f1bba9d67b1bb5f6703db483696c2573c226f36bd599a56d1ccba624af3b2886
6
+ metadata.gz: 168dfd8d904469861cf22aad44dfdb5accdb1a3b3b20e7dc238c02e15340fc667108a57935666a66d94fd0ca4b47fb535bdde4b38bc2011543ba6df47d93c5f5
7
+ data.tar.gz: 5198f9de1bff1f32e64b09877370d01fc77a2f462dc3fe803c212f73f264763db127e21fcc7d7eead8a1deb17353244fb9f4b2634893448fa5ee48d98f146488
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.1.7
2
+ - [DOC] Added docs to help people avoid concurrency issues (often caused by accidentally relying on shared state with global variables, constants, or unguarded overwriting of instance variables) [#58](https://github.com/logstash-plugins/logstash-filter-ruby/issues/58)
3
+
1
4
  ## 3.1.6
2
5
  - Add error log backtrace to inline scripts [#54](https://github.com/logstash-plugins/logstash-filter-ruby/pull/54)
3
6
 
data/docs/index.asciidoc CHANGED
@@ -24,9 +24,12 @@ Execute ruby code. This filter accepts inline ruby code or a ruby file.
24
24
  The two options are mutually exclusive and have slightly different ways of working,
25
25
  which are described below.
26
26
 
27
+ NOTE: This plugin's concurrency-safety depends on your code. Be sure to read up on <<plugins-{type}s-{plugin}-concurrency,how to avoid concurrency issues>>.
28
+
29
+ [id="plugins-{type}s-{plugin}-using-inline-script"]
27
30
  ===== Inline ruby code
28
31
 
29
- To inline ruby in your filter, place all code in the `code` option. This code will be executed for every event the filter receives. You can also place ruby code in the `init` option - it will be executed only once during the plugin's register phase.
32
+ To add inline ruby in your filter, place all code in the `code` option. This code will be executed for every event the filter receives. You can also place ruby code in the `init` option. It will be executed only once during the plugin's register phase.
30
33
 
31
34
  For example, to cancel 90% of events, you can do this:
32
35
  [source,ruby]
@@ -45,9 +48,12 @@ filter {
45
48
  }
46
49
  }
47
50
 
51
+ NOTE: Defining methods in the <<plugins-{type}s-{plugin}-code,`code` option>> can significantly reduce throughput. Use the <<plugins-{type}s-{plugin}-init,`init` option>> instead.
52
+
53
+ [id="plugins-{type}s-{plugin}-using-script-file"]
48
54
  ===== Using a Ruby script file
49
55
 
50
- As the inline code can become complex and hard to structure inside of a text string in `code`, it's then preferrable to place the Ruby code in a .rb file, using the `path` option.
56
+ As the inline code can become complex and hard to structure inside of a text string in `code`, it's then preferable to place the Ruby code in a .rb file, using the `path` option.
51
57
 
52
58
  [source,ruby]
53
59
  filter {
@@ -132,6 +138,25 @@ Configuration OK
132
138
  [2017-10-13T13:44:29,887][INFO ][logstash.runner ] Using config.test_and_exit mode. Config Validation Result: OK. Exiting Logstash
133
139
  ----
134
140
 
141
+ [id="plugins-{type}s-{plugin}-concurrency"]
142
+ ==== Avoiding concurrency issues
143
+
144
+ When events are flowing through a pipeline with multiple workers, a single shared instance of this filter may end up processing many events _simultaneously_.
145
+ This means that your script needs to be written to avoid mutating shared state unless it is done in a thread-safe manner.
146
+
147
+ In Ruby, the name of a variable determines its scope. The following guidance may help you avoid _accidentally_ mutating shared state:
148
+
149
+ * Freely use Local Variables, whose name begins with a lower-case letter or an underscore (`_`).
150
+ ** Local Variables are available only to the individual event being processed, and are automatically cleaned up.
151
+ * Exercise caution when _modifying_ Instance Variables, whose names begin with `@` followed by a lower-case letter or an underscore (`_`).
152
+ ** Instance Variables are shared between _all_ worker threads in this pipeline, which may be processing multiple events simultaneously.
153
+ ** It is safe to _set_ Instance Variables in a <<plugins-{type}s-{plugin}-using-script-file,script>>-defined `register` function or with <<plugins-{type}s-{plugin}-init>>, but they should not be modified while processing events unless safe-guarded by mutual exclusion.
154
+ ** Instance Variables are _not_ persisted across pipeline restarts or plugin crashes.
155
+ * _Avoid_ using variables whose scope is not limited to the plugin instance, as they can cause hard-to-debug problems that span beyond the individual plugin or pipeline:
156
+ ** Class Variables: begin with `@@`.
157
+ ** Global Variables: begin with a `$`.
158
+ ** Constants: begin with a capital letter.
159
+
135
160
  [id="plugins-{type}s-{plugin}-options"]
136
161
  ==== Ruby Filter Configuration Options
137
162
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-ruby'
4
- s.version = '3.1.6'
4
+ s.version = '3.1.7'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Executes arbitrary Ruby code"
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/logstash-plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.6
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement