stackprofiler-sidekiq 0.0.1 → 0.0.2

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
2
  SHA1:
3
- metadata.gz: 14ca549c9b88e41ab8c05aa7fe0ec25c8a1056ed
4
- data.tar.gz: b8c1d20b338827684603c22d95bad1a628b9b49f
3
+ metadata.gz: 593f5e5de644fb3d05c3f5908312a3cac14c942a
4
+ data.tar.gz: 350775af985bcbdff4ae4678807415568c6db3cd
5
5
  SHA512:
6
- metadata.gz: 1e0ed961199a4ffd4446529cc1d040289d5f68a8fa89b25794b7d060604f7196db05dfd3d9720db88ecd53aed8f1d1f1be2fb8c314471d6c811862bbfe5f304c
7
- data.tar.gz: 0fe3ff12b8c14d7905979fcf19e237ec3810a4f5a7a82884bab2efb77d0af6a4ba89a951ddcaa93deccf071cdd49a7ee32f5139b95a0bd3b0ac349a1cba9d0f0
6
+ metadata.gz: bfc853ba23f67da662def20bf388950663c0f2c646e3d5308f92145da77b8cee62ff2a921beef883664e412c75fe1d1a0035daee648b91b83e793ba0a41feb8a
7
+ data.tar.gz: 6d09f2f3e934b05ffd1266b6125898e1a76ec18d816f38bec97637deb350a5e743cbc4b0633e10a3a75e3c90bb6518717db68af78f74069ded8bf960c91d6c18
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # Sidekiq::Profiler
1
+ # Stackprofiler::Sidekiq
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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 worker, job, queue
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.1'
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.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackprofiler-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Steele