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 +4 -4
- data/lib/grape-appsignal/middleware.rb +15 -3
- data/lib/grape-appsignal/version.rb +1 -1
- data/spec/grape-appsignal/middleware_spec.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca276a652910634f9bc78d02cea3c704f9322be
|
4
|
+
data.tar.gz: 8516f43b625fcf4bb519d03cb6a8d2a1b6488cd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 = "
|
21
|
-
action = action.
|
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)
|
@@ -8,7 +8,7 @@ describe Appsignal::Grape::Middleware do
|
|
8
8
|
use Appsignal::Grape::Middleware
|
9
9
|
|
10
10
|
resource :hello do
|
11
|
-
get '
|
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: "
|
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: "
|
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")
|