yabeda-grape 0.2.0 → 0.2.0.1
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/yabeda/grape.rb +15 -5
- data/lib/yabeda/grape/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb8d386795e0faab4a984b2dd3c0fed32d57b9fa37eeadd415ad647ad3688d7b
|
4
|
+
data.tar.gz: c08679820788f815d2676d8aced409d658035d1809f9ffa2046a5f15b197a1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f36c90b42738159290ef31ac90fa4b90a3924e099b506cd095f7eb7337771e19db2234825ce53d64513db615ef9e891f5a98b58b4c932399eb82d1ea9b8a74d2
|
7
|
+
data.tar.gz: 6c7212a9d2b50ba1d39ab1143c8f5e041df2385d2e57519fc7a176dfb0ce57423c89411d308258ca7f3c04ce60ac62c3a9f8fbb9c17abc38db7b72cd2b4892ca
|
data/lib/yabeda/grape.rb
CHANGED
@@ -24,11 +24,7 @@ module Yabeda
|
|
24
24
|
ActiveSupport::Notifications.subscribe 'endpoint_run.grape' do |*args|
|
25
25
|
event = ActiveSupport::Notifications::Event.new(*args)
|
26
26
|
|
27
|
-
labels =
|
28
|
-
method: event.payload[:endpoint].options[:method].first.downcase,
|
29
|
-
path: event.payload[:endpoint].route.path,
|
30
|
-
status: event.payload[:endpoint].status
|
31
|
-
}
|
27
|
+
next unless (labels = Yabeda::Grape.extract_labels(event))
|
32
28
|
|
33
29
|
grape_requests_total.increment(labels)
|
34
30
|
grape_request_duration.measure(labels, Yabeda::Grape.ms2s(event.duration))
|
@@ -39,6 +35,20 @@ module Yabeda
|
|
39
35
|
def ms2s(ms)
|
40
36
|
(ms.to_f / 1000).round(3)
|
41
37
|
end
|
38
|
+
|
39
|
+
def extract_labels(event)
|
40
|
+
return unless (endpoint = event.payload[:endpoint])
|
41
|
+
|
42
|
+
# endpoint.route.path can throw an error in Grape inside_route.rb, which
|
43
|
+
# is caught below
|
44
|
+
path = endpoint.route&.path # path description (e.g. /user/{id}.json)
|
45
|
+
method = endpoint.options[:method]&.first&.downcase # http method
|
46
|
+
status = endpoint.status # http code
|
47
|
+
|
48
|
+
{ method: method, path: path, status: status }
|
49
|
+
rescue StandardError
|
50
|
+
nil
|
51
|
+
end
|
42
52
|
end
|
43
53
|
end
|
44
54
|
end
|
data/lib/yabeda/grape/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
4
|
+
version: 0.2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadym Filipov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yabeda
|