stackprofiler-sidekiq 0.0.1 → 0.0.2
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 +41 -3
- data/lib/stackprofiler/sidekiq.rb +1 -1
- data/stackprofiler-sidekiq.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 593f5e5de644fb3d05c3f5908312a3cac14c942a
|
4
|
+
data.tar.gz: 350775af985bcbdff4ae4678807415568c6db3cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfc853ba23f67da662def20bf388950663c0f2c646e3d5308f92145da77b8cee62ff2a921beef883664e412c75fe1d1a0035daee648b91b83e793ba0a41feb8a
|
7
|
+
data.tar.gz: 6d09f2f3e934b05ffd1266b6125898e1a76ec18d816f38bec97637deb350a5e743cbc4b0633e10a3a75e3c90bb6518717db68af78f74069ded8bf960c91d6c18
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
# Sidekiq
|
1
|
+
# Stackprofiler::Sidekiq
|
2
2
|
|
3
|
-
|
3
|
+
Please read the [`stackprofiler`][1] gem README for background on Stackprofiler
|
4
|
+
in general.
|
5
|
+
|
6
|
+
This is a [Sidekiq][2] middleware that makes benchmarking of Sidekiq apps a breeze.
|
7
|
+
It utilises a fork of the the brilliant [`stackprof`][3] to enable low-overhead
|
8
|
+
sampling of Ruby processes.
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -20,7 +25,35 @@ Or install it yourself as:
|
|
20
25
|
|
21
26
|
## Usage
|
22
27
|
|
23
|
-
|
28
|
+
[Sidekiq middleware][4] are helpers that can be included in your background jobs.
|
29
|
+
The Stackprofiler middleware is `Stackprofiler::Sidekiq::Middleware`. It can be
|
30
|
+
configured like this:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'stackprofiler/sidekiq'
|
34
|
+
|
35
|
+
Sidekiq.configure_server do |config|
|
36
|
+
config.server_middleware do |chain|
|
37
|
+
chain.add Stackprofiler::Sidekiq::Middleware, {
|
38
|
+
ui_url: 'http://localhost:9292/receive',
|
39
|
+
predicate: proc do |worker, job, queue|
|
40
|
+
job['class'] == 'MyBackgroundJob'
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
The `:ui_url` option is a URL that points to a running instance of the
|
48
|
+
Stackprofiler web UI. It is mandatory. Refer to the Stackprofiler gem README
|
49
|
+
to see how to run this (hint, run `stackprofiler` in the terminal).
|
50
|
+
|
51
|
+
The `:predicate` option is optional. By default, the middleware will profile
|
52
|
+
*every* Sidekiq job. This might be undesirable because you want to focus on
|
53
|
+
only one problematic job and filter out the others. The parameter is a proc
|
54
|
+
object that receives the same arguments as Sidekiq middleware - see the above
|
55
|
+
link to determine what these are. Returning a truthy value will have the job
|
56
|
+
profiled, otherwise it is ignored.
|
24
57
|
|
25
58
|
## Contributing
|
26
59
|
|
@@ -29,3 +62,8 @@ TODO: Write usage instructions here
|
|
29
62
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
31
64
|
5. Create a new Pull Request
|
65
|
+
|
66
|
+
[1]: https://github.com/glassechidna/stackprofiler
|
67
|
+
[2]: https://github.com/mperham/sidekiq
|
68
|
+
[3]: https://github.com/tmm1/stackprof
|
69
|
+
[4]: https://github.com/mperham/sidekiq/wiki/Middleware
|
@@ -12,7 +12,7 @@ module Stackprofiler
|
|
12
12
|
def call worker, job, queue, &blk
|
13
13
|
opts = {mode: :wall, raw: true, threads: [Thread.current] }.merge @options
|
14
14
|
|
15
|
-
if @predicate.call
|
15
|
+
if @predicate.call(worker, job, queue) && !StackProfx.running?
|
16
16
|
profile = StackProfx.run(opts) { blk.call }
|
17
17
|
|
18
18
|
klass, jid = job.values_at 'class', 'jid'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'stackprofiler-sidekiq'
|
5
|
-
spec.version = '0.0.
|
5
|
+
spec.version = '0.0.2'
|
6
6
|
spec.authors = ['Aidan Steele']
|
7
7
|
spec.email = ['aidan.steele@glassechidna.com.au']
|
8
8
|
spec.summary = %q{Sidekiq middleware for low-overhead profiling of background jobs.}
|