stackprofiler-sidekiq 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/stackprofiler/sidekiq.rb +42 -0
- data/stackprofiler-sidekiq.gemspec +21 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14ca549c9b88e41ab8c05aa7fe0ec25c8a1056ed
|
4
|
+
data.tar.gz: b8c1d20b338827684603c22d95bad1a628b9b49f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e0ed961199a4ffd4446529cc1d040289d5f68a8fa89b25794b7d060604f7196db05dfd3d9720db88ecd53aed8f1d1f1be2fb8c314471d6c811862bbfe5f304c
|
7
|
+
data.tar.gz: 0fe3ff12b8c14d7905979fcf19e237ec3810a4f5a7a82884bab2efb77d0af6a4ba89a951ddcaa93deccf071cdd49a7ee32f5139b95a0bd3b0ac349a1cba9d0f0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Aidan Steele
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Sidekiq::Profiler
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'stackprofiler-sidekiq'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install stackprofiler-sidekiq
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/glassechidna/stackprofiler-sidekiq/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'stackprofx'
|
3
|
+
|
4
|
+
module Stackprofiler
|
5
|
+
module Sidekiq
|
6
|
+
class Middleware
|
7
|
+
def initialize opts={}
|
8
|
+
@options = opts
|
9
|
+
@predicate = opts[:predicate] || proc { true }
|
10
|
+
end
|
11
|
+
|
12
|
+
def call worker, job, queue, &blk
|
13
|
+
opts = {mode: :wall, raw: true, threads: [Thread.current] }.merge @options
|
14
|
+
|
15
|
+
if @predicate.call worker, job, queue
|
16
|
+
profile = StackProfx.run(opts) { blk.call }
|
17
|
+
|
18
|
+
klass, jid = job.values_at 'class', 'jid'
|
19
|
+
profile[:suggested_rebase] = "#{klass}#perform"
|
20
|
+
profile[:name] = "Sidekiq:#{klass}:#{jid}"
|
21
|
+
|
22
|
+
Thread.new { send_profile profile }
|
23
|
+
else
|
24
|
+
blk.call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def send_profile profile
|
29
|
+
url = URI::parse ui_url
|
30
|
+
headers = {'Content-Type' => 'application/x-ruby-marshal'}
|
31
|
+
req = Net::HTTP::Post.new(url.to_s, headers)
|
32
|
+
req.body = Marshal.dump profile
|
33
|
+
|
34
|
+
response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def ui_url
|
38
|
+
@options[:ui_url] || ENV['STACKPROFILER_UI_URL']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'stackprofiler-sidekiq'
|
5
|
+
spec.version = '0.0.1'
|
6
|
+
spec.authors = ['Aidan Steele']
|
7
|
+
spec.email = ['aidan.steele@glassechidna.com.au']
|
8
|
+
spec.summary = %q{Sidekiq middleware for low-overhead profiling of background jobs.}
|
9
|
+
spec.homepage = 'https://github.com/glassechidna/stackprofiler-sidekiq'
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0")
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ['lib']
|
16
|
+
|
17
|
+
spec.add_dependency 'stackprofx', '~> 0.2'
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stackprofiler-sidekiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aidan Steele
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: stackprofx
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- aidan.steele@glassechidna.com.au
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/stackprofiler/sidekiq.rb
|
68
|
+
- stackprofiler-sidekiq.gemspec
|
69
|
+
homepage: https://github.com/glassechidna/stackprofiler-sidekiq
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.2.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Sidekiq middleware for low-overhead profiling of background jobs.
|
93
|
+
test_files: []
|
94
|
+
has_rdoc:
|