grape-appsignal 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 801fa49a4ee1290f3145ce8bfd2910472016e0b4
4
- data.tar.gz: 2d11531026cd6c0c50aef962514fea5a5ddadc2f
3
+ metadata.gz: c0a52b4dfdf6f23389a64d350b5b482596a827d3
4
+ data.tar.gz: 16687f8a13c5540a7baafb2b0d4b58244f7fe4c6
5
5
  SHA512:
6
- metadata.gz: b14855bf668efacee9e6a1f73843fe12c4faf65b08002956316b3782cd3b0d4d0b5cf23a0864906148b4ccf0eb3f5d34e457968ed3df9aca8c53fdf63824f2fd
7
- data.tar.gz: 44e97b5ab1b563e01f03741d1d06a93c46b87af7b587ab045af011fa85c9c24060d0eefb74c0180d2fe83ab9542601661485ac11f2c35cfc17e1923590d66816
6
+ metadata.gz: c3de557f96ebc3d97647eecaf5778765742cd03b0c935438c979d926cc7f3cbd4149b26de1601033fe317455beafda91ba3bd11120c9a5f8cd1b3ab59309b1e8
7
+ data.tar.gz: 59547e6f06534c8664e77aaf4abca915cf2f076191f3e94670d390f01ac78cae94f15d80ad1ec7adbaa6ca448e268b7bfa1875a7b22850adc58d5d3002bd204e
@@ -1,5 +1,5 @@
1
1
  rvm:
2
- - 2.1.0
2
+ - 2.1.2
3
3
  - 2.0.0
4
4
  - 1.9.3
5
5
  - jruby
@@ -1,4 +1,7 @@
1
1
  ## Changelog
2
2
 
3
+ ### Version 0.2.0
4
+ * Change the logging so that id's are pulled out of the URLs.
5
+
3
6
  ### Version 0.0.1
4
7
  * First commit. Yeah!
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ group :development, :test do
13
13
  gem 'rspec'
14
14
  gem 'github-markup'
15
15
  gem 'rack-test'
16
- gem 'rspec-expectations', '~> 2.14.0'
17
- gem 'rspec-mocks', '~> 2.14.0'
16
+ gem 'rspec-expectations', '~> 3.0.0'
17
+ gem 'rspec-mocks', '~> 3.0.0'
18
18
  gem 'listen', '~> 2.1'
19
19
  end
@@ -9,12 +9,12 @@ module Appsignal
9
9
  end
10
10
 
11
11
  def call(env)
12
+ req = ::Rack::Request.new(env)
12
13
  method = env['REQUEST_METHOD']
13
- metric_path = env['PATH_INFO'].nil? ? ".api" : env['PATH_INFO'].gsub("/", ".")
14
- request_path = env['api.endpoint'].routes.first.route_path[1..-1].gsub(/\(\.:format\)\z/, "")
15
14
 
16
- metric_name = "process_action.grape#{metric_path}"
17
- action = "#{method}#{env['PATH_INFO']}"
15
+ request_path = env['api.endpoint'].routes.first.route_path[1..-1].sub(/\(\.:format\)\z/, "")
16
+ metric_name = "grape.#{req.request_method}.#{request_path}"
17
+ action = "#{method} #{env['PATH_INFO']}"
18
18
 
19
19
  ActiveSupport::Notifications.instrument(metric_name, { method: method, path: request_path, action: action, class: "API" } ) do |payload|
20
20
  @app.call(env)
@@ -1,5 +1,5 @@
1
1
  module Appsignal
2
2
  module Grape
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Appsignal::Grape::Middleware do
4
4
 
5
- class TestAPI < Grape::API
5
+ class ComplexAPI < Grape::API
6
6
  prefix "api"
7
7
  version "v1"
8
8
  use Appsignal::Grape::Middleware
@@ -14,30 +14,79 @@ describe Appsignal::Grape::Middleware do
14
14
  end
15
15
  end
