honeykiq 1.0.0 → 1.1.0.pre

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: d5da094ed5b07d9c5b4c514370e14e641c4d88d7cd65d80afab77d3e18d5b0f1
4
- data.tar.gz: 4abbc53f3905305b7322d4441cdbbf72f9a707fe525a84c27ccf5c79a1d0ff80
3
+ metadata.gz: 52c98d7685025080d69c27b4639144cbb78c1f5405a3fb440652e3836252557c
4
+ data.tar.gz: 1d792568a79281e6f41f3a92e4d3e060ba73b473e0d0baa3195befdafaf55438
5
5
  SHA512:
6
- metadata.gz: 9c6421a534757c3fbe8b6a59bf6b58fcfd95b12ee3b7ee927ceb58915ccce96bb13f04f8bb4de7f8dbb6569ddcfd9de710c42d00e1a618906b37586b5b2f6735
7
- data.tar.gz: 176758798b49ba340ea658f0b82e2c2cdf57fd1d19d5ab14bccdabe939c9d5bc3eacea0d8c4e7093434435129231cbf830262f07bb56aa4e66762c8f80fe4486
6
+ metadata.gz: 3a4fbae5b7c9c60678ce677be5388f5887691e577f3a219a4280b533330e8fec03c689c8de0856b75c781dbad3181ee9c0469af79e09ee72dce9a8b25770f177
7
+ data.tar.gz: 6f26f2a3b1e836f800be3f2fca13a9da1199875551b3c717c0297dcda5e2f7e51a8a0a6518a40a2e664bff256d2e8d51a06574563a6f401a3f70023fd585808f
data/.circleci/config.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ruby: &ruby
2
- image: carwow/ruby-ci:2.5.3
2
+ image: carwow/ruby-ci:2.6
3
3
 
4
4
  version: 2
5
5
 
data/Gemfile.lock CHANGED
@@ -1,84 +1,94 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeykiq (1.0.0)
4
+ honeykiq (1.1.0.pre)
5
5
  sidekiq
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
12
  ast (2.4.0)
13
- carwow_rubocop (2.1.1)
14
- rubocop (~> 0.58)
15
- rubocop-rspec (~> 1.28)
13
+ carwow_rubocop (3.2.2)
14
+ rubocop (>= 0.78)
15
+ rubocop-performance
16
+ rubocop-rspec
16
17
  coderay (1.1.2)
17
18
  connection_pool (2.2.2)
18
19
  diff-lcs (1.3)
19
- domain_name (0.5.20180417)
20
+ domain_name (0.5.20190701)
20
21
  unf (>= 0.0.5, < 1.0.0)
21
- http (3.3.0)
22
+ ffi (1.12.2)
23
+ ffi-compiler (1.0.1)
24
+ ffi (>= 1.0.0)
25
+ rake
26
+ honeycomb-beeline (2.0.0)
27
+ libhoney (~> 1.14, >= 1.14.2)
28
+ http (4.4.1)
22
29
  addressable (~> 2.3)
23
30
  http-cookie (~> 1.0)
24
- http-form_data (~> 2.0)
25
- http_parser.rb (~> 0.6.0)
31
+ http-form_data (~> 2.2)
32
+ http-parser (~> 1.2.0)
26
33
  http-cookie (1.0.3)
27
34
  domain_name (~> 0.5)
28
- http-form_data (2.1.1)
29
- http_parser.rb (0.6.0)
30
- jaro_winkler (1.5.1)
31
- libhoney (1.11.0)
35
+ http-form_data (2.3.0)
36
+ http-parser (1.2.1)
37
+ ffi-compiler (>= 1.0, < 2.0)
38
+ jaro_winkler (1.5.4)
39
+ libhoney (1.14.4)
32
40
  addressable (~> 2.0)
33
- http (>= 2.0, < 4.0)
34
- method_source (0.9.2)
35
- parallel (1.12.1)
36
- parser (2.5.3.0)
41
+ http (>= 2.0, < 5.0)
42
+ method_source (1.0.0)
43
+ parallel (1.19.1)
44
+ parser (2.7.1.2)
37
45
  ast (~> 2.4.0)
