riemann-tools 1.8.0 → 1.8.2

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: e19bf35e435918b5107c15cbcaabbe6da5c707e771dead6f971f38babe6967c7
4
- data.tar.gz: fab496cdc89a6fdfa45b5740189b09d23dc3014d47a2e4fc889e19464eb365f8
3
+ metadata.gz: 4332ce7f616ae97148796f5563e9d1920e104da9f22ce5fade96204a46e83538
4
+ data.tar.gz: 4a84364a07bba6d111d124491ac65bf310075cf439fac30717c9aa5f95f0b68c
5
5
  SHA512:
6
- metadata.gz: d0f40cd275ad0e71191bd021d16bc197be89b3ef869bd2ac3e0734b5444e89abb1e4db1976dffcb9911d567f24be17d2fd4103e85098866152fa5a4cd426f2cf
7
- data.tar.gz: e141ca404e46fd6e4a95030dade5f0062ed670a191ed03022d1cfcab607ab46579c32dc75e80ea8ddaed3799477869dceaab44d5685dfbe91b17d906cdd1dc63
6
+ metadata.gz: 9791c57e10683c4509f08a75ef454545bf90fc3ab33a852c2797b302937a6d17aeb2ce19de6e4f1ee91d99291f442c5ac06e019cf8d893718487c70645a431e7
7
+ data.tar.gz: 7ab5ebb5ede098d648ff78033bac1b0743f99a98fb8a68a9898e70a2e7f29d60901b089f905c4b7afa2e32c50bdab025e68df7d2b6bc0c9c3806733ebcd8693c
@@ -5,7 +5,14 @@
5
5
 
6
6
  version: 2
7
7
  updates:
8
+ # Open PR for gem updates
8
9
  - package-ecosystem: "bundler" # See documentation for possible values
9
10
  directory: "/" # Location of package manifests
10
11
  schedule:
11
12
  interval: "daily"
13
+
14
+ # Open PR for GitHub Actions updates
15
+ - package-ecosystem: "github-actions"
16
+ directory: "/"
17
+ schedule:
18
+ interval: "daily"
data/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ## [v1.8.0](https://github.com/riemann/riemann-tools/tree/v1.8.0) (2023-02-01)
3
+ ## [v1.8.2](https://github.com/riemann/riemann-tools/tree/v1.8.2) (2023-05-22)
4
+
5
+ [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.8.1...v1.8.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Gracefully handle all communication errors [\#268](https://github.com/riemann/riemann-tools/pull/268) ([smortex](https://github.com/smortex))
10
+
11
+ ## [v1.8.1](https://github.com/riemann/riemann-tools/tree/v1.8.1) (2023-02-28)
12
+
13
+ [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.8.0...v1.8.1)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Improve event sending thread lifecycle management [\#265](https://github.com/riemann/riemann-tools/pull/265) ([smortex](https://github.com/smortex))
18
+ - Make sure all events are send before terminating [\#264](https://github.com/riemann/riemann-tools/pull/264) ([smortex](https://github.com/smortex))
19
+
20
+ ## [v1.8.0](https://github.com/riemann/riemann-tools/tree/v1.8.0) (2023-02-02)
4
21
 
5
22
  [Full Changelog](https://github.com/riemann/riemann-tools/compare/v1.7.1...v1.8.0)
6
23
 
@@ -7,52 +7,63 @@ require 'riemann/client'
7
7
  module Riemann
8
8
  module Tools
9
9
  class RiemannClientWrapper
10
- include Singleton
10
+ attr_reader :options
11
+
12
+ def initialize(options)
13
+ @options = options
11
14
 
12
- def initialize
13
- @client = nil
14
15
  @queue = Queue.new
15
16
  @max_bulk_size = 1000
16
- end
17
-
18
- def configure(options)
19
- return self unless @client.nil?
20
-
21
- r = Riemann::Client.new(
22
- host: options[:host],
23
- port: options[:port],
24
- timeout: options[:timeout],
25
- ssl: options[:tls],
26
- key_file: options[:tls_key],
27
- cert_file: options[:tls_cert],
28
- ca_file: options[:tls_ca_cert],
29
- ssl_verify: options[:tls_verify],
30
- )
31
-
32
- @client = if options[:tcp] || options[:tls]
33
- r.tcp
34
- else
35
- r
36
- end
17
+ @draining = false
37
18
 
38
19
  @worker = Thread.new do
20
+ Thread.current.abort_on_exception = true
39
21
  loop do
40
22
  events = []
41
23
 
42
24
  events << @queue.pop
43
25
  events << @queue.pop while !@queue.empty? && events.size < @max_bulk_size
44
26
 
45
- @client.bulk_send(events)
27
+ client.bulk_send(events)
28
+ rescue StandardError => e
29
+ warn "Dropping #{events.size} event#{'s' if events.size > 1} due to #{e}"
46
30
  end
47
31
  end
48
- @worker.abort_on_exception = true
49
32
 
50
- self
33
+ at_exit { drain }
34
+ end
35
+
36
+ def client
37
+ @client ||= begin
38
+ r = Riemann::Client.new(
39
+ host: options[:host],
40
+ port: options[:port],
41
+ timeout: options[:timeout],
42
+ ssl: options[:tls],
43
+ key_file: options[:tls_key],
44
+ cert_file: options[:tls_cert],
45
+ ca_file: options[:tls_ca_cert],
46
+ ssl_verify: options[:tls_verify],
47
+ )
48
+
49
+ if options[:tcp] || options[:tls]
50
+ r.tcp
51
+ else
52
+ r
53
+ end
54
+ end
51
55
  end
52
56
 
53
57
  def <<(event)
58
+ raise('Cannot queue events when draining') if @draining
59
+
54
60
  @queue << event
55
61
  end
62
+
63
+ def drain
64
+ @draining = true
65
+ sleep(1) until @queue.empty? || @worker.stop?
66
+ end
56
67
  end
57
68
  end
58
69
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
- VERSION = '1.8.0'
5
+ VERSION = '1.8.2'
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
 
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.8.0
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-02 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  - !ruby/object:Gem::Version
368
368
  version: '0'
369
369
  requirements: []
370
- rubygems_version: 3.4.2
370
+ rubygems_version: 3.4.12
371
371
  signing_key:
372
372
  specification_version: 4
373
373
  summary: Utilities which submit events to Riemann.