skylight 0.7.1 → 0.8.0.beta.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: da9baa6ea5e74582e4f12f1f609dad96b41060fb
4
- data.tar.gz: 71d118970abb5b4be8f11e013c5aeaede224a593
3
+ metadata.gz: b0e3fa37632ad3220389279e789146f96720de4d
4
+ data.tar.gz: 6a338bac5dfcaaafa26e1737da491f6281bc5470
5
5
  SHA512:
6
- metadata.gz: 54363976405c9c7fef83293dc3dabb0d83b5e289991074b32be420fce72561fc5e0071869eaf9b3bd7795c42498e45963aaf55cb2dc530cfc11a5f243b11da84
7
- data.tar.gz: 729f3144b5fdc1b263132abc4899a8cf8f75878a68b098f548b171b2abed79a29ba38f567ae726f194faa4f2055d8c20077a4401daaeb05ea0e38034d3479ca7
6
+ metadata.gz: 5b15f061ab93da78cbe138458d81b93c2019473c46040740c06bdd079179c781b2267f2261d16ef3325bc9c91fff2c459c1a78c731e782ff2bd95f9d4baa2c90
7
+ data.tar.gz: 70bb2e9ea8f4effb5d3878a0e6159366ebbdf836f7111f65f004ac9244933420edf1121a9533989c2abb8891261e12a12cc70495c59898c2dcd60a708364fe62
@@ -1,30 +1,17 @@
1
+ ## 0.8.0-beta.1 (August 4, 2015)
2
+
3
+ * [FEATURE] Add Grape instumentation
4
+
1
5
  ## 0.7.1 (August 4, 2015)
2
6
 
3
7
  * [BUGFIX] Fix bug in FFI error handling
4
8
 
5
9
  ## 0.7.0 (August 3, 2015)
6
10
 
7
- * No changes
8
-
9
- ## 0.7.0-beta.3 (July 30, 2015)
10
-
11
11
  * [BUFIX] Condvar bug in Rust. Updated to latest nightly.
12
-
13
- ## 0.7.0-beta.2 (July 23, 2015)
14
-
15
- * [IMPROVEMENT] Silence a noisy log message
16
-
17
- ## 0.7.0-beta.1 (July 15, 2015)
18
-
19
12
  * [BUGFIX] Don't crash on ruby stack overflow
13
+ * [IMPROVEMENT] Silence a noisy log message
20
14
  * [IMPROVEMENT] Update to latest openssl & curl
21
-
22
- ## 0.6.2-beta.2 (July 1, 2015)
23
-
24
- * No changes. Replaces bad 0.6.2-beta.1 build.
25
-
26
- ## 0.6.2-beta.1 (June 30, 2015) [YANKED]
27
-
28
15
  * [FEATURE] Add probe on ActionView for layout renders
29
16
 
30
17
  ## 0.6.1 (June 30, 2015)