38
- powerpack (0.1.2)
39
- pry (0.12.2)
40
- coderay (~> 1.1.0)
41
- method_source (~> 0.9.0)
42
- public_suffix (3.0.3)
46
+ pry (0.13.1)
47
+ coderay (~> 1.1)
48
+ method_source (~> 1.0)
49
+ public_suffix (4.0.5)
43
50
  rack (2.2.2)
44
51
  rack-protection (2.0.8.1)
45
52
  rack
46
53
  rainbow (3.0.0)
47
54
  rake (13.0.1)
48
- redis (4.1.3)
49
- rspec (3.8.0)
50
- rspec-core (~> 3.8.0)
51
- rspec-expectations (~> 3.8.0)
52
- rspec-mocks (~> 3.8.0)
53
- rspec-core (3.8.0)
54
- rspec-support (~> 3.8.0)
55
- rspec-expectations (3.8.2)
55
+ redis (4.1.4)
56
+ rexml (3.2.4)
57
+ rspec (3.9.0)
58
+ rspec-core (~> 3.9.0)
59
+ rspec-expectations (~> 3.9.0)
60
+ rspec-mocks (~> 3.9.0)
61
+ rspec-core (3.9.2)
62
+ rspec-support (~> 3.9.3)
63
+ rspec-expectations (3.9.2)
56
64
  diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.8.0)
58
- rspec-mocks (3.8.0)
65
+ rspec-support (~> 3.9.0)
66
+ rspec-mocks (3.9.1)
59
67
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.8.0)
61
- rspec-support (3.8.0)
62
- rubocop (0.61.1)
68
+ rspec-support (~> 3.9.0)
69
+ rspec-support (3.9.3)
70
+ rubocop (0.82.0)
63
71
  jaro_winkler (~> 1.5.1)
64
72
  parallel (~> 1.10)
65
- parser (>= 2.5, != 2.5.1.1)
66
- powerpack (~> 0.1)
73
+ parser (>= 2.7.0.1)
67
74
  rainbow (>= 2.2.2, < 4.0)
75
+ rexml
68
76
  ruby-progressbar (~> 1.7)
69
- unicode-display_width (~> 1.4.0)
70
- rubocop-rspec (1.30.1)
71
- rubocop (>= 0.60.0)
72
- ruby-progressbar (1.10.0)
73
- sidekiq (6.0.5)
77
+ unicode-display_width (>= 1.4.0, < 2.0)
78
+ rubocop-performance (1.5.2)
79
+ rubocop (>= 0.71.0)
80
+ rubocop-rspec (1.39.0)
81
+ rubocop (>= 0.68.1)
82
+ ruby-progressbar (1.10.1)
83
+ sidekiq (6.0.7)
74
84
  connection_pool (>= 2.2.2)
75
85
  rack (~> 2.0)
76
86
  rack-protection (>= 2.0.0)
77
87
  redis (>= 4.1.0)
78
88
  unf (0.1.4)
79
89
  unf_ext
80
- unf_ext (0.0.7.5)
81
- unicode-display_width (1.4.0)
90
+ unf_ext (0.0.7.7)
91
+ unicode-display_width (1.7.0)
82
92
 
83
93
  PLATFORMS
84
94
  ruby
@@ -86,11 +96,11 @@ PLATFORMS
86
96
  DEPENDENCIES
87
97
  bundler
88
98
  carwow_rubocop
99
+ honeycomb-beeline
89
100
  honeykiq!
90
- libhoney
91
101
  pry
92
102
  rake
93
103
  rspec
94
104
 
95
105
  BUNDLED WITH
96
- 1.17.2
106
+ 2.1.4
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Sidekiq → Honeycomb 🐝
4
4
 
