sidekiq-history 0.0.9 → 0.0.10
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/README.md +2 -2
- data/lib/sidekiq/history.rb +33 -10
- data/lib/sidekiq/history/middleware.rb +23 -22
- data/lib/sidekiq/history/version.rb +1 -1
- data/lib/sidekiq/history/web_extension.rb +1 -1
- data/web/views/history.erb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e960876faa26b6bc5144bf2651c229e9863f4c01
|
4
|
+
data.tar.gz: 41f8495091e1fa008ff9f19cf4165c0939544e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de904b6ec8eae8dc5416d00c09c07af70eb0e5288a15f05c0d5a6020d8e1522f967b0587566b8fde41d2ae8d65fc9c13616b76c86ef3ee22163fd241a24a5d61
|
7
|
+
data.tar.gz: 87d356426ec6ab4025880a983d0d02c6dd501914f9e103a560710da04588eff2f9fbfc11866fd6a66ed6ae4db2874063c4e84ea7a311449fe404d816187ef155
|
data/README.md
CHANGED
@@ -20,9 +20,9 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
Nothing left to do. Mount sidekiq, and go to the web interface. You'll see a shiny new History tab!
|
22
22
|
|
23
|
-
By default it will keep history on the last 1000 jobs. To change that set `Sidekiq
|
23
|
+
By default it will keep history on the last 1000 jobs. To change that set `Sidekiq.history_max_count = 10000`. Be careful because the data is persisted in Redis Sorted Set and it WILL take up RAM. Max possible value is 4294967295 per Redis limit.
|
24
24
|
|
25
|
-
If you want to only record history for specific jobs you can set `Sidekiq
|
25
|
+
If you want to only record history for specific jobs you can set `Sidekiq.history_exclude_jobs = ['OneJob']` (do not record for specified jobs) and `Sidekiq.history_include_jobs = ['AnotherJob']` (record ONLY jobs specified). INCLUDE will take precedence so if you set it to blank array nothing will be recorded.
|
26
26
|
|
27
27
|
## Screenshot
|
28
28
|
|
data/lib/sidekiq/history.rb
CHANGED
@@ -9,26 +9,51 @@ module Sidekiq
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.history_max_count
|
12
|
-
# => use default 1000 unless specified in config.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
# => use default 1000 unless specified in config.
|
13
|
+
# Max is 4294967295 per Redis Sorted Set limit
|
14
|
+
hmc = if defined? MAX_COUNT
|
15
|
+
[MAX_COUNT, 4_294_967_295].min
|
16
|
+
else
|
17
|
+
1000
|
18
|
+
end
|
18
19
|
return hmc if @history_max_count.nil?
|
19
20
|
@history_max_count
|
20
21
|
end
|
21
22
|
|
23
|
+
def self.history_exclude_jobs=(value)
|
24
|
+
@history_exclude_jobs = value
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.history_exclude_jobs
|
28
|
+
if defined? Sidekiq::History::Middleware::EXCLUDE_JOBS
|
29
|
+
jobs = Sidekiq::History::Middleware::EXCLUDE_JOBS
|
30
|
+
end
|
31
|
+
return jobs if @history_exclude_jobs.nil?
|
32
|
+
@history_exclude_jobs
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.history_include_jobs=(value)
|
36
|
+
@history_include_jobs = value
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.history_include_jobs
|
40
|
+
if defined? Sidekiq::History::Middleware::INCLUDE_JOBS
|
41
|
+
jobs = Sidekiq::History::Middleware::INCLUDE_JOBS
|
42
|
+
end
|
43
|
+
return jobs if @history_include_jobs.nil?
|
44
|
+
@history_include_jobs
|
45
|
+
end
|
46
|
+
|
22
47
|
module History
|
23
48
|
LIST_KEY = :history
|
24
49
|
|
25
50
|
def self.reset_history(options = {})
|
26
|
-
Sidekiq.redis
|
51
|
+
Sidekiq.redis do |c|
|
27
52
|
c.multi do
|
28
53
|
c.del(LIST_KEY)
|
29
54
|
c.set('stat:history', 0) if options[:counter] || options['counter']
|
30
55
|
end
|
31
|
-
|
56
|
+
end
|
32
57
|
end
|
33
58
|
|
34
59
|
def self.count
|
@@ -40,9 +65,7 @@ module Sidekiq
|
|
40
65
|
super LIST_KEY
|
41
66
|
end
|
42
67
|
end
|
43
|
-
|
44
68
|
end
|
45
|
-
|
46
69
|
end
|
47
70
|
|
48
71
|
Sidekiq.configure_server do |config|
|
@@ -7,14 +7,22 @@ module Sidekiq
|
|
7
7
|
|
8
8
|
attr_accessor :msg
|
9
9
|
|
10
|
-
def call(
|
10
|
+
def call(_worker, msg, queue)
|
11
11
|
self.msg = msg
|
12
|
-
|
12
|
+
|
13
|
+
# Use the Sidekiq API to unwrap the job
|
14
|
+
job = Sidekiq::Job.new(msg)
|
15
|
+
job_class = job.display_class
|
16
|
+
|
17
|
+
# Setup a unwraped copy of the bare job data
|
18
|
+
payload = msg.dup
|
19
|
+
payload['class'] = job_class
|
20
|
+
payload['args'] = job.display_args
|
13
21
|
|
14
22
|
data = {
|
15
23
|
started_at: Time.now.utc,
|
16
|
-
payload:
|
17
|
-
worker:
|
24
|
+
payload: payload,
|
25
|
+
worker: job_class,
|
18
26
|
processor: "#{identity}-#{Thread.current.object_id}",
|
19
27
|
queue: queue
|
20
28
|
}
|
@@ -28,7 +36,8 @@ module Sidekiq
|
|
28
36
|
list.each do |entry|
|
29
37
|
migrated_data = JSON.parse(entry)
|
30
38
|
if record_history(job_class) == true
|
31
|
-
conn.zadd(LIST_KEY, data[:started_at].to_f,
|
39
|
+
conn.zadd(LIST_KEY, data[:started_at].to_f,
|
40
|
+
Sidekiq.dump_json(migrated_data))
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
@@ -48,25 +57,17 @@ module Sidekiq
|
|
48
57
|
private
|
49
58
|
|
50
59
|
# check if this job should be recorded
|
51
|
-
def record_history
|
52
|
-
# first check inclusion
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
elsif defined? EXCLUDE_JOBS
|
60
|
-
if EXCLUDE_JOBS.include? job_class
|
61
|
-
return false
|
62
|
-
else
|
63
|
-
return true
|
64
|
-
end
|
65
|
-
else
|
66
|
-
return true
|
60
|
+
def record_history(job_class)
|
61
|
+
# first check inclusion, when present
|
62
|
+
# it will take precedence over exclude
|
63
|
+
if !Sidekiq.history_include_jobs.nil?
|
64
|
+
return Sidekiq.history_include_jobs.include?(job_class)
|
65
|
+
elsif !Sidekiq.history_exclude_jobs.nil?
|
66
|
+
return !Sidekiq.history_exclude_jobs.include?(job_class)
|
67
67
|
end
|
68
|
-
end
|
69
68
|
|
69
|
+
true
|
70
|
+
end
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
data/web/views/history.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russ Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.5.2
|
138
|
+
rubygems_version: 2.5.2.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: History for sidekiq jobs.
|