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 +5 -5
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +10 -9
- data/README.md +22 -1
- data/lib/honeykiq/server_middleware.rb +13 -3
- data/lib/honeykiq/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bd68d2d6502122121c482fa34ed093f1d1e8fc55
|
4
|
+
data.tar.gz: c78a51adabd03fff9f7e17b140eaaca58a310cd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
17
|
-
[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.
|
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.
|
44
|
-
rack-protection (2.0.
|
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.
|
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 (
|
74
|
-
connection_pool (
|
75
|
-
rack
|
76
|
-
|
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.
|
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/
|
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
|
11
|
-
|
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
|
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)),
|
data/lib/honeykiq/version.rb
CHANGED
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.
|
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:
|
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.
|
154
|
+
rubygems_version: 2.6.14.1
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: "Sidekiq → Honeycomb \U0001F41D"
|