5
- Send [Sidekiq](https://sidekiq.org)-related events to [Honeycomb](https://www.honeycomb.io).
5
+ Send [Sidekiq](https://sidekiq.org)-related events to
6
+ [Honeycomb](https://www.honeycomb.io).
6
7
 
7
8
  ## Installation
8
9
 
@@ -24,11 +25,25 @@ The library provides two use cases:
24
25
 
25
26
  ### Honeykiq::ServerMiddleware
26
27
 
27
- Add Honeykiq to your Sidekiq server middleware chain, and pass a [`Libhoney::Client`][libhoney] as shown below. It will send an event to Honeycomb once a job finishes or fails. Have a look at [server_middleware.rb] to see what kind of information we send.
28
+ Add Honeykiq to your Sidekiq server middleware chain. It will send an event to
29
+ Honeycomb once a job finishes or fails. Have a look at [server_middleware.rb]
30
+ to see what kind of information it sends.
28
31
 
29
32
  [server_middleware.rb]: https://github.com/carwow/honeykiq/blob/master/lib/honeykiq/server_middleware.rb
30
33
 
31
34
  ```ruby
35
+ # Configure Honeycomb and add the middleware to Sidekiq chain
36
+ Honeycomb.configure do |config|
37
+ config.writekey = ENV.fetch('HONEYCOMB_WRITE_KEY')
38
+ config.dataset = ENV.fetch('HONEYCOMB_DATASET')
39
+ end
40
+ Sidekiq.configure_server do |config|
41
+ config.server_middleware do |chain|
42
+ chain.add Honeykiq::ServerMiddleware
43
+ end
44
+ end
45
+
46
+ # Or pass the libhoney client to the middleware
32
47
  Sidekiq.configure_server do |config|
33
48
  config.server_middleware do |chain|
34
49
  chain.add Honeykiq::ServerMiddleware,
@@ -40,7 +55,10 @@ Sidekiq.configure_server do |config|
40
55
  end
41
56
  ```
42
57
 
43
- You can add your own data or functions to the Honeycomb event by subclassing `Honeykiq::ServerMiddleware`, and overriding the the `extra_fields` method with your own hash. The contents will be serialized into individual items in the event:
58
+ You can add your own data or functions to the Honeycomb event by subclassing
59
+ `Honeykiq::ServerMiddleware`, and overriding the the `extra_fields` method with
60
+ your own hash. The contents will be serialized into individual items in the
61
+ event:
44
62
 
45
63
  ```ruby
46
64
  class MyServerMiddleware < Honeykiq::ServerMiddleware
@@ -58,13 +76,23 @@ Sidekiq.configure_server do |config|
58
76
  ...
59
77
  ```
60
78
 
61
- **Note:** If you have long running jobs, an event is only sent to Honeycomb when the job finishes. Therefore, it may appear as though no jobs are currently running. Additionally, if the process receives a `SIGKILL` then no event is sent about that job, and the job may keep retrying without appearing in Honeycomb. The `PeriodicReporter` should help with this, but we are thinking of a nicer approach.
79
+ **Note:** If you have long running jobs, an event is only sent to Honeycomb
80
+ when the job finishes. Therefore, it may appear as though no jobs are currently
81
+ running. Additionally, if the process receives a `SIGKILL` then no event is
82
+ sent about that job, and the job may keep retrying without appearing in
83
+ Honeycomb. The `PeriodicReporter` should help with this, but we are thinking of
84
+ a nicer approach.
62
85
 
63
86
  ### Honeykiq::PeriodicReporter
64
87
 
65
- The periodic reporter should be scheduled to report every few seconds, depending on your use case. Every time the `#report` method is called it will send a total of `1 + P + Q` events to Honeycomb where `P` and `Q` are the number of processes and queues respectively.
88
+ The periodic reporter should be scheduled to report every few seconds,
89
+ depending on your use case. Every time the `#report` method is called it will
90
+ send a total of `1 + P + Q` events to Honeycomb where `P` and `Q` are the
91
+ number of processes and queues respectively.
66
92
 
67
- It sends three types of events: `instance`, `process`, and `queue`. Have a look at [periodic_reporter.rb] to see what kind of information we send for each type.
93
+ It sends three types of events: `instance`, `process`, and `queue`. Have a look
94
+ at [periodic_reporter.rb] to see what kind of information we send for each
95
+ type.
68
96
 
69
97
  [periodic_reporter.rb]: https://github.com/carwow/honeykiq/blob/master/lib/honeykiq/periodic_reporter.rb
70
98
 
@@ -110,5 +138,4 @@ Please report bugs in a [new issue](https://github.com/carwow/honeykiq/issues/ne
110
138
 
111
139
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
112
140
 
113
- [libhoney]: https://github.com/honeycombio/libhoney-rb
114
141
  [clockwork]: https://github.com/Rykian/clockwork
data/honeykiq.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency 'bundler'
30
30
  spec.add_development_dependency 'carwow_rubocop'
31
- spec.add_development_dependency 'libhoney'
31
+ spec.add_development_dependency 'honeycomb-beeline'
32
32
  spec.add_development_dependency 'pry'
33
33
  spec.add_development_dependency 'rake'
34
34
  spec.add_development_dependency 'rspec'
@@ -3,20 +3,20 @@ require 'sidekiq/api'
3
3
  module Honeykiq
4
4
  class ServerMiddleware
5
5
  def initialize(options = {})
6
- @honey_client = options.fetch(:honey_client)
6
+ @honey_client = options[:honey_client]
7
7
  end
8
8
 
9
9
  def call(_worker, msg, queue_name)
10
- event = @honey_client.event
10
+ job = Sidekiq::Job.new(msg, queue_name)
11
11
 
12
- call_event(event, msg, queue_name) { yield }
13
- rescue StandardError => error
14
- event&.add_field(:'job.status', 'failed')
15
- event&.add(error_info(error))
16
- raise
17
- ensure
18
- event&.add(extra_fields)
19
- event&.send
12
+ start_span(name: job.display_class) do |event|
13
+ call_with_event(event, job, queue_name) { yield }
14
+ rescue StandardError => error
15
+ on_error(event, error)
16
+ raise
17
+ ensure
18
+ event&.add(extra_fields)
19
+ end
20
20
  end
21
21
 
22
22
  def extra_fields
@@ -25,16 +25,28 @@ module Honeykiq
25
25
 
26
26
  private
27
27
 
28
- def call_event(event, msg, queue_name)
29
- event.add(default_fields(msg, queue_name))
30
- duration_ms(event) { yield }
28
+ def start_span(name:)
29
+ if @honey_client
30
+ @honey_client.event.tap do |event|
31
+ duration_ms(event) { yield event }
32
+ ensure
33
+ event.send
34
+ end
35
+ else
36
+ Honeycomb.start_span(name: name) { |event| yield event }
37
+ end
38
+ end
39
+
40
+ def call_with_event(event, job, queue_name)
41
+ event.add(default_fields(job, queue_name))
42
+ yield
31
43
  event.add_field(:'job.status', 'finished')
32
44
  end
33
45
 
34
- def default_fields(msg, queue_name)
46
+ def default_fields(job, queue_name)
35
47
  {
36
48
  type: :job,
37
- **job_fields(Sidekiq::Job.new(msg, queue_name)),
49
+ **job_fields(job),
38
50
  **queue_fields(Sidekiq::Queue.new(queue_name)),
39
51
  'meta.thread_id': Thread.current.object_id
40
52
  }
@@ -66,8 +78,16 @@ module Honeykiq
66
78
  event.add_field(:duration_ms, duration * 1000)
67
79
  end
68
80
 
69
- def error_info(error)
70
- { 'error.class': error.class.name, 'error.message': error.message }
81
+ def on_error(event, error)
82
+ return unless event
83
+
84
+ event.add_field(:'job.status', 'failed')
85
+ return unless @honey_client
86
+
87
+ event.add(
88
+ 'error.class': error.class.name,
89
+ 'error.message': error.message
90
+ )
71
91
  end
72
92
  end
73
93
  end
@@ -1,3 +1,3 @@
1
1
  module Honeykiq
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0.pre'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeykiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - carwow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-09 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: libhoney
56
+ name: honeycomb-beeline
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -148,12 +148,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - ">"
152
152
  - !ruby/object:Gem::Version
153
- version: '0'
153
+ version: 1.3.1
154
154
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.6
155
+ rubygems_version: 3.1.2
157
156
  signing_key:
158
157
  specification_version: 4
159
158
  summary: "Sidekiq → Honeycomb \U0001F41D"