grape-appsignal 0.0.5 → 0.1.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: ef8b6005a99f1788d2cf708e934499bd6d7938e5
4
- data.tar.gz: 64364dfa86711b95f2b48fdb4aacedad5788180b
3
+ metadata.gz: dbcec5bbe2309a4d6830fd69ba1a5d265a52a5a5
4
+ data.tar.gz: d934ad23a9c540929fd13d637109bd906d5601c6
5
5
  SHA512:
6
- metadata.gz: c08db89ea7ec6ee1d9ef30fcdd231d34e8513a094a1282fa735b4e08eb9cced781b2f70ae505e54b4c723ab089c6bdccd9279e21a6f3dab605beda2c4df5f008
7
- data.tar.gz: c5304941d5780db740801216f542910671df179f091f42200cda51c3de0873ab14b5ba681fc93270069584548f2cd83c320ffe67f3242051aa332990476f4a3a
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
- req = ::Rack::Request.new(env)
13
- metric_action = env['PATH_INFO'].gsub("/", ".")
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
- metric_name = "process_action.api#{metric_action}"
16
- action = "#{req.request_method}::#{request_path}"
17
- ActiveSupport::Notifications.instrument(metric_name, { method: req.request_method, path: request_path, action: action } ) do |payload|
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
@@ -1,5 +1,5 @@
1
1
  module Appsignal
2
2
  module Grape
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  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
- get 'hello/:name' do
8
- "hello #{params['name']}"
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::hello/:name"}
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
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.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Madsen