@@ -0,0 +1,2 @@
1
+ require 'skylight'
2
+ require 'skylight/probes/grape'
@@ -0,0 +1,118 @@
1
+ module Skylight
2
+ module Probes
3
+ module Grape
4
+ class Probe
5
+ def install
6
+ version = ::Grape::VERSION.split('.')
7
+ if version[0] == '0' && version[1].to_i < 10
8
+ # Using $stderr here isn't great, but we don't have a logger accessible
9
+ $stderr.puts "[SKYLIGHT] [#{Skylight::VERSION}] The Grape probe only works with version 0.10.0+ " \
10
+ "and will be disabled."
11
+
12
+ return
13
+ end
14
+
15
+ # Grape relies on this but does doesn't correctly require it.
16
+ # However, when using ActiveSupport 4 it is implicitly loaded,
17
+ # in AS 3, it will fail.
18
+ # https://github.com/ruby-grape/grape/issues/1087
19
+ require 'active_support/core_ext/hash/except'
20
+
21
+ ::Grape::Endpoint.class_eval do
22
+ alias initialize_without_sk initialize
23
+ def initialize(*args, &block)
24
+ initialize_without_sk(*args, &block)
25
+
26
+ # This solution of wrapping the block is effective, but potentially fragile.
27
+ # A cleaner solution would be to call the original initialize with the already
28
+ # modified block. However, Grape does some odd stuff with the block binding
29
+ # that makes this difficult to reason about.
30
+ if original_block = @block
31
+ opts = {
32
+ category: "app.grape.endpoint",
33
+ title: method_name.gsub(/\s+/, ' ')
34
+ }
35
+
36
+ @block = lambda do |endpoint_instance|
37
+ Skylight.instrument(opts) do
38
+ original_block.call(endpoint_instance)
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ alias run_without_sk run
45
+ def run(*args)
46
+ # We run the original method first since it gives us access to more information
47
+ # about the current state, including populating `route`.
48
+ run_without_sk(*args)
49
+ ensure
50
+ if instrumenter = Skylight::Instrumenter.instance
51
+ if trace = instrumenter.current_trace
52
+ # FIXME: How do we handle endpoints with multiple methods?
53
+ # Currently we'll see things like "PUT POST DELETE PATCH HEAD"
54
+
55
+ # OPTION A: GET /prefix/name [v1]
56
+ # # FIXME: Ideally we wouldn't have to do this, but I don't know
57
+ # # of a better way
58
+ # info = route.instance_variable_get :@options
59
+
60
+ # # FIXME: Consider whether we should include the module name
61
+ # name = "#{info[:method]} #{info[:path]}"
62
+ # name << " [#{info[:version]}]" if info[:version]
63
+
64
+
65
+ # OPTION B: Module::Class GET /name
66
+ http_method = options[:method].first
67
+ http_method << "..." if options[:method].length > 1
68
+
69
+ path = options[:path].join("/")
70
+ namespace = ::Grape::Namespace.joined_space(namespace_stackable(:namespace))
71
+
72
+ if namespace && !namespace.empty?
73
+ path = "/#{path}" if path[0] != '/'
74
+ path = "#{namespace}#{path}"
75
+ end
76
+
77
+ name = "#{options[:for]} [#{http_method}] #{path}"
78
+
79
+ trace.endpoint = name
80
+ end
81
+ end
82
+ end
83
+
84
+ alias run_filters_without_sk run_filters
85
+ def run_filters(filters)
86
+ if !filters || filters.empty?
87
+ # If there's no filters nothing should happen, but let Grape decide
88
+ return run_filters_without_sk(filters)
89
+ end
90
+
91
+ # Unfortunately, this method only gets passed an array of filters.
92
+ # This means we have to compare to known lists to attempt to detect
93
+ # the type.
94
+ type = case filters
95
+ when befores then "Before"
96
+ when before_validations then "Before Validation"
97
+ when after_validations then "After Validation"
98
+ when afters then "After"
99
+ else "Other"
100
+ end
101
+
102
+ opts = {
103
+ category: "app.grape.filters",
104
+ title: "#{type} Filters"
105
+ }
106
+
107
+ Skylight.instrument(opts) do
108
+ run_filters_without_sk(filters)
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ register("Grape", "grape", Grape::Probe.new)
117
+ end
118
+ end
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0-beta.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  description:
@@ -53,6 +53,7 @@ files:
53
53
  - lib/skylight/data/cacert.pem
54
54
  - lib/skylight/formatters/http.rb
55
55
  - lib/skylight/gc.rb
56
+ - lib/skylight/grape.rb
56
57
  - lib/skylight/helpers.rb
57
58
  - lib/skylight/instrumenter.rb
58
59
  - lib/skylight/middleware.rb
@@ -81,6 +82,7 @@ files:
81
82
  - lib/skylight/probes/action_view.rb
82
83
  - lib/skylight/probes/excon.rb
83
84
  - lib/skylight/probes/excon/middleware.rb
85
+ - lib/skylight/probes/grape.rb
84
86
  - lib/skylight/probes/net_http.rb
85
87
  - lib/skylight/probes/redis.rb
86
88
  - lib/skylight/probes/sequel.rb
@@ -163,17 +165,17 @@ require_paths:
163
165
  - lib
164
166
  required_ruby_version: !ruby/object:Gem::Requirement
165
167
  requirements:
166
- - - '>='
168
+ - - ">="
167
169
  - !ruby/object:Gem::Version
168
170
  version: 1.9.2
169
171
  required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  requirements:
171
- - - '>='
173
+ - - ">"
172
174
  - !ruby/object:Gem::Version
173
- version: '0'
175
+ version: 1.3.1
174
176
  requirements: []
175
177
  rubyforge_project:
176
- rubygems_version: 2.2.2
178
+ rubygems_version: 2.4.8
177
179
  signing_key:
178
180
  specification_version: 4
179
181
  summary: Skylight is a smart profiler for Rails apps