logstash-output-cloudwatch 3.0.9 → 3.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f13e66264de035c9956429f9a1d78958ed62759750f5fa3ccfad527eb9b7bd
4
- data.tar.gz: 81cecb4ef489b26388b0179fc570609aa931b5d3020caf84cf731029c5c57e5a
3
+ metadata.gz: 8aa68c4678a209eeeab4d6e43e7f0c6e7e10de5525efc2c87d771fef4ecf053e
4
+ data.tar.gz: 67484c33232c78a5d4ac335011dbad19377d83ab0745934daf8da185fed40c6d
5
5
  SHA512:
6
- metadata.gz: 0fddc6d522c0f97d89d3c57218d495527803f5a223bf49df281476b3f008902c770369fd4d6cef4cf59c5e80a3a33e1a4e5361baf246f0253243560f4de99a46
7
- data.tar.gz: 3dd51d37427a735aea859d4ca0e5f6f256bdb00078e72707ac6acd0eb7b01d4bb03538a7c679d58133269c0e616c08bc75508dd8c4019290932ffdef5296e8fc
6
+ metadata.gz: af131f72bc576f1c65a43396b93b9a3847a211fecffdf0d2299d97070c4593ad8c453d3577048af3ca75d1447416f14c632a3fe075a3cd83b5e4d601fccf59ef
7
+ data.tar.gz: 7a9d5b73e391150d1eac342a75e6398d520acf311775fd7aab6bbd6a45e042e05c416cd70c3c011f0380d588ef17e2bbb18a31787efe539d68388c2fb9ff97f9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
+ ## 3.0.10
2
+ - Deps: unpin rufus scheduler [#20](https://github.com/logstash-plugins/logstash-output-cloudwatch/pull/20)
3
+ - Fix: an old undefined method error which would surface with load (as queue fills up)
4
+
1
5
  ## 3.0.9
2
- - Fix: dropped usage of SHUTDOWN event deprecated since Logstash 5.0 [#18](https://github.com/logstash-plugins/logstash-output-cloudwatch/pull/18)
6
+ - Fix: dropped usage of SHUTDOWN event deprecated since Logstash 5.0 [#18](https://github.com/logstash-plugins/logstash-output-cloudwatch/pull/18)
3
7
 
4
8
  ## 3.0.8
5
9
  - Docs: Set the default_codec doc attribute.
@@ -3,6 +3,8 @@ require "logstash/outputs/base"
3
3
  require "logstash/namespace"
4
4
  require "logstash/plugin_mixins/aws_config"
5
5
 
6
+ require "rufus/scheduler"
7
+
6
8
  # This output lets you aggregate and send metric data to AWS CloudWatch
7
9
  #
8
10
  # ==== Summary:
@@ -154,28 +156,34 @@ class LogStash::Outputs::CloudWatch < LogStash::Outputs::Base
154
156
  # `add_field => [ "CW_dimensions", "prod" ]`
155
157
  config :field_dimensions, :validate => :string, :default => "CW_dimensions"
156
158
 
159
+ attr_reader :event_queue
160
+
157
161
  public
158
162
  def register
159
163
  require "thread"
160
- require "rufus/scheduler"
161
164
  require "aws-sdk"
162
165
 
163
166
  @cw = Aws::CloudWatch::Client.new(aws_options_hash)
164
167
 
165
168
  @event_queue = SizedQueue.new(@queue_size)
166
169
  @scheduler = Rufus::Scheduler.new
167
- @job = @scheduler.every @timeframe do
170
+ @job = @scheduler.schedule_every @timeframe do
168
171
  @logger.debug("Scheduler Activated")
169
172
  publish(aggregate({}))
170
173
  end
171
174
  end # def register
172
175
 
176
+ # Rufus::Scheduler >= 3.4 moved the Time impl into a gem EoTime = ::EtOrbi::EoTime`
177
+ # Rufus::Scheduler 3.1 - 3.3 using it's own Time impl `Rufus::Scheduler::ZoTime`
178
+ RufusTimeImpl = defined?(Rufus::Scheduler::EoTime) ? Rufus::Scheduler::EoTime :
179
+ (defined?(Rufus::Scheduler::ZoTime) ? Rufus::Scheduler::ZoTime : ::Time)
180
+
173
181
  public
174
182
  def receive(event)
175
183
  return unless (event.get(@field_metricname) || @metricname)
176
184
 
177
185
  if (@event_queue.length >= @event_queue.max)
178
- @job.trigger
186
+ @job.trigger RufusTimeImpl.now
179
187
  @logger.warn("Posted to AWS CloudWatch ahead of schedule. If you see this often, consider increasing the cloudwatch queue_size option.")
180
188
  end
181
189
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-cloudwatch'
4
- s.version = '3.0.9'
4
+ s.version = '3.0.10'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Aggregates and sends metric data to AWS CloudWatch"
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"
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  # Gem dependencies
23
23
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
24
  s.add_runtime_dependency 'logstash-mixin-aws', '>= 1.0.0'
25
- s.add_runtime_dependency 'rufus-scheduler', [ '~> 3.0.9' ]
25
+ s.add_runtime_dependency 'rufus-scheduler', '>= 3.0.9'
26
26
 
27
27
  s.add_development_dependency 'logstash-devutils'
28
28
  end
@@ -1,18 +1,38 @@
1
1
  require "logstash/devutils/rspec/spec_helper"
2
- require "logstash/plugin"
3
- require "logstash/json"
2
+ require "logstash/outputs/cloudwatch"
4
3
 
5
4
  describe "outputs/cloudwatch" do
6
5
 
6
+ let(:config) { { 'metricname' => 'foo' } }
7
7
 
8
- output = LogStash::Plugin.lookup("output", "cloudwatch").new
8
+ subject(:plugin) { LogStash::Outputs::CloudWatch.new(config) }
9
9
 
10
10
  it "should register" do
11
- expect {output.register}.to_not raise_error
11
+ expect { plugin.register }.to_not raise_error
12
12
  end
13
13
 
14
14
  it "should respond correctly to a receive call" do
15
+ plugin.register
15
16
  event = LogStash::Event.new
16
- expect { output.receive(event) }.to_not raise_error
17
+ expect { plugin.receive(event) }.to_not raise_error
18
+ end
19
+
20
+ context 'with queue_size' do
21
+
22
+ let(:queue_size) { 100 }
23
+
24
+ let(:config) { super().merge('queue_size' => queue_size) }
25
+
26
+ it "triggers job ahead of time" do
27
+ plugin.register
28
+ event_queue = plugin.event_queue
29
+ allow( event_queue ).to receive(:length).and_return queue_size # emulate full queue
30
+ expect( plugin ).to receive(:publish)
31
+
32
+ event = LogStash::Event.new
33
+ plugin.receive(event)
34
+ sleep 1.0 # allow scheduler to kick in
35
+ end
36
+
17
37
  end
18
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-cloudwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.9
4
+ version: 3.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -47,7 +47,7 @@ dependencies:
47
47
  - !ruby/object:Gem::Dependency
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - "~>"
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 3.0.9
53
53
  name: rufus-scheduler
@@ -55,7 +55,7 @@ dependencies:
55
55
  type: :runtime
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 3.0.9
61
61
  - !ruby/object:Gem::Dependency
@@ -111,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.6.13
114
+ rubygems_version: 3.1.6
116
115
  signing_key:
117
116
  specification_version: 4
118
117
  summary: Aggregates and sends metric data to AWS CloudWatch