newrelic-grape 2.0.0 → 2.1.0
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 +4 -4
- data/.travis.yml +18 -0
- data/CHANGELOG.md +4 -3
- data/Gemfile +11 -4
- data/README.md +6 -0
- data/Rakefile +3 -3
- data/example_app/Gemfile +4 -4
- data/example_app/config.ru +1 -1
- data/example_app_with_newrelic_3_8/Gemfile +3 -3
- data/example_app_with_newrelic_3_8/config.ru +1 -1
- data/lib/newrelic-grape.rb +2 -2
- data/lib/newrelic-grape/instrument.rb +38 -22
- data/lib/newrelic-grape/version.rb +1 -1
- data/newrelic-grape.gemspec +11 -11
- data/spec/newrelic-grape/instrumenter_spec.rb +4 -6
- data/spec/newrelic-grape/version_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d1c6a522ac658fdea25afcb6d90fdf1d7d9fb46
|
|
4
|
+
data.tar.gz: 31fc208d6c5433975b6c992ed14aeacefe4a6fdf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b20c6e72cc34576c5cd6e24eb77f0e25f23ee1c53761abe11ef45f9d72f1de7268ddb172227565b7beb34881b4ea0e734717daeefdba621ebbd97aed943cea25
|
|
7
|
+
data.tar.gz: 985840a2d20dbb9250dfb191c24c367bd44151a6d3ee4b9df87050c5ad58d8bc3f9305c5ece54dc6d98b18516f89768a6ee2e9393bce877eca3230642b298ed5
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
|
|
3
|
+
rvm:
|
|
4
|
+
- 2.2
|
|
5
|
+
- 2.0
|
|
6
|
+
- rbx-2.5.8
|
|
7
|
+
- jruby-19mode
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
- GRAPE_VERSION=0.8.0
|
|
11
|
+
- GRAPE_VERSION=0.9.0
|
|
12
|
+
- GRAPE_VERSION=0.10.0
|
|
13
|
+
- GRAPE_VERSION=0.10.1
|
|
14
|
+
- GRAPE_VERSION=0.11.0
|
|
15
|
+
- GRAPE_VERSION=0.12.0
|
|
16
|
+
- GRAPE_VERSION=0.13.0
|
|
17
|
+
- GRAPE_VERSION=0.14.0
|
|
18
|
+
- GRAPE_VERSION=HEAD
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 2.1.0 (12/08/2014)
|
|
2
|
+
|
|
3
|
+
* Work with grape 0.14.0 [@dblock](https://github.com/dblock)
|
|
2
4
|
|
|
3
5
|
## 2.0.0 (10/20/2014)
|
|
4
6
|
|
|
@@ -6,8 +8,7 @@
|
|
|
6
8
|
|
|
7
9
|
## 1.4.1 (07/04/2014)
|
|
8
10
|
|
|
9
|
-
* Fix "uninitialized constant NewRelic::MetricSpec (NameError)" with
|
|
10
|
-
newrelic_rpm 3.8.1.221
|
|
11
|
+
* Fix "uninitialized constant NewRelic::MetricSpec (NameError)" with newrelic_rpm 3.8.1.221
|
|
11
12
|
* Fix "uninitialized constant Grape"
|
|
12
13
|
|
|
13
14
|
## 1.4.0 (05/09/2014)
|
data/Gemfile
CHANGED
|
@@ -3,9 +3,16 @@ source 'https://rubygems.org'
|
|
|
3
3
|
# Specify your gem's dependencies in newrelic-grape.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
+
case version = ENV['GRAPE_VERSION'] || '~> 0.14.0'
|
|
7
|
+
when 'HEAD'
|
|
8
|
+
gem 'grape', github: 'ruby-grape/grape'
|
|
9
|
+
else
|
|
10
|
+
gem 'grape', version
|
|
11
|
+
end
|
|
12
|
+
|
|
6
13
|
group :development, :test do
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
9
|
-
gem
|
|
10
|
-
gem
|
|
14
|
+
gem 'rake', '~> 10.0'
|
|
15
|
+
gem 'bundler', '~> 1.0'
|
|
16
|
+
gem 'rspec', '~> 3.4.0'
|
|
17
|
+
gem 'rack-test', '~> 0.6.3'
|
|
11
18
|
end
|
data/README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# NewRelic::Grape
|
|
2
2
|
|
|
3
|
+
### NewRelic has already officially support grape, see more [here](https://docs.newrelic.com/docs/agents/ruby-agent/frameworks/grape-instrumentation)
|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.org/xinminlabs/newrelic-grape)
|
|
6
|
+
|
|
3
7
|
NewRelic instrumentation for the [Grape API DSL][0], inspired by [this blog post][1].
|
|
4
8
|
|
|
5
9
|
If you use newrelic_rpm < 3.9.0, please use newrelic-grape 1.4.x
|
|
6
10
|
If you use newrelic_rpm >= 3.9.0, please use newrelic-grape >= 2.0.0
|
|
7
11
|
|
|
12
|
+
**Please note**: newrelic_rpm 3.9.8 is [incompatible](https://discuss.newrelic.com/t/refusing-to-re-register-dependencydetection-block-with-name-grape/13734)! A fix was [included in 3.9.9](https://docs.newrelic.com/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-399275).
|
|
13
|
+
|
|
8
14
|
## Installation
|
|
9
15
|
|
|
10
16
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
2
|
|
|
3
3
|
begin
|
|
4
4
|
Bundler.setup(:default, :development)
|
|
5
5
|
rescue Bundler::BundlerError => e
|
|
6
6
|
$stderr.puts e.message
|
|
7
|
-
$stderr.puts
|
|
7
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
|
8
8
|
exit e.status_code
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -17,4 +17,4 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
|
17
17
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
task :
|
|
20
|
+
task default: :spec
|
data/example_app/Gemfile
CHANGED
|
@@ -2,10 +2,10 @@ source 'http://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gem 'rack'
|
|
4
4
|
gem 'grape'
|
|
5
|
-
gem 'newrelic_rpm'
|
|
6
|
-
gem 'newrelic-grape'
|
|
5
|
+
gem 'newrelic_rpm', '~> 3.9.0'
|
|
6
|
+
gem 'newrelic-grape', '~> 2.0.0'
|
|
7
7
|
|
|
8
8
|
group :test do
|
|
9
|
-
gem
|
|
10
|
-
gem
|
|
9
|
+
gem 'rspec'
|
|
10
|
+
gem 'rack-test', require: 'rack/test'
|
|
11
11
|
end
|
data/example_app/config.ru
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.expand_path('../config/environment', __FILE__)
|
|
2
2
|
|
|
3
3
|
if ENV['RACK_ENV'] == 'development'
|
|
4
|
-
puts
|
|
4
|
+
puts 'Loading NewRelic in developer mode ...'
|
|
5
5
|
require 'new_relic/rack/developer_mode'
|
|
6
6
|
use NewRelic::Rack::DeveloperMode
|
|
7
7
|
end
|
|
@@ -3,9 +3,9 @@ source 'http://rubygems.org'
|
|
|
3
3
|
gem 'rack'
|
|
4
4
|
gem 'grape'
|
|
5
5
|
gem 'newrelic_rpm', '~> 3.8.0'
|
|
6
|
-
gem 'newrelic-grape'
|
|
6
|
+
gem 'newrelic-grape', '~> 1.4.0'
|
|
7
7
|
|
|
8
8
|
group :test do
|
|
9
|
-
gem
|
|
10
|
-
gem
|
|
9
|
+
gem 'rspec'
|
|
10
|
+
gem 'rack-test', require: 'rack/test'
|
|
11
11
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require File.expand_path('../config/environment', __FILE__)
|
|
2
2
|
|
|
3
3
|
if ENV['RACK_ENV'] == 'development'
|
|
4
|
-
puts
|
|
4
|
+
puts 'Loading NewRelic in developer mode ...'
|
|
5
5
|
require 'new_relic/rack/developer_mode'
|
|
6
6
|
use NewRelic::Rack::DeveloperMode
|
|
7
7
|
end
|
data/lib/newrelic-grape.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require 'newrelic-grape/version'
|
|
2
|
+
require 'newrelic-grape/instrument'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'new_relic/agent/instrumentation'
|
|
2
|
-
require 'new_relic/agent/instrumentation/
|
|
2
|
+
require 'new_relic/agent/instrumentation/middleware_proxy'
|
|
3
3
|
require 'grape'
|
|
4
4
|
|
|
5
5
|
module NewRelic
|
|
@@ -12,10 +12,10 @@ module NewRelic
|
|
|
12
12
|
@env = env
|
|
13
13
|
@newrelic_request = ::Rack::Request.new(env)
|
|
14
14
|
trace_options = {
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
15
|
+
category: :rack,
|
|
16
|
+
path: "#{request_method} #{request_path}",
|
|
17
|
+
request: @newrelic_request,
|
|
18
|
+
params: @newrelic_request.params
|
|
19
19
|
}
|
|
20
20
|
perform_action_with_newrelic_trace(trace_options) do
|
|
21
21
|
@app_response = @app.call(@env)
|
|
@@ -27,7 +27,7 @@ module NewRelic
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def request_path
|
|
30
|
-
path = route.route_path[1..-1].
|
|
30
|
+
path = route.route_path[1..-1].tr('/', '-')
|
|
31
31
|
path.sub!(/\(\.:format\)\z/, '')
|
|
32
32
|
route.route_version && path.sub!(':version', route.route_version)
|
|
33
33
|
|
|
@@ -46,32 +46,48 @@ DependencyDetection.defer do
|
|
|
46
46
|
@name = :grape
|
|
47
47
|
|
|
48
48
|
depends_on do
|
|
49
|
-
defined?(::Grape) && ! ::NewRelic::Control.instance['disable_grape'] && !
|
|
49
|
+
defined?(::Grape) && ! ::NewRelic::Control.instance['disable_grape'] && !ENV['DISABLE_NEW_RELIC_GRAPE']
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
executes do
|
|
53
|
-
NewRelic::Agent.logger.
|
|
53
|
+
NewRelic::Agent.logger.info 'Installing Grape instrumentation'
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
executes do
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
begin
|
|
58
|
+
NewRelic::Agent::Instrumentation::MiddlewareProxy.class_eval do
|
|
59
|
+
def self.needs_wrapping?(target)
|
|
60
|
+
(
|
|
61
|
+
!target.respond_to?(:_nr_has_middleware_tracing) &&
|
|
62
|
+
!is_sinatra_app?(target) &&
|
|
63
|
+
!target.is_a?(Proc)
|
|
64
|
+
)
|
|
65
|
+
end
|
|
64
66
|
end
|
|
65
|
-
end
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
::Grape::Endpoint.class_eval do
|
|
69
|
+
if method_defined?(:build_middleware)
|
|
70
|
+
alias_method :_build_middleware, :build_middleware
|
|
71
|
+
|
|
72
|
+
def build_middleware
|
|
73
|
+
b = _build_middleware
|
|
74
|
+
b.use ::NewRelic::Agent::Instrumentation::Grape
|
|
75
|
+
b
|
|
76
|
+
end
|
|
77
|
+
elsif private_method_defined?(:build_stack)
|
|
78
|
+
include Grape::DSL::Middleware::ClassMethods
|
|
69
79
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
alias_method :_build_stack, :build_stack
|
|
81
|
+
|
|
82
|
+
def build_stack
|
|
83
|
+
use ::NewRelic::Agent::Instrumentation::Grape
|
|
84
|
+
_build_stack
|
|
85
|
+
end
|
|
86
|
+
end
|
|
74
87
|
end
|
|
88
|
+
rescue Exception => e
|
|
89
|
+
STDERR.puts e
|
|
90
|
+
raise e
|
|
75
91
|
end
|
|
76
92
|
end
|
|
77
93
|
end
|
data/newrelic-grape.gemspec
CHANGED
|
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'newrelic-grape/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name =
|
|
7
|
+
gem.name = 'newrelic-grape'
|
|
8
8
|
gem.version = NewRelic::Grape::VERSION
|
|
9
|
-
gem.authors = [
|
|
10
|
-
gem.email = [
|
|
11
|
-
gem.description =
|
|
12
|
-
gem.summary =
|
|
13
|
-
gem.homepage =
|
|
9
|
+
gem.authors = ['Richard Huang']
|
|
10
|
+
gem.email = ['flyerhzm@gmail.com']
|
|
11
|
+
gem.description = 'newrelic instrument for grape'
|
|
12
|
+
gem.summary = 'newrelic instrument for grape'
|
|
13
|
+
gem.homepage = 'https://github.com/flyerhzm/newrelic-grape'
|
|
14
14
|
|
|
15
|
-
gem.files = `git ls-files`.split(
|
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
-
gem.require_paths = [
|
|
18
|
+
gem.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
gem.add_runtime_dependency(
|
|
21
|
-
gem.add_runtime_dependency(
|
|
20
|
+
gem.add_runtime_dependency('grape')
|
|
21
|
+
gem.add_runtime_dependency('newrelic_rpm')
|
|
22
22
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe NewRelic::Agent::Instrumentation::Grape do
|
|
4
|
-
|
|
5
4
|
subject { Class.new(Grape::API) }
|
|
6
5
|
|
|
7
6
|
def app
|
|
@@ -16,8 +15,8 @@ describe NewRelic::Agent::Instrumentation::Grape do
|
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
it 'perform_action_with_newrelic_trace' do
|
|
19
|
-
NewRelic::Agent::Instrumentation::Grape
|
|
20
|
-
.
|
|
18
|
+
expect_any_instance_of(NewRelic::Agent::Instrumentation::Grape)
|
|
19
|
+
.to receive(:perform_action_with_newrelic_trace)
|
|
21
20
|
.with(hash_including(path: 'GET hello'))
|
|
22
21
|
.and_yield
|
|
23
22
|
|
|
@@ -38,8 +37,8 @@ describe NewRelic::Agent::Instrumentation::Grape do
|
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
it 'perform_action_with_newrelic_trace' do
|
|
41
|
-
NewRelic::Agent::Instrumentation::Grape
|
|
42
|
-
.
|
|
40
|
+
expect_any_instance_of(NewRelic::Agent::Instrumentation::Grape)
|
|
41
|
+
.to receive(:perform_action_with_newrelic_trace)
|
|
43
42
|
.with(hash_including(path: 'GET v1-hello'))
|
|
44
43
|
.and_yield
|
|
45
44
|
|
|
@@ -50,5 +49,4 @@ describe NewRelic::Agent::Instrumentation::Grape do
|
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
end
|
|
53
|
-
|
|
54
52
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: newrelic-grape
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Huang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: grape
|
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
|
47
47
|
files:
|
|
48
48
|
- ".gitignore"
|
|
49
49
|
- ".rspec"
|
|
50
|
+
- ".travis.yml"
|
|
50
51
|
- CHANGELOG.md
|
|
51
52
|
- Gemfile
|
|
52
53
|
- LICENSE.txt
|
|
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
101
102
|
version: '0'
|
|
102
103
|
requirements: []
|
|
103
104
|
rubyforge_project:
|
|
104
|
-
rubygems_version: 2.
|
|
105
|
+
rubygems_version: 2.4.5.1
|
|
105
106
|
signing_key:
|
|
106
107
|
specification_version: 4
|
|
107
108
|
summary: newrelic instrument for grape
|