sidekiq-haron 0.1.0 → 0.1.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 +4 -4
- data/.gitignore +1 -0
- data/README.md +39 -5
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sidekiq/haron.rb +8 -1
- data/lib/sidekiq/haron/exception_logger.rb +1 -0
- data/lib/sidekiq/haron/version.rb +1 -1
- data/sidekiq-haron.gemspec +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8013e20dadb47994367e66c8bdbed92b6a0abf8d571d3bc6b7071d511dfe82b5
|
4
|
+
data.tar.gz: c6a9d958fb78125df046ad404093b3f41cde5fe5401a2dfc9a2cef79dc572779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e265582b9f338f7e2ef4c1ba206130b6759544a0b0ecc009ebb3b5154c6389458f7aa61b94bbac9e3b7f1d0febde08d45551ac06bf5d4289cdec398ae5e188
|
7
|
+
data.tar.gz: 631c33cbbbc9ecfb9f6f72ebe29b74ac040ed0c99f500a62e4e38ac1b7e1f37bd79edaf424ee2d78144f31d5f8efece27f4401b8245d8091b6e82a0fab7faf4f
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Sidekiq::Haron
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging job args. Example request_id or other request info.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,43 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Аdd to project class inheriting from `Sidekiq::Haron::Transmitter` like this:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class HaronTransmitter < Sidekiq::Haron::Transmitter
|
27
|
+
|
28
|
+
def saved_data *args
|
29
|
+
{
|
30
|
+
request_id: Current.request_id,
|
31
|
+
parent_request_id: Current.parent_request_id
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_data hash
|
36
|
+
Current.request_id = hash['request_id'].presence || SecureRandom.hex
|
37
|
+
Current.parent_request_id = hash['parent_request_id']
|
38
|
+
end
|
39
|
+
|
40
|
+
def tags
|
41
|
+
[Current.parent_request_id]
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Аdd to `config/initializers/sidekiq.rb`:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
Sidekiq::Haron.install(HaronTransmitter)
|
51
|
+
```
|
52
|
+
|
53
|
+
Now all your sidekiq log have `Current.parent_request_id` value as tag and log job args too:
|
54
|
+
|
55
|
+
```
|
56
|
+
2020-01-14T14:22:09.035Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] with args [1, {"q"=>2}]
|
57
|
+
2020-01-14T14:22:09.035Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] start
|
58
|
+
2020-01-14T14:22:09.041Z TestWorker JID-940645f14b345b3b4031d1cc I: [4f445354] done: 0.006 sec
|
59
|
+
```
|
26
60
|
|
27
61
|
## Development
|
28
62
|
|
@@ -32,7 +66,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
66
|
|
33
67
|
## Contributing
|
34
68
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Rnd-Soft/sidekiq-haron.
|
36
70
|
|
37
71
|
## License
|
38
72
|
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tttt"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/sidekiq/haron.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'sidekiq'
|
1
2
|
require 'sidekiq/haron/formatter'
|
2
3
|
require 'sidekiq/haron/storage'
|
3
4
|
require 'sidekiq/haron/transmitter'
|
@@ -10,7 +11,13 @@ require 'sidekiq/haron/version'
|
|
10
11
|
module Sidekiq
|
11
12
|
module Haron
|
12
13
|
|
13
|
-
|
14
|
+
def self.transmitter
|
15
|
+
Sidekiq.options[:transmitter]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.transmitter= v
|
19
|
+
Sidekiq.options[:transmitter] = v
|
20
|
+
end
|
14
21
|
|
15
22
|
def self.install transmitter_class
|
16
23
|
Sidekiq::Haron.transmitter = transmitter_class.new
|
data/sidekiq-haron.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["wolferingys@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Transfer some data to sidekiq job and can tag sidekiq logs}
|
13
|
-
spec.description = %q{Transfer some
|
13
|
+
spec.description = %q{Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging job args}
|
14
14
|
spec.homepage = "https://github.com/Rnd-Soft/sidekiq-haron"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-haron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serg F
|
@@ -94,7 +94,8 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description: Transfer some
|
97
|
+
description: Transfer some metadata to sidekiq job, can tag sidekiq logs and add logging
|
98
|
+
job args
|
98
99
|
email:
|
99
100
|
- wolferingys@gmail.com
|
100
101
|
executables: []
|
@@ -107,6 +108,8 @@ files:
|
|
107
108
|
- LICENSE.txt
|
108
109
|
- README.md
|
109
110
|
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
110
113
|
- lib/sidekiq/haron.rb
|
111
114
|
- lib/sidekiq/haron/client_middleware.rb
|
112
115
|
- lib/sidekiq/haron/exception_logger.rb
|