honeykiq 0.2.0 → 0.3.0

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
- SHA256:
3
- metadata.gz: 44fbbee328df450194663816c3f3cdb196970dfd8be5b9bcb547569255e44513
4
- data.tar.gz: cb8fbe2e9ab677c6f2aa360729b23f26de1b0c37a417057c142307850e260da3
2
+ SHA1:
3
+ metadata.gz: bd68d2d6502122121c482fa34ed093f1d1e8fc55
4
+ data.tar.gz: c78a51adabd03fff9f7e17b140eaaca58a310cd2
5
5
  SHA512:
6
- metadata.gz: 0e85c6f494daadd232009dec33a5fe616d058a1a7e69f04bd7fd124b2c96f7cec240cb4fc6a5df0c7a435087de101f7de0adedc13032276d69e2def17d4378bd
7
- data.tar.gz: 8d9bcfcdedd91ffa9d26b537e2fa38a44386053a172c67b44029742b795b6341f47568df28096035c6b24f9b12e517e3f88871502694559ba46805cc057a5780
6
+ metadata.gz: cb767053db59b6e3c568b9dba2059bb00d54c79c9fc6794148d81642a1cfcfee3bb27860a298218c620eaa739351bda563ecd56019eb7af68343381edc48905e
7
+ data.tar.gz: f2c2a102e62632209fe9e4c120700e53677a167ec1aeb0300cd5f162001c48b181a0f5cb59aea58648b09fcf1f6d134d254b721a34ecd0af6b419e6547a5573c
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.0]
10
+ ### Added
11
+ - `Honeykiq::ServerMiddleware#extra_fields` so you can add custom fields to an event
12
+
9
13
  ## [0.2.0]
10
14
  ### Added
11
15
  - `Honeykiq::ServerMiddleware` 🙌
@@ -13,5 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
17
  ### Removed
14
18
  - `Honeykiq.periodic_reporter`. (Use `Honeykiq::PeriodicReporter.new` instead.)
15
19
 
16
- [Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.2.0...HEAD
17
- [0.2.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...v0.2.0
20
+ [Unreleased]: https://github.com/carwow/honeykiq/compare/v0.3.0...HEAD
21
+ [0.3.0]: https://github.com/carwow/honeykiq/compare/v0.2.0...v0.3.0
22
+ [0.2.0]: https://github.com/carwow/honeykiq/compare/v0.1.0...v0.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeykiq (0.2.0)
4
+ honeykiq (0.3.0)
5
5
  sidekiq
6
6
 
7
7
  GEM
@@ -40,12 +40,12 @@ GEM
40
40
  coderay (~> 1.1.0)
41
41
  method_source (~> 0.9.0)
42
42
  public_suffix (3.0.3)
43
- rack (2.0.6)
44
- rack-protection (2.0.4)
43
+ rack (2.0.8)
44
+ rack-protection (2.0.8.1)
45
45
  rack
46
46
  rainbow (3.0.0)
47
47
  rake (12.3.2)
48
- redis (4.0.3)
48
+ redis (4.1.3)
49
49
  rspec (3.8.0)
50
50
  rspec-core (~> 3.8.0)
51
51
  rspec-expectations (~> 3.8.0)
@@ -70,10 +70,11 @@ GEM
70
70
  rubocop-rspec (1.30.1)
71
71
  rubocop (>= 0.60.0)
72
72
  ruby-progressbar (1.10.0)
73
- sidekiq (5.2.3)
74
- connection_pool (~> 2.2, >= 2.2.2)
75
- rack-protection (>= 1.5.0)
76
- redis (>= 3.3.5, < 5)
73
+ sidekiq (6.0.4)
74
+ connection_pool (>= 2.2.2)
75
+ rack (>= 2.0.0)
76
+ rack-protection (>= 2.0.0)
77
+ redis (>= 4.1.0)
77
78
  unf (0.1.4)
78
79
  unf_ext
79
80
  unf_ext (0.0.7.5)
@@ -92,4 +93,4 @@ DEPENDENCIES
92
93
  rspec
93
94
 
94
95
  BUNDLED WITH
95
- 1.17.1
96
+ 1.17.2
data/README.md CHANGED
@@ -42,6 +42,27 @@ Sidekiq.configure_server do |config|
42
42
  end
43
43
  ```
44
44
 
45
+ #### Adding extra data to events
46
+ You can add your own data or functions to the Honeycomb event by subclassing
47
+ `Honeykiq::ServerMiddleware` and overriding the the `extra_fields` method with your own
48
+ hash. These will be serialized into individual items in the event:
49
+
50
+ ```ruby
51
+ class MyServerMiddleware < Honeykiq::ServerMiddleware
52
+ def extra_fields
53
+ {
54
+ my_data: 'evaluated and added to the event after the job has finished/errored',
55
+ my_function: -> { Time.now }
56
+ }
57
+ end
58
+ end
59
+
60
+ Sidekiq.configure_server do |config|
61
+ config.server_middleware do |chain|
62
+ chain.add MyServerMiddleware, honey_client: ...
63
+ ...
64
+ ```
65
+
45
66
  **Note on long running jobs:** If you have long running jobs an event is only
46
67
  sent to Honeycomb when it finishes so it may appear as no jobs are running.
47
68
  Also if the process gets a SIGKILL then no event is sent about that job and the
@@ -62,7 +83,7 @@ It sends three types of events: instance, process, and queue. Have a look at
62
83
 
63
84
  A simple setup using [clockwork] would look like this:
64
85
 
65
- [clockwork]: https://github.com/adamwiggins/clockwork
86
+ [clockwork]: https://github.com/Rykian/clockwork
66
87
 
67
88
  ```ruby
68
89
  require 'clockwork'
@@ -7,8 +7,8 @@ module Honeykiq
7
7
  end
8
8
 
9
9
  def call(_worker, msg, queue_name)
10
- event = @honey_client.event.add(**all_fields(msg, queue_name))
11
- duration_ms(event) { yield }
10
+ event = @honey_client.event
11
+ run_with_hooks(event, msg, queue_name) { yield }
12
12
  event.add_field(:'job.status', 'finished')
13
13
  rescue StandardError => error
14
14
  event&.add_field(:'job.status', 'failed')
@@ -18,9 +18,19 @@ module Honeykiq
18
18
  event&.send
19
19
  end
20
20
 
21
+ def extra_fields
22
+ {}
23
+ end
24
+
21
25
  private
22
26
 
23
- def all_fields(msg, queue_name)
27
+ def run_with_hooks(event, msg, queue_name)
28
+ event.add(default_fields(msg, queue_name))
29
+ duration_ms(event) { yield }
30
+ event.add(extra_fields)
31
+ end
32
+
33
+ def default_fields(msg, queue_name)
24
34
  {
25
35
  type: :job,
26
36
  **job_fields(Sidekiq::Job.new(msg, queue_name)),
@@ -1,3 +1,3 @@
1
1
  module Honeykiq
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.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: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carwow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2020-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.7.6
154
+ rubygems_version: 2.6.14.1
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: "Sidekiq → Honeycomb \U0001F41D"