rack-profiler 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe1afedae470bb85742aeb3a12c0d254fe85dcae
4
- data.tar.gz: 1e70fe3c574df047fecc89476c6ae25ac684ebb9
3
+ metadata.gz: a343b0c57f979d808c382c43240fab52021e0d2b
4
+ data.tar.gz: af40d1d74d3b9bcd3bb3e2497ce0173a20e6ea6c
5
5
  SHA512:
6
- metadata.gz: 873f5b0416871e69754316871703e68ae47df70aab738192dc5d7867460abb755c46834a45cd58182406ec89187a9d07224709e4f7f48e55555bd45ee16fa1cb
7
- data.tar.gz: da4315aba4b60ac6807de38c84fbe15ad83eeaedb1c8849b51f84f3c1c6d14aecda2802c8fb4af558d59aa90d18d707a5d17d8cb070ec9af21b5d3a72e015efd
6
+ metadata.gz: 888e9762b98c4c8a6bb20d0db4eb23c53358b1b32a595e3c7383b585d8fd44854dd5bb03210a9489207e186e381584471b0520a5517a35b9988c1b4947a2ae38
7
+ data.tar.gz: 9436e633d74ba37e8b347d6f8e5581a8bb7e2a059ca044759c495038367f20c490ce08b7426dcaa6fafe9318831a3dae1061cd34f129b77d9e3439ba2072f034
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/dawanda/rack-profiler.svg)](https://travis-ci.org/dawanda/rack-profiler) [![Code Climate](https://codeclimate.com/github/dawanda/rack-profiler/badges/gpa.svg)](https://codeclimate.com/github/dawanda/rack-profiler) [![Test Coverage](https://codeclimate.com/github/dawanda/rack-profiler/badges/coverage.svg)](https://codeclimate.com/github/dawanda/rack-profiler)
4
4
  [![Gem Version](https://badge.fury.io/rb/rack-profiler.svg)](http://badge.fury.io/rb/rack-profiler)
5
5
 
6
- Simple profiler for Rack applications (Sinatra and Ruby on Rails for example).
6
+ Simple profiler for Rack applications (Sinatra, Ruby on Rails, or Grape for example).
7
7
  It helps providing an answer to common questions like:
8
8
 
9
9
  - Where is time spent in requests to my app?
@@ -21,6 +21,11 @@ subscribes by default to the following hooks:
21
21
  * [render_partial.action_view](http://guides.rubyonrails.org/active_support_instrumentation.html#render_partial.action_view)
22
22
  * [process_action.action_controller](http://guides.rubyonrails.org/active_support_instrumentation.html#process_action.action_controller)
23
23
 
24
+ `Rack::Profiler` also automatically subscribes to [Grape's](https://github.com/ruby-grape/grape) Active Support Instrumentation notifications
25
+ * [endpoint_run.grape](https://github.com/ruby-grape/grape#performance-monitoring)
26
+ * [endpoint_render.grape](https://github.com/ruby-grape/grape#performance-monitoring)
27
+ * [endpoint_run_filters.grape](https://github.com/ruby-grape/grape#performance-monitoring)
28
+
24
29
  On top of this, you can also define your own events, by wrapping your code with
25
30
  the [`Rack::Profiler.step`](#custom-steps).
26
31
 
@@ -46,7 +51,7 @@ Or install it yourself as:
46
51
 
47
52
  $ gem install rack-profiler
48
53
 
49
- ### Rack/Sinatra
54
+ ### Rack/Sinatra/Grape
50
55
 
51
56
  In your `config.ru` use the `Rack::Profiler` middleware at the beginning of your
52
57
  middleware stack:
@@ -0,0 +1,7 @@
1
+ module Grape
2
+ class Endpoint
3
+ def as_json(options = nil)
4
+ body.to_hash.as_json(options)
5
+ end
6
+ end
7
+ end
data/lib/rack/profiler.rb CHANGED
@@ -3,6 +3,7 @@ require "rack/request"
3
3
  require "rack/auth/basic"
4
4
  require "rack/profiler/version"
5
5
  require "active_support/notifications"
6
+ require "grape/endpoint"
6
7
 
7
8
  module Rack
8
9
  class Profiler
@@ -14,8 +15,12 @@ module Rack
14
15
  'render_template.action_view',
15
16
  'render_partial.action_view',
16
17
  'process_action.action_controller',
18
+ 'endpoint_run.grape',
19
+ 'endpoint_render.grape',
20
+ 'endpoint_run_filters.grape',
17
21
  'rack-profiler.total_time',
18
- 'rack-profiler.step']
22
+ 'rack-profiler.step'
23
+ ]
19
24
 
20
25
  class DummyError < StandardError; end
21
26
 
@@ -83,6 +88,10 @@ module Rack
83
88
  status, headers, body = @app.call(env)
84
89
  end
85
90
  return [status, headers, body] unless authorized?(env)
91
+ # Grape will inject the env into the payload.
92
+ # That'll cause problems with the json, so we'll just remove it.
93
+ events.each { |e| e[:payload].delete(:env) }
94
+
86
95
  results = {
87
96
  events: events.sort_by { |event| event[:start] },
88
97
  response: {
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Profiler
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Ongaro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-27 00:00:00.000000000 Z
12
+ date: 2016-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -95,6 +95,7 @@ files:
95
95
  - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
+ - lib/grape/endpoint.rb
98
99
  - lib/rack/profiler.rb
99
100
  - lib/rack/profiler/version.rb
100
101
  - public/rack-profiler.html
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project:
124
- rubygems_version: 2.4.8
125
+ rubygems_version: 2.2.2
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: A simple profiler for Rack applications