griffin-interceptors 0.1.5 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/griffin/interceptors/server/filtered_payload_interceptor.rb +9 -3
- data/lib/griffin/interceptors/server/logging_interceptor.rb +1 -1
- data/lib/griffin/interceptors/server/newrelic_interceptor.rb +22 -21
- data/lib/griffin/interceptors/server/raven_interceptor.rb +8 -1
- data/lib/griffin/interceptors/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 577b6e15c3329e7de3161208786195c3c294b0cd2b049dbac28cd65760ac69aa
|
4
|
+
data.tar.gz: 4b2b4735f2ddcaec02fd0edc7a7008383fc16d21153124b97c0ebe751a6b5039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ed7afe5b35e0f2d501993c627a063a76d843430e4a96855dc7495048c8dc8633b96d1c3cd009b2734168740f00b100aeaaf0e983d8ba437a80816507afcc76
|
7
|
+
data.tar.gz: 69ed67e1d0ae800429004c3d732b95ac582fac407b0c5dba5d360bae2d50ec0df2b27d313599b0b42b65f61d913327b5c2abdb9e7fca87714cbcab129a08cfbe
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'griffin/interceptors/server/payload_interceptor'
|
4
4
|
|
5
|
-
# Check actionpack exists to use ActionDispatch::Http::ParameterFilter
|
6
|
-
gem 'actionpack'
|
5
|
+
# Check actionpack exists to use ActionDispatch::Http::ParameterFilter if needed
|
6
|
+
gem 'actionpack' unless defined?(ActiveSupport::ParameterFilter)
|
7
7
|
|
8
8
|
module Griffin
|
9
9
|
module Interceptors
|
@@ -19,7 +19,13 @@ module Griffin
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
# ActionDispatch::Http::ParameterFilter is deprecated and will be removed from Rails 6.1.
|
23
|
+
parameter_filter_klass = if defined?(ActiveSupport::ParameterFilter)
|
24
|
+
ActiveSupport::ParameterFilter
|
25
|
+
else
|
26
|
+
ActionDispatch::Http::ParameterFilter
|
27
|
+
end
|
28
|
+
@parameter_filter = parameter_filter_klass.new(@filters)
|
23
29
|
end
|
24
30
|
|
25
31
|
def server_streamer(call: nil, **)
|
@@ -19,26 +19,14 @@ module Griffin
|
|
19
19
|
|
20
20
|
return yield if @ignored_services.include?(service_name)
|
21
21
|
|
22
|
-
transaction_name = build_transaction_name(service_name, method.name)
|
23
|
-
state = NewRelic::Agent::TransactionState.tl_get
|
24
|
-
|
25
22
|
# gRPC's HTTP method is fixed. https://github.com/grpc/grpc/blob/af89e8c00e796f3398b09b7daed693df2b14da56/doc/PROTOCOL-HTTP2.md
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# gRPC alway returns HTTP status code 200
|
34
|
-
state.current_transaction.http_response_code = '200'
|
35
|
-
|
36
|
-
resp
|
37
|
-
rescue => e
|
38
|
-
NewRelic::Agent::Transaction.notice_error(e)
|
39
|
-
raise e
|
40
|
-
ensure
|
41
|
-
NewRelic::Agent::Transaction.stop(state)
|
23
|
+
request = Request.new("/#{service_name}/#{method.name}", call.metadata['user-agent'], 'POST')
|
24
|
+
|
25
|
+
in_transaction("#{service_name}/#{method.name}", request) do |txn|
|
26
|
+
yield.tap do
|
27
|
+
# gRPC always returns HTTP status code 200.
|
28
|
+
txn.http_response_code = '200'
|
29
|
+
end
|
42
30
|
end
|
43
31
|
end
|
44
32
|
|
@@ -46,8 +34,21 @@ module Griffin
|
|
46
34
|
|
47
35
|
private
|
48
36
|
|
49
|
-
|
50
|
-
|
37
|
+
if Gem::Version.new(NewRelic::VERSION::STRING) >= Gem::Version.new('6.0.0')
|
38
|
+
def in_transaction(partial_name, request)
|
39
|
+
NewRelic::Agent::Tracer.in_transaction(partial_name: partial_name, category: :web, options: { request: request }) do
|
40
|
+
yield NewRelic::Agent::Tracer.current_transaction
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
def in_transaction(partial_name, request)
|
45
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
46
|
+
# Specify the controller category so that the transaction gets categorized as a web transaction.
|
47
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/5.7.0.350/lib/new_relic/agent/transaction.rb#L39.
|
48
|
+
NewRelic::Agent::Transaction.wrap(state, "Controller/#{partial_name}", :controller, request: request) do
|
49
|
+
yield state.current_transaction
|
50
|
+
end
|
51
|
+
end
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -6,7 +6,11 @@ module Griffin
|
|
6
6
|
module Interceptors
|
7
7
|
module Server
|
8
8
|
class RavenInterceptor < GRPC::ServerInterceptor
|
9
|
-
def request_response(
|
9
|
+
def request_response(call: nil, **)
|
10
|
+
if call.metadata['x-request-id']
|
11
|
+
Raven.tags_context(request_id: call.metadata['x-request-id'])
|
12
|
+
end
|
13
|
+
|
10
14
|
begin
|
11
15
|
yield
|
12
16
|
rescue => e
|
@@ -17,6 +21,9 @@ module Griffin
|
|
17
21
|
|
18
22
|
raise GRPC::Unknown.new('Internal server error')
|
19
23
|
end
|
24
|
+
ensure
|
25
|
+
Raven::Context.clear!
|
26
|
+
Raven::BreadcrumbBuffer.clear!
|
20
27
|
end
|
21
28
|
|
22
29
|
alias_method :server_streamer, :request_response
|
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.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuta Iwama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: get_process_mem
|
@@ -148,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
|
-
|
152
|
-
rubygems_version: 2.6.14.1
|
151
|
+
rubygems_version: 3.1.4
|
153
152
|
signing_key:
|
154
153
|
specification_version: 4
|
155
154
|
summary: A collection of interceptors for griffin
|