istox 0.1.152.1.test3 → 0.1.152.1.test4

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: 758fc766dfc65e9d4d0b23738b9b307cdcb236a6c285026b31547c90bfa394df
4
- data.tar.gz: 5be8eb757880769faa79f50a946639a5887b665331c67840d7cf7201941b9068
3
+ metadata.gz: 22172b2aecd51d7190552627a94affb11786127c3a02d0895a36560d5a372380
4
+ data.tar.gz: 30f072330cb82b023aeb7e17110a0f96d0b419ea4ea6d63f111c4d32a594678d
5
5
  SHA512:
6
- metadata.gz: 531d98e17c4ed0ab48abbd6117175874ca3a8c8dc13b4bcc065987f2b100a7157f96191dadcee1438851560ae85615b861d2c59c816e849ffdf8f1670d05f36a
7
- data.tar.gz: 7f87201248c55674239a2a86b0bd4b195e9ef29e696924ac7abe9d61be7409b9fd93e5d6efea9e6cfd5195e5d6bbb5b5ca86afa9978df0dbdaf93e41ad0a4c1f
6
+ metadata.gz: e13df624678c8cdb47aee17427564aca8349cde04fdaf209eeb22a0de96cbcca77987738050ba31b32f2fc5b0182aca2506a0f012dffd7b205f4da1893ac5691
7
+ data.tar.gz: 7e00d3da3058aea3ab84fdf6da015a0fbf867101c66931fb40db0448604081f6c92939c372a18a7cfca34155bfae4cbc3e2b6ae356f395b23dc29ee903e7c461
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.152)
4
+ istox (0.1.152.1.test2)
5
5
  awesome_print
6
+ aws-xray-sdk
6
7
  binding_of_caller
7
8
  bunny (>= 2.12.0)
8
9
  graphlient
@@ -65,8 +66,20 @@ GEM
65
66
  arel (9.0.0)
66
67
  awesome_print (1.8.0)
67
68
  aws-eventstream (1.1.0)
68
- aws-sigv4 (1.1.1)
69
+ aws-partitions (1.318.0)
70
+ aws-sdk-core (3.96.1)
71
+ aws-eventstream (~> 1, >= 1.0.2)
72
+ aws-partitions (~> 1, >= 1.239.0)
73
+ aws-sigv4 (~> 1.1)
74
+ jmespath (~> 1.0)
75
+ aws-sdk-xray (1.4.0)
76
+ aws-sdk-core (~> 3)
77
+ aws-sigv4 (~> 1.0)
78
+ aws-sigv4 (1.1.3)
69
79
  aws-eventstream (~> 1.0, >= 1.0.2)
80
+ aws-xray-sdk (0.11.4)
81
+ aws-sdk-xray (~> 1.4.0)
82
+ multi_json (~> 1)
70
83
  binding_of_caller (0.8.0)
71
84
  debug_inspector (>= 0.0.1)
72
85
  builder (3.2.4)
@@ -98,18 +111,18 @@ GEM
98
111
  ffi (1.12.2)
99
112
  globalid (0.4.2)
100
113
  activesupport (>= 4.2.0)
101
- google-protobuf (3.11.4-universal-darwin)
114
+ google-protobuf (3.12.1)
102
115
  googleapis-common-protos-types (1.0.5)
103
116
  google-protobuf (~> 3.11)
104
117
  graphlient (0.3.7)
105
118
  faraday
106
119
  faraday_middleware
107
120
  graphql-client
108
- graphql (1.10.6)
121
+ graphql (1.10.10)
109
122
  graphql-client (0.16.0)
110
123
  activesupport (>= 3.0)
111
124
  graphql (~> 1.8)
112
- grpc (1.28.0-universal-darwin)
125
+ grpc (1.28.0)
113
126
  google-protobuf (~> 3.11)
114
127
  googleapis-common-protos-types (~> 1.0)
115
128
  grpc-tools (1.28.0)
@@ -128,6 +141,7 @@ GEM
128
141
  grpc (~> 1.10)
129
142
  grpc-tools (~> 1.10)
130
143
  slop (~> 4.6)
144
+ jmespath (1.4.0)
131
145
  listen (3.0.8)
132
146
  rb-fsevent (~> 0.9, >= 0.9.4)
