grape-appsignal 0.0.5 → 0.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/lib/grape-appsignal/middleware.rb +7 -5
- data/lib/grape-appsignal/version.rb +1 -1
- data/spec/grape-appsignal/middleware_spec.rb +10 -5
- 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: dbcec5bbe2309a4d6830fd69ba1a5d265a52a5a5
|
4
|
+
data.tar.gz: d934ad23a9c540929fd13d637109bd906d5601c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04317616fc5aee9fb4297c8733eb5b95c2240393eceea51634070beff08df2010daedef41ed046b6a56f7846d960c806fb160fb54b566aacf1e9903a9c79921b
|
7
|
+
data.tar.gz: 4eef7f5e6a39550ce9770858e6786272a8300b1b782a283728c122fa4a80e712db72e7c263a03e33388e9eee5b2119c413b84e36fd39d95ab4bb9ac345589102
|
@@ -9,12 +9,14 @@ module Appsignal
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
-
|
13
|
-
|
12
|
+
method = env['REQUEST_METHOD']
|
13
|
+
metric_path = env['PATH_INFO'].nil? ? ".api" : env['PATH_INFO'].gsub("/", ".")
|
14
14
|
request_path = env['api.endpoint'].routes.first.route_path[1..-1].gsub(/\(\.:format\)\z/, "")
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
|
16
|
+
metric_name = "process_action.grape#{metric_path}"
|
17
|
+
action = "#{method}#{metric_path}"
|
18
|
+
|
19
|
+
ActiveSupport::Notifications.instrument(metric_name, { method: method, path: request_path, action: action } ) do |payload|
|
18
20
|
@app.call(env)
|
19
21
|
end
|
20
22
|
end
|
@@ -3,9 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe Appsignal::Grape::Middleware do
|
4
4
|
|
5
5
|
class TestAPI < Grape::API
|
6
|
+
prefix "api"
|
7
|
+
version "v1"
|
6
8
|
use Appsignal::Grape::Middleware
|
7
|
-
|
8
|
-
|
9
|
+
|
10
|
+
resource :hello do
|
11
|
+
get ':name' do
|
12
|
+
"hello #{params['name']}"
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
11
16
|
|
@@ -16,17 +21,17 @@ describe Appsignal::Grape::Middleware do
|
|
16
21
|
|
17
22
|
before(:all) do
|
18
23
|
@events = []
|
19
|
-
ActiveSupport::Notifications.subscribe('process_action.api.hello.mark') do |*args|
|
24
|
+
ActiveSupport::Notifications.subscribe('process_action.grape.api.v1.hello.mark') do |*args|
|
20
25
|
@events << ActiveSupport::Notifications::Event.new(*args)
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
29
|
before(:each) do
|
25
|
-
get "/hello/mark"
|
30
|
+
get "api/v1/hello/mark"
|
26
31
|
end
|
27
32
|
|
28
33
|
it do
|
29
|
-
should == { method: "GET" , path: "hello/:name", action: "GET
|
34
|
+
should == { method: "GET" , path: "api/:version/hello/:name", action: "GET.api.v1.hello.mark"}
|
30
35
|
end
|
31
36
|
|
32
37
|
context "verify the api request" do
|