griffin-interceptors 0.1.10 → 0.1.11

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
  SHA256:
3
- metadata.gz: 577b6e15c3329e7de3161208786195c3c294b0cd2b049dbac28cd65760ac69aa
4
- data.tar.gz: 4b2b4735f2ddcaec02fd0edc7a7008383fc16d21153124b97c0ebe751a6b5039
3
+ metadata.gz: b785b3cafb37b0e0591d0711e53b26234f42e5fa030e97b1abcd0aeea1cdb7ea
4
+ data.tar.gz: 1088309028a6cc0b5ef0c9eda8d90959877104f7363bec69bc1edc74c99edee4
5
5
  SHA512:
6
- metadata.gz: 78ed7afe5b35e0f2d501993c627a063a76d843430e4a96855dc7495048c8dc8633b96d1c3cd009b2734168740f00b100aeaaf0e983d8ba437a80816507afcc76
7
- data.tar.gz: 69ed67e1d0ae800429004c3d732b95ac582fac407b0c5dba5d360bae2d50ec0df2b27d313599b0b42b65f61d913327b5c2abdb9e7fca87714cbcab129a08cfbe
6
+ metadata.gz: 185036907e1423ecbfb463ada4759865c59012e3c3fb927821f148a7cec6f5610a0398c8807e8bb44f2777ff9663a7ecdfe6bb87eef5e116c9986df9dca9e4f7
7
+ data.tar.gz: a5924cd5e8b47d68fb2ca35c0ec9274b983a7e872699921092d0e6f5546048fc583ca149f61c79bbdbfe4a8f080947baac5dbf4f5ddd9e6af8d37432fb2ed5ba
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem 'scout_apm'
4
+
5
+ require 'scout_apm/layer'
6
+ require 'scout_apm/request_manager'
7
+
8
+ module Griffin
9
+ module Interceptors
10
+ module Server
11
+ class ScoutApmInterceptor < GRPC::ServerInterceptor
12
+ # Specify the controller layer so that the transaction gets categorized as a web transaction.
13
+ LAYER_TYPE = 'Controller'
14
+
15
+ def initialize(ignored_services: [], sampling_rate: 1.0)
16
+ @ignored_services = ignored_services.map(&:service_name)
17
+ @sampling_rate = sampling_rate.to_f
18
+ end
19
+
20
+ def request_response(request: nil, call: nil, method: nil)
21
+ service_name = call.service_name
22
+ method_name = method.name
23
+
24
+ return yield if rand > @sampling_rate || @ignored_services.include?(service_name)
25
+
26
+ layer = ScoutApm::Layer.new(LAYER_TYPE, "#{service_name}/#{method_name}")
27
+
28
+ req = ScoutApm::RequestManager.lookup
29
+ req.start_layer(layer)
30
+ req.annotate_request(uri: "/#{service_name}/#{method_name}")
31
+
32
+ ScoutApm::Context.add(
33
+ request_id: call.metadata['x-request-id'],
34
+ user_agent: call.metadata['user-agent'],
35
+ )
36
+
37
+ begin
38
+ yield
39
+ rescue => e
40
+ req.error!
41
+ raise e
42
+ ensure
43
+ req.stop_layer
44
+ end
45
+ end
46
+
47
+ # For now, we don't support server_streamer, client_streamer and bidi_streamer
48
+ # alias_method :server_streamer, :request_response
49
+ # alias_method :client_streamer, :request_response
50
+ # alias_method :bidi_streamer, :request_response
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  module Griffin
2
2
  module Interceptors
3
- VERSION = '0.1.10'.freeze
3
+ VERSION = '0.1.11'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griffin-interceptors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Iwama
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: get_process_mem
@@ -125,6 +125,7 @@ files:
125
125
  - lib/griffin/interceptors/server/payload_streamer.rb
126
126
  - lib/griffin/interceptors/server/rails_exception_interceptor.rb
127
127
  - lib/griffin/interceptors/server/raven_interceptor.rb
128
+ - lib/griffin/interceptors/server/scout_apm_interceptor.rb
128
129
  - lib/griffin/interceptors/server/timeout_interceptor.rb
129
130
  - lib/griffin/interceptors/server/worker_killer_interceptor.rb
130
131
  - lib/griffin/interceptors/server/x_request_id_interceptor.rb
@@ -133,7 +134,7 @@ homepage: https://github.com/cookpad/griffin-interceptors
133
134
  licenses:
134
135
  - MIT
135
136
  metadata: {}
136
- post_install_message:
137
+ post_install_message:
137
138
  rdoc_options: []
138
139
  require_paths:
139
140
  - lib
@@ -148,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  - !ruby/object:Gem::Version
149
150
  version: '0'
150
151
  requirements: []
151
- rubygems_version: 3.1.4
152
- signing_key:
152
+ rubygems_version: 3.0.3
153
+ signing_key:
153
154
  specification_version: 4
154
155
  summary: A collection of interceptors for griffin
155
156
  test_files: []