133
147
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -143,12 +157,13 @@ GEM
143
157
  mini_mime (1.0.1)
144
158
  mini_portile2 (2.4.0)
145
159
  minitest (5.14.0)
160
+ multi_json (1.14.1)
146
161
  multipart-post (2.1.1)
147
162
  nio4r (2.3.1)
148
163
  nokogiri (1.10.9)
149
164
  mini_portile2 (~> 2.4.0)
150
165
  oj (3.10.6)
151
- ougai (1.8.3)
166
+ ougai (1.8.5)
152
167
  oj (~> 3.10)
153
168
  paranoia (2.4.2)
154
169
  activerecord (>= 4.0, < 6.1)
@@ -185,7 +200,7 @@ GEM
185
200
  rake (>= 0.8.7)
186
201
  thor (>= 0.19.0, < 2.0)
187
202
  rake (10.5.0)
188
- rb-fsevent (0.10.3)
203
+ rb-fsevent (0.10.4)
189
204
  rb-inotify (0.10.1)
190
205
  ffi (~> 1.0)
191
206
  redis (4.1.3)
@@ -243,7 +258,7 @@ GEM
243
258
  tzinfo (1.2.6)
244
259
  thread_safe (~> 0.1)
245
260
  uniform_notifier (1.11.0)
246
- vault (0.13.0)
261
+ vault (0.13.2)
247
262
  aws-sigv4
248
263
  websocket-driver (0.7.0)
249
264
  websocket-extensions (>= 0.1.0)
data/istox.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency 'awesome_print'
34
+ spec.add_dependency 'aws-xray-sdk'
34
35
  spec.add_dependency 'binding_of_caller'
35
36
  spec.add_dependency 'bunny', '>= 2.12.0'
36
37
  spec.add_dependency 'graphlient'
@@ -3,8 +3,6 @@ require 'istox/helpers/logger'
3
3
  module Istox
4
4
  class GrpcClient
5
5
  class << self
6
- attr_accessor :client_metadata_hook
7
-
8
6
  def add_host(host_type, url)
9
7
  @@hosts = {} unless defined?(@@hosts)
10
8
 
@@ -50,7 +48,7 @@ module Istox
50
48
  log.info "Calling method in grpc method: #{method.inspect}, params: #{keyword_args.inspect}"
51
49
  t1 = Time.now
52
50
 
53
- result = get_host(host_type, service).call(method, keyword_args, client_metadata)
51
+ result = get_host(host_type, service).call(method, keyword_args)
54
52
  log.info "Time taken for grpc execution: #{Time.now - t1} seconds"
55
53
 
56
54
  return_values = ::Istox::CommonHelper.to_open_struct(result.message)
@@ -96,16 +94,6 @@ module Istox
96
94
  channel_args: default_channel_options
97
95
  }
98
96
  end
99
-
100
- def client_metadata
101
- return {} if @client_metadata_hook.blank?
102
-
103
- unless @client_metadata_hook.methods.include?(:inject_metadata)
104
- raise StandardError, 'Unable to find method .inject_metadata, have you forgotten to define it in your hook?'
105
- end
106
-
107
- @client_metadata_hook.inject_metadata
108
- end
109
97
  end
110
98
  end
111
99
  end
