stackflame 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/rack/stackflame.rb +3 -2
- data/lib/stackflame/version.rb +1 -1
- data/lib/stackflame.rb +11 -4
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a371b3ca76216b8729ee4a3486fc141f196207ae
|
4
|
+
data.tar.gz: 399a853e4ee66393aa5b52291c7bd0ef84d9d731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1180e73b1756377ee1c7f945fb1508beb11d3adea98c714afef251ab6d378e47b537da974b8b914d2096344e5bdba08e5abf38be7f9f39979f853ca674e9be4
|
7
|
+
data.tar.gz: 1a8076a8822f667b6daa6c19e6d0b9db43f01a2524575701fe91c3521248dba6a7d10bfc863e9f238677e55e53885b48cd88d23adc9d90f33730e5fa34e79819
|
data/README.md
CHANGED
@@ -23,6 +23,12 @@ If you use OSX, flamegraph will be opened with your default browser.
|
|
23
23
|
|
24
24
|
![](http://i.gyazo.com/47871c2de985298c61d0fcca041a34d0.png)
|
25
25
|
|
26
|
+
### Rack middlware
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
use Rack::Stackflame, interval: 10
|
30
|
+
```
|
31
|
+
|
26
32
|
## License
|
27
33
|
|
28
34
|
MIT License
|
data/lib/rack/stackflame.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Rack
|
2
2
|
class Stackflame
|
3
|
-
def initialize(app)
|
3
|
+
def initialize(app, options = {})
|
4
4
|
@app = app
|
5
|
+
@options = options
|
5
6
|
end
|
6
7
|
|
7
8
|
def call(env)
|
8
9
|
result = nil
|
9
|
-
::Stackflame.profile do
|
10
|
+
::Stackflame.profile(@options) do
|
10
11
|
result = @app.call(env)
|
11
12
|
end
|
12
13
|
result
|
data/lib/stackflame/version.rb
CHANGED
data/lib/stackflame.rb
CHANGED
@@ -3,14 +3,21 @@ require "rack/stackflame"
|
|
3
3
|
require "stackprof"
|
4
4
|
|
5
5
|
class Stackflame
|
6
|
-
|
6
|
+
DEFAULT_OPTIONS = {
|
7
|
+
interval: 1000,
|
8
|
+
mode: :cpu,
|
9
|
+
raw: true,
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def self.profile(options = {}, &block)
|
7
13
|
stackflame = self.new
|
8
|
-
stackflame.run(
|
14
|
+
stackflame.run(options, &block)
|
9
15
|
stackflame.open_flamegraph
|
10
16
|
end
|
11
17
|
|
12
|
-
def run(
|
13
|
-
|
18
|
+
def run(options = {}, &block)
|
19
|
+
options = DEFAULT_OPTIONS.merge(options)
|
20
|
+
result = StackProf.run(options, &block)
|
14
21
|
|
15
22
|
File.open(temp_js_path, 'w') do |f|
|
16
23
|
StackProf::Report.new(result).print_flamegraph(f)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackflame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stackprof
|
@@ -138,4 +138,3 @@ signing_key:
|
|
138
138
|
specification_version: 4
|
139
139
|
summary: Stackflame provides a simple API to deal with Flamegraph of stackprof.
|
140
140
|
test_files: []
|
141
|
-
has_rdoc:
|