16
16
 
17
- def app; TestAPI; end
18
-
19
- let(:event) { @events.pop }
20
- subject { event.payload }
17
+ class SimpleAPI < Grape::API
18
+ use Appsignal::Grape::Middleware
21
19
 
22
- before(:all) do
23
- @events = []
24
- ActiveSupport::Notifications.subscribe('process_action.grape.api.v1.hello.mark') do |*args|
25
- @events << ActiveSupport::Notifications::Event.new(*args)
20
+ resource :hello do
21
+ get ':id' do
22
+ "hello #{params['id']}"
23
+ end
26
24
  end
27
25
  end
28
26
 
29
- before(:each) do
30
- get "api/v1/hello/mark"
31
- end
27
+ context "with a simple API" do
28
+ let(:events){ [] }
29
+ let(:app){ SimpleAPI }
30
+ before do
31
+ ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
32
+ events << ActiveSupport::Notifications::Event.new(*args)
33
+ end
34
+ end
32
35
 
33
- it do
34
- should == { method: "GET" , path: "api/:version/hello/:name", action: "GET/api/v1/hello/mark", class: "API"}
36
+ subject { get "/hello/1337"; events.last}
37
+
38
+ it "delivers a payload consistent with the API call."do
39
+ expect(subject.payload ).to eq(
40
+ { method: "GET" , path: "hello/:id", action: "GET /hello/1337", class: "API"}
41
+ )
42
+ end
43
+
44
+ it "names the payload consistent with the API call."do
45
+ expect(subject.name ).to eq("grape.GET.hello/:id")
46
+ end
47
+
48
+ context "verify the api request" do
49
+ subject{ get "/hello/1337"; last_response }
50
+
51
+ it "returns the correct body" do
52
+ expect(subject.body).to eq("hello 1337")
53
+ end
54
+ it "returns the correct status code" do
55
+ expect(subject.status).to eq(200)
56
+ end
57
+ end
35
58
  end
36
59
 
37
- context "verify the api request" do
38
- subject{ last_response }
60
+ context "with a complex API" do
61
+ let(:events){ [] }
62
+ let(:app){ ComplexAPI }
63
+ before do
64
+ ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
65
+ events << ActiveSupport::Notifications::Event.new(*args)
66
+ end
67
+ end
68
+
69
+ subject { get "api/v1/hello/mark"; events.last}
70
+
71
+ it "delivers a payload consistent with the API call."do
72
+ expect(subject.payload ).to eq(
73
+ { method: "GET" , path: "api/:version/hello/:name", action: "GET /api/v1/hello/mark", class: "API"}
74
+ )
75
+ end
39
76
 
40
- its(:body){ should == "hello mark" }
41
- its(:status){ should == 200 }
77
+ it "names the payload consistent with the API call."do
78
+ expect(subject.name ).to eq("grape.GET.api/:version/hello/:name")
79
+ end
80
+
81
+ context "verify the api request" do
82
+ subject{ get "api/v1/hello/mark"; last_response }
83
+
84
+ it "returns the correct body" do
85
+ expect(subject.body).to eq("hello mark")
86
+ end
87
+ it "returns the correct status code" do
88
+ expect(subject.status).to eq(200)
89
+ end
90
+ end
42
91
  end
43
92
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Appsignal::Grape do
4
4
  it "has a version" do
5
- Appsignal::Grape::VERSION.should_not be_nil
5
+ expect(Appsignal::Grape::VERSION).to_not be_nil
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Madsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appsignal
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>'
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.7'
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: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: grape
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>'
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>'
38
+ - - ">"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.14'
83
83
  description: appsignal integration for grape
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .rspec
92
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
93
  - CHANGELOG.md
94
94
  - Gemfile
95
95
  - Guardfile
@@ -113,17 +113,17 @@ require_paths:
113
113
  - lib
114
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.0.14
126
+ rubygems_version: 2.2.2
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: appsignal integration for grape