@@ -0,0 +1,18 @@
1
+ require 'istox/helpers/logger'
2
+ require 'aws-xray-sdk'
3
+
4
+ module Istox
5
+ module Xray
6
+ class GrpcClientXrayInterceptor < ::Gruf::Interceptors::ClientInterceptor
7
+ def call(request_context:)
8
+ XRay.recorder.begin_subsegment name: "GrpcRequest.#{request_context.method}"
9
+
10
+ request_context.metadata[:xray_trace_id] = XRay.recorder.current_segment.trace_id
11
+
12
+ yield
13
+
14
+ XRay.recorder.end_subsegment
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'istox/helpers/logger'
2
+ require 'aws-xray-sdk'
3
+
4
+ module Istox
5
+ module Xray
6
+ class GrpcServerXrayInterceptor < ::Gruf::Interceptors::ServerInterceptor
7
+ def call
8
+ meta = request.active_call.metadata
9
+ trace_id = (meta['xray_trace_id'] if meta.present? && meta.key?('xray_trace_id'))
10
+
11
+ XRay.recorder.begin_segment("GrpcHandler.#{request.method_key}", trace_id: trace_id)
12
+
13
+ result = yield # this returns the protobuf message
14
+
15
+ XRay.recorder.end_segment
16
+
17
+ result
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'istox/helpers/logger'
2
+ require 'aws-xray-sdk'
3
+
4
+ module Istox
5
+ module Xray
6
+ class RabbitmqPublisherInterceptor
7
+ def call; end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'istox/helpers/logger'
2
+ require 'aws-xray-sdk'
3
+
4
+ module Istox
5
+ module Xray
6
+ class RabbitmqSubscriberInterceptor
7
+ def call; end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ require 'istox/helpers/logger'
2
+ require 'istox/helpers/xray/grpc_client_xray_interceptor'
3
+ require 'istox/helpers/xray/grpc_server_xray_interceptor'
4
+ require 'istox/helpers/xray/rabbitmq_publisher_interceptor'
5
+ require 'istox/helpers/xray/rabbitmq_subscriber_interceptor'
6
+ require 'istox/helpers/logger'
7
+ require 'aws-xray-sdk'
8
+
9
+ module Istox
10
+ module Xray
11
+ class XrayInitializer
12
+ class << self
13
+ ## input gruf config to enable gruf/grpc tracing, eg. Gruf.configure do |config|
14
+ ## set enable_rabbitmq_trace to enable rabbitmq tracing
15
+ def init(service_name, gruf_config: nil, enable_rabbitmq_trace: nil)
16
+ Rails.application.config.xray = {
17
+ # default segment name generated by XRay middleware
18
+ daemon_address: ENV['AWS_XRAY_DAEMON_ADDRESS'],
19
+ name: service_name,
20
+ patch: %I[net_http aws_sdk],
21
+ # record db transactions as subsegments
22
+ active_record: true
23
+ }
24
+
25
+ if gruf_config.present?
26
+ gruf_config.interceptors.use(::Istox::Xray::GrpcServerXrayInterceptor)
27
+ ::Istox::GrpcClient.add_interceptors(::Istox::Xray::GrpcClientXrayInterceptor)
28
+ end
29
+
30
+ return unless enable_rabbitmq_trace == true
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.152.1.test3'.freeze
2
+ VERSION = '0.1.152.1.test4'.freeze
3
3
  end
data/lib/istox.rb CHANGED
@@ -35,6 +35,13 @@ module Istox
35
35
  require 'istox/helpers/redis'
36
36
  require 'istox/helpers/dlm'
37
37
  require 'istox/helpers/remote_model_cache'
38
+
39
+ require 'istox/helpers/xray/grpc_client_xray_interceptor'
40
+ require 'istox/helpers/xray/grpc_server_xray_interceptor'
41
+ require 'istox/helpers/xray/rabbitmq_publisher_interceptor'
42
+ require 'istox/helpers/xray/rabbitmq_subscriber_interceptor'
43
+ require 'istox/helpers/xray/xray_initializer'
44
+
38
45
  require 'istox/models/blockchain_receipt'
39
46
  require 'istox/models/concerns/blockchain_receipt_query'
40
47
  require 'istox/consumers/blockchain_status_handler'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.152.1.test3
4
+ version: 0.1.152.1.test4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-xray-sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: binding_of_caller
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -452,6 +466,11 @@ files:
452
466
  - lib/istox/helpers/result_handler.rb
453
467
  - lib/istox/helpers/subscriber.rb
454
468
  - lib/istox/helpers/vault.rb
469
+ - lib/istox/helpers/xray/grpc_client_xray_interceptor.rb
470
+ - lib/istox/helpers/xray/grpc_server_xray_interceptor.rb
471
+ - lib/istox/helpers/xray/rabbitmq_publisher_interceptor.rb
472
+ - lib/istox/helpers/xray/rabbitmq_subscriber_interceptor.rb
473
+ - lib/istox/helpers/xray/xray_initializer.rb
455
474
  - lib/istox/interfaces/chainhub/transaction.rb
456
475
  - lib/istox/models/blockchain_receipt.rb
457
476
  - lib/istox/models/concerns/blockchain_receipt_query.rb