grape-appsignal 0.3.1 → 0.4.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: 858d3282919c11fa61d0b327def403754a7f09a3
4
- data.tar.gz: cc176dc11602e423482b51bd1a4c20d53ee75ee6
3
+ metadata.gz: eca276a652910634f9bc78d02cea3c704f9322be
4
+ data.tar.gz: 8516f43b625fcf4bb519d03cb6a8d2a1b6488cd4
5
5
  SHA512:
6
- metadata.gz: b1f1c0ece2081125e6e78f82a0ea1ce9e2143743637737017cd5c5c7d2d556081963e94c9de56dd5225936495a19ae0baa031adefa78d084815617c546d9492b
7
- data.tar.gz: 3ed231a95f68584ece63014e2f66472e9e8f5e2de6ac8fe689c1715f33702fe43bd89eb62c4d50df7ed9d1fc8b52609790a09fc768626ce47206055b63e941a1
6
+ metadata.gz: b4b817a504e242701e9b087158679dd4d41d5c29535c5bf355829ea1a23640a6e1b1870c450a7ee73abb7646f232b50deca4fed7e088336d411c7e5b31e88671
7
+ data.tar.gz: 5f6be88e8678dfbede37021e9f7d33a5fccaab04819885029c3cce38cfaeb4ee83ca8ada2327920af5932a7a8db1ee1ba43ca7b716be207b48d2d72f9335ea0e
@@ -12,13 +12,25 @@ module Appsignal
12
12
  req = ::Rack::Request.new(env)
13
13
  method = env['REQUEST_METHOD']
14
14
 
15
- request_path = env['api.endpoint'].routes.first.route_path[1..-1].sub(/\(\.:format\)\z/, "")
15
+ api_endpoint = env['api.endpoint']
16
+
17
+ puts api_endpoint.method_name
18
+
19
+ method_name = api_endpoint.method_name.gsub(/ ?[ \/]/, '/') if api_endpoint && api_endpoint.method_name
20
+
21
+ request_path = api_endpoint.routes.first.route_path[1..-1].sub(/\(\.:format\)\z/, "")
16
22
 
17
23
  metric_name = "process_action.grape.#{req.request_method}.#{request_path}"
18
24
  metric_name = metric_name.gsub(/\/:?/, '.')
19
25
 
20
- action = "GRAPE#{env['PATH_INFO']}"
21
- action = action.gsub(/\//, '::')
26
+ action = "Grape"
27
+ action = action + "(#{api_endpoint.settings[:version].first})" if
28
+ api_endpoint.settings[:version] && api_endpoint.settings[:version].first
29
+ action = action + "(#{api_endpoint.settings[:root_prefix]})" if
30
+ api_endpoint.settings && api_endpoint.settings[:root_prefix]
31
+
32
+ action = action + "::#{method_name}"
33
+ #action = action.gsub(/ ?/, '/')
22
34
 
23
35
  ActiveSupport::Notifications.instrument(metric_name, { method: method, path: request_path, action: action, class: "API" } ) do |payload|
24
36
  @app.call(env)
@@ -1,5 +1,5 @@
1
1
  module Appsignal
2
2
  module Grape
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ describe Appsignal::Grape::Middleware do
8
8
  use Appsignal::Grape::Middleware
9
9
 
10
10
  resource :hello do
11
- get ':name' do
11
+ get 'name/:name' do
12
12
  "hello #{params['name']}"
13
13
  end
14
14
  end
@@ -37,7 +37,7 @@ describe Appsignal::Grape::Middleware do
37
37
 
38
38
  it "delivers a payload consistent with the API call."do
39
39
  expect(subject.payload ).to eq(
40
- { method: "GET" , path: "hello/:id", action: "GRAPE::hello::1337", class: "API"}
40
+ { method: "GET" , path: "hello/:id", action: "Grape::GET/hello/:id", class: "API"}
41
41
  )
42
42
  end
43
43
 
@@ -66,20 +66,20 @@ describe Appsignal::Grape::Middleware do
66
66
  end
67
67
  end
68
68
 
69
- subject { get "api/v1/hello/mark"; events.last}
69
+ subject { get "api/v1/hello/name/mark"; events.last}
70
70
 
71
71
  it "delivers a payload consistent with the API call."do
72
72
  expect(subject.payload ).to eq(
73
- { method: "GET" , path: "api/:version/hello/:name", action: "GRAPE::api::v1::hello::mark", class: "API"}
73
+ { method: "GET" , path: "api/:version/hello/name/:name", action: "Grape(v1)(api)::GET/hello/name/:name", class: "API"}
74
74
  )
75
75
  end
76
76
 
77
77
  it "names the payload consistent with the API call."do
78
- expect(subject.name ).to eq("process_action.grape.GET.api.version.hello.name")
78
+ expect(subject.name ).to eq("process_action.grape.GET.api.version.hello.name.name")
79
79
  end
80
80
 
81
81
  context "verify the api request" do
82
- subject{ get "api/v1/hello/mark"; last_response }
82
+ subject{ get "api/v1/hello/name/mark"; last_response }
83
83
 
84
84
  it "returns the correct body" do
85
85
  expect(subject.body).to eq("hello mark")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Madsen