riemann-tools 1.7.1 → 1.8.1

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: 9fa44263a952846fc5cc62c61b6ffec769d0be379f28acb4e93b4daf3e0837bb
4
- data.tar.gz: 1efb518984161d6ffa35d1f73ac54bfa2d4f95096c2b854ea1a7fb32f5e5394c
3
+ metadata.gz: fa9747ae11420451d621eac1f337dc543d3ee395cfde545ca1b819070ad0caef
4
+ data.tar.gz: f7d3b2a6493bcf478778a517f57a46179659e6c8b49bbe73c2769a82de3dbf8d
5
5
  SHA512:
6
- metadata.gz: 5dc1d992536ac76647acf1777139b8c793df76e3d7373f3f86f40f2de54d551d0eca5d5703f9a4a0986bedb05af0b0256bd888a518be90eeb75b6a09112c1c1f
7
- data.tar.gz: 66f578a6b3b39602800345693699a0653e86fd169ff622dcce17e651f1ba8ca945ced131d6b1e65264aa7d6ac13b2c0b94effcacb7820fd39f697b1bd855e1af
6
+ metadata.gz: 70855a5ff26bf7f02a35f80a86348ba3401db6576c6e7b97fa900c5ae134c6d4f4d066a1a6455c83a268442fb38b4a6ed36fae70d1aad3f759db9de97e1aa8fd
7
+ data.tar.gz: f9658262416652b5844b2f9b25d507e200da60b28ec50d6b8d56c1889b820e0c97457b79faf8feb19eaf7f40f8edb23ebc29676f49a078a478b1e78cc943c6a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.8.1](https://github.com/riemann/riemann-tools/tree/v1.8.1) (2023-02-27)
4
+
5
+ [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.8.0...v1.8.1)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Improve event sending thread lifecycle management [\#265](https://github.com/riemann/riemann-tools/pull/265) ([smortex](https://github.com/smortex))
10
+ - Make sure all events are send before terminating [\#264](https://github.com/riemann/riemann-tools/pull/264) ([smortex](https://github.com/smortex))
11
+
12
+ ## [v1.8.0](https://github.com/riemann/riemann-tools/tree/v1.8.0) (2023-02-02)
13
+
14
+ [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.7.1...v1.8.0)
15
+
16
+ **Implemented enhancements:**
17
+
18
+ - Send events in bulk when they are stacking [\#261](https://github.com/riemann/riemann-tools/pull/261) ([smortex](https://github.com/smortex))
19
+
3
20
  ## [v1.7.1](https://github.com/riemann/riemann-tools/tree/v1.7.1) (2023-01-12)
4
21
 
5
22
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.7.0...v1.7.1)
@@ -378,7 +395,7 @@
378
395
 
379
396
  **Merged pull requests:**
380
397
 
381
- - Update FreeBSD load average for 1 min [\#79](https://github.com/riemann/riemann-tools/pull/79) ([xaque208](https://github.com/xaque208))
398
+ - Update FreeBSD load average for 1 min [\#79](https://github.com/riemann/riemann-tools/pull/79) ([zachfi](https://github.com/zachfi))
382
399
  - Added riemann-varnish collector script [\#77](https://github.com/riemann/riemann-tools/pull/77) ([pradeepchhetri](https://github.com/pradeepchhetri))
383
400
  - allow dashes in diskstats volume names to support lvm volumes like "dm-0" [\#75](https://github.com/riemann/riemann-tools/pull/75) ([cmerrick](https://github.com/cmerrick))
384
401
  - rieman-tools aws billing [\#74](https://github.com/riemann/riemann-tools/pull/74) ([jespada](https://github.com/jespada))
@@ -7,36 +7,65 @@ require 'riemann/client'
7
7
  module Riemann
8
8
  module Tools
9
9
  class RiemannClientWrapper
10
- include Singleton
10
+ attr_reader :options
11
11
 
12
- def initialize
13
- @client = nil
12
+ def initialize(options)
13
+ @options = options
14
+
15
+ @queue = Queue.new
16
+ @max_bulk_size = 1000
17
+ @draining = false
18
+
19
+ @worker = Thread.new do
20
+ Thread.current.abort_on_exception = true
21
+ loop do
22
+ events = []
23
+
24
+ events << @queue.pop
25
+ events << @queue.pop while !@queue.empty? && events.size < @max_bulk_size
26
+
27
+ client.bulk_send(events)
28
+ rescue Riemann::Client::Error => e
29
+ warn "Dropping #{events.size} event#{'s' if events.size > 1} due to #{e}"
30
+ rescue StandardError => e
31
+ warn "#{e.class} #{e}\n#{e.backtrace.join "\n"}"
32
+ Thread.main.terminate
33
+ end
34
+ end
35
+
36
+ at_exit { drain }
14
37
  end
15
38
 
16
- def configure(options)
17
- return self unless @client.nil?
18
-
19
- r = Riemann::Client.new(
20
- host: options[:host],
21
- port: options[:port],
22
- timeout: options[:timeout],
23
- ssl: options[:tls],
24
- key_file: options[:tls_key],
25
- cert_file: options[:tls_cert],
26
- ca_file: options[:tls_ca_cert],
27
- ssl_verify: options[:tls_verify],
28
- )
29
-
30
- @client = if options[:tcp] || options[:tls]
31
- r.tcp
32
- else
33
- r
34
- end
35
- self
39
+ def client
40
+ @client ||= begin
41
+ r = Riemann::Client.new(
42
+ host: options[:host],
43
+ port: options[:port],
44
+ timeout: options[:timeout],
45
+ ssl: options[:tls],
46
+ key_file: options[:tls_key],
47
+ cert_file: options[:tls_cert],
48
+ ca_file: options[:tls_ca_cert],
49
+ ssl_verify: options[:tls_verify],
50
+ )
51
+
52
+ if options[:tcp] || options[:tls]
53
+ r.tcp
54
+ else
55
+ r
56
+ end
57
+ end
36
58
  end
37
59
 
38
60
  def <<(event)
39
- @client << event
61
+ raise('Cannot queue events when draining') if @draining
62
+
63
+ @queue << event
64
+ end
65
+
66
+ def drain
67
+ @draining = true
68
+ sleep(1) until @queue.empty? || @worker.stop?
40
69
  end
41
70
  end
42
71
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.6.2
3
+ # This file is automatically generated by Racc 1.6.0
4
4
  # from Racc grammar file "".
5
5
  #
6
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
- VERSION = '1.7.1'
5
+ VERSION = '1.8.1'
6
6
  end
7
7
  end
data/lib/riemann/tools.rb CHANGED
@@ -73,7 +73,7 @@ module Riemann
73
73
  end
74
74
 
75
75
  def riemann
76
- @riemann ||= RiemannClientWrapper.instance.configure(options)
76
+ @riemann ||= RiemannClientWrapper.new(options)
77
77
  end
78
78
  alias r riemann
79
79
 
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
39
39
 
40
40
  spec.add_runtime_dependency 'json', '>= 1.8'
41
41
  spec.add_runtime_dependency 'optimist', '~> 3.0', '>= 3.0.0'
42
- spec.add_runtime_dependency 'riemann-client', '~> 1.0'
42
+ spec.add_runtime_dependency 'riemann-client', '~> 1.1'
43
43
 
44
44
  spec.add_development_dependency 'github_changelog_generator'
45
45
  spec.add_development_dependency 'racc'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-12 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.0'
53
+ version: '1.1'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.0'
60
+ version: '1.1'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: github_changelog_generator
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -352,7 +352,7 @@ metadata:
352
352
  homepage_uri: https://github.com/aphyr/riemann-tools
353
353
  source_code_uri: https://github.com/aphyr/riemann-tools
354
354
  changelog_uri: https://github.com/aphyr/riemann-tools
355
- post_install_message:
355
+ post_install_message:
356
356
  rdoc_options: []
357
357
  require_paths:
358
358
  - lib
@@ -367,8 +367,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  - !ruby/object:Gem::Version
368
368
  version: '0'
369
369
  requirements: []
370
- rubygems_version: 3.2.5
371
- signing_key:
370
+ rubygems_version: 3.4.5
371
+ signing_key:
372
372
  specification_version: 4
373
373
  summary: Utilities which submit events to Riemann.
374
374
  test_files: []