griffin-interceptors 0.1.8 → 0.1.9

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: 69d23b2ed7f3196a4c72393c88145cf9c2927f5d36c005bc5ab0773b4343142f
4
- data.tar.gz: d8eb1abff86e60b36952ccdfc1890a9ff247e44f900f4c409d6b549958586291
3
+ metadata.gz: 239fb7f3036b63120fdeb63eeb5504848b95a1e89d34708186fec7fb7b492203
4
+ data.tar.gz: de98b38b9a0ee827b439948cf0179da9ab2f2bcb08b06da2db05de23403a95fa
5
5
  SHA512:
6
- metadata.gz: 85155625fcab199a6289766fbe30b3bcf19609cfd3493243c5f7e0d4573f63baa2dc1cf4437f6b0f51d5fbc1dcc01a7f8c76b33691a3e26c5a7707e6c454564a
7
- data.tar.gz: b0018e9838a89b0f455a48a680f4ff42d663624a214df34f7812f32efdbff639096c0bd8a424355df2841e1061254ea0bc61c836fa4f32bb3a25719b41d26c91
6
+ metadata.gz: 5051fa9479be355ae9a5982dfffd6896149c7261e9bea9f75ab8db3d72752eda04546eeeb12fdcb52b672bc7a60b7420806c1e782482dfa57b426b818bfee014
7
+ data.tar.gz: f6eec90328bd4aa6e7617a9b2bacdbcf7512565d3b97186ef39ff98a49fb74719c84c94270c8170959c9ea5402993434593ffb88c83cbc3dd0c1e8ab27732ac0
@@ -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
- req = Request.new("/#{transaction_name}", call.metadata['user-agent'], 'POST')
27
- # ":controller" is not correct category name for gRPC, But since we want to categorized this transaction as web transactions.
28
- # https://docs.newrelic.com/docs/apm/transactions/key-transactions/introduction-key-transactions
29
- NewRelic::Agent::Transaction.start(state, :controller, transaction_name: "Controller/#{transaction_name}", request: req)
30
-
31
- begin
32
- resp = yield
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
- def build_transaction_name(service, mthd)
50
- "#{service}/#{mthd}"
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
@@ -1,5 +1,5 @@
1
1
  module Griffin
2
2
  module Interceptors
3
- VERSION = '0.1.8'.freeze
3
+ VERSION = '0.1.9'.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.8
4
+ version: 0.1.9
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-04-27 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: get_process_mem
@@ -133,7 +133,7 @@ homepage: https://github.com/cookpad/griffin-interceptors
133
133
  licenses:
134
134
  - MIT
135
135
  metadata: {}
136
- post_install_message:
136
+ post_install_message:
137
137
  rdoc_options: []
138
138
  require_paths:
139
139
  - lib
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubygems_version: 3.1.2
152
- signing_key:
152
+ signing_key:
153
153
  specification_version: 4
154
154
  summary: A collection of interceptors for griffin
155
155
  test_files: []