jcw 0.2.4 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7f97935444bb8d0285e96565c731f99e65df848573cc0257eb041dc90d3bf8b
4
- data.tar.gz: a119efdd207f9ebf9965cb8a62fab5c8e3541db7535e5649a14808f02a0683f9
3
+ metadata.gz: 893fa1af1110a98f454f922f84ea13c229403b33341990a28874368f87f3c1ea
4
+ data.tar.gz: 1a474d1c6e323b54187d024766255bd957f2953259d593eed2d056105f7b5537
5
5
  SHA512:
6
- metadata.gz: b70cfaecfca2e89dda7c95eb471d0169afc9deb286fb42481f36663db89c07850ef8c7d5185b7cb47658313e812d01328f95d8f68a88a8e4db6b0b37007f5a2f
7
- data.tar.gz: 14ca08c194b0c3c710670f7b9e77f6584a269366167a3ec4bfadaf042c7fa0e60776981af46b2dff7af69ed0a96fafd116585fbfa1a2721624225d9aeec399c1
6
+ metadata.gz: 640c14c81d9c8250f77a6474b51ec5520f4038cd71ffd4e913bdadb2c25dbec61b2cf27740fbbeafddba4f04b428e9576a0d853d0bfddaf4ec4e1e114d198e92
7
+ data.tar.gz: 651ff795bf933b9c66d37bf4893b2bf8b81c9c7fa6c8b25cc507f54fd068b54976db2e092fa0f64dd93b9512847c3129c941dfe3cf36f3139c969085429060e3
@@ -41,7 +41,7 @@ jobs:
41
41
  strategy:
42
42
  fail-fast: false
43
43
  matrix:
44
- ruby: [2.6, 2.7, 2.7.4, 3.0.0, 3.0.1, 3.0.2]
44
+ ruby: [2.7, 2.7.6, 3.0, 3.0.2, 3.1, 3.1.2]
45
45
  experimental: [false]
46
46
 
47
47
  steps:
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 2.7
7
7
 
8
8
  RSpec/EmptyLineAfterHook:
9
9
  Enabled: false
data/Gemfile.lock CHANGED
@@ -1,29 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jcw (0.2.4)
4
+ jcw (0.5.0)
5
5
  activesupport (>= 5.0, < 7.0.0)
6
- gruf (~> 2.10)
7
6
  httprb-opentracing (~> 0.4.0)
8
- jaeger-client (~> 1.1.0)
7
+ jaeger-client (~> 1.3.0)
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
- actionpack (6.1.4.4)
14
- actionview (= 6.1.4.4)
15
- activesupport (= 6.1.4.4)
12
+ actionpack (6.1.6.1)
13
+ actionview (= 6.1.6.1)
14
+ activesupport (= 6.1.6.1)
16
15
  rack (~> 2.0, >= 2.0.9)
17
16
  rack-test (>= 0.6.3)
18
17
  rails-dom-testing (~> 2.0)
19
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.1.4.4)
21
- activesupport (= 6.1.4.4)
19
+ actionview (6.1.6.1)
20
+ activesupport (= 6.1.6.1)
22
21
  builder (~> 3.1)
23
22
  erubi (~> 1.4)
24
23
  rails-dom-testing (~> 2.0)
25
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activesupport (6.1.4.4)
25
+ activesupport (6.1.6.1)
27
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
27
  i18n (>= 1.6, < 2)
29
28
  minitest (>= 5.1)
@@ -37,7 +36,7 @@ GEM
37
36
  bundler (>= 1.2.0, < 3)
38
37
  thor (~> 1.0)
39
38
  coderay (1.1.3)
40
- concurrent-ruby (1.1.9)
39
+ concurrent-ruby (1.1.10)
41
40
  crass (1.0.6)
42
41
  diff-lcs (1.4.4)
43
42
  docile (1.4.0)
@@ -49,22 +48,31 @@ GEM
49
48
  ffi-compiler (1.0.1)
50
49
  ffi (>= 1.0.0)
51
50
  rake
52
- google-protobuf (3.19.3)
53
- googleapis-common-protos-types (1.3.0)
51
+ google-protobuf (3.21.3)
52
+ google-protobuf (3.21.3-x86_64-darwin)
53
+ google-protobuf (3.21.3-x86_64-linux)
54
+ googleapis-common-protos-types (1.3.2)
54
55
  google-protobuf (~> 3.14)
55
- grpc (1.41.0)
56
- google-protobuf (~> 3.17)
56
+ grpc (1.48.0)
57
+ google-protobuf (~> 3.19)
57
58
  googleapis-common-protos-types (~> 1.0)
58
- grpc-tools (1.41.0)
59
- gruf (2.12.0)
59
+ grpc (1.48.0-x86_64-darwin)
60
+ google-protobuf (~> 3.19)
61
+ googleapis-common-protos-types (~> 1.0)
62
+ grpc (1.48.0-x86_64-linux)
63
+ google-protobuf (~> 3.19)
64
+ googleapis-common-protos-types (~> 1.0)
65
+ grpc-tools (1.48.0)
66
+ gruf (2.15.1)
60
67
  activesupport (> 4)
61
68
  concurrent-ruby (> 1)
62
69
  e2mmap (>= 0.1)
63
- grpc (~> 1.10, <= 1.41.0)
64
- grpc-tools (~> 1.10, <= 1.41.0)
70
+ grpc (~> 1.10)
71
+ grpc-tools (~> 1.10)
65
72
  json (>= 2.3)
66
73
  slop (>= 4.6)
67
74
  thwait (>= 0.1)
75
+ zeitwerk (>= 2)
68
76
  http (5.0.4)
69
77
  addressable (~> 2.8)
70
78
  http-cookie (~> 1.0)
@@ -77,56 +85,56 @@ GEM
77
85
  ffi-compiler (>= 1.0, < 2.0)
78
86
  httprb-opentracing (0.4.0)
79
87
  opentracing (~> 0.5.0)
80
- i18n (1.8.11)
88
+ i18n (1.12.0)
81
89
  concurrent-ruby (~> 1.0)
82
- jaeger-client (1.1.0)
90
+ jaeger-client (1.3.0)
83
91
  opentracing (~> 0.3)
84
92
  thrift
85
- json (2.6.1)
93
+ json (2.6.2)
86
94
  llhttp-ffi (0.4.0)
87
95
  ffi-compiler (~> 1.0)
88
96
  rake (~> 13.0)
89
- loofah (2.13.0)
97
+ loofah (2.18.0)
90
98
  crass (~> 1.0.2)
91
99
  nokogiri (>= 1.5.9)
92
100
  method_source (1.0.0)
93
- mini_portile2 (2.6.1)
94
- minitest (5.15.0)
95
- nokogiri (1.12.5)
96
- mini_portile2 (~> 2.6.1)
101
+ mini_portile2 (2.8.0)
102
+ minitest (5.16.2)
103
+ nokogiri (1.13.8)
104
+ mini_portile2 (~> 2.8.0)
97
105
  racc (~> 1.4)
98
- nokogiri (1.12.5-x86_64-darwin)
106
+ nokogiri (1.13.8-x86_64-darwin)
99
107
  racc (~> 1.4)
100
- nokogiri (1.12.5-x86_64-linux)
108
+ nokogiri (1.13.8-x86_64-linux)
101
109
  racc (~> 1.4)
102
110
  opentracing (0.5.0)
103
111
  opentracing_test_tracer (0.1.1)
104
112
  opentracing
105
- parallel (1.21.0)
106
- parser (3.0.3.2)
113
+ parallel (1.22.1)
114
+ parser (3.1.2.0)
107
115
  ast (~> 2.4.1)
108
116
  pry (0.14.1)
109
117
  coderay (~> 1.1)
110
118
  method_source (~> 1.0)
111
119
  public_suffix (4.0.6)
112
120
  racc (1.6.0)
113
- rack (2.2.3)
114
- rack-test (1.1.0)
115
- rack (>= 1.0, < 3)
121
+ rack (2.2.4)
122
+ rack-test (2.0.2)
123
+ rack (>= 1.3)
116
124
  rails-dom-testing (2.0.3)
117
125
  activesupport (>= 4.2.0)
118
126
  nokogiri (>= 1.6)
119
- rails-html-sanitizer (1.4.2)
127
+ rails-html-sanitizer (1.4.3)
120
128
  loofah (~> 2.3)
121
- railties (6.1.4.4)
122
- actionpack (= 6.1.4.4)
123
- activesupport (= 6.1.4.4)
129
+ railties (6.1.6.1)
130
+ actionpack (= 6.1.6.1)
131
+ activesupport (= 6.1.6.1)
124
132
  method_source
125
- rake (>= 0.13)
133
+ rake (>= 12.2)
126
134
  thor (~> 1.0)
127
- rainbow (3.0.0)
135
+ rainbow (3.1.1)
128
136
  rake (13.0.6)
129
- regexp_parser (2.2.0)
137
+ regexp_parser (2.5.0)
130
138
  rexml (3.2.5)
131
139
  rspec (3.10.0)
132
140
  rspec-core (~> 3.10.0)
@@ -141,37 +149,36 @@ GEM
141
149
  diff-lcs (>= 1.2.0, < 2.0)
142
150
  rspec-support (~> 3.10.0)
143
151
  rspec-support (3.10.3)
144
- rubocop (1.17.0)
152
+ rubocop (1.30.1)
145
153
  parallel (~> 1.10)
146
- parser (>= 3.0.0.0)
154
+ parser (>= 3.1.0.0)
147
155
  rainbow (>= 2.2.2, < 4.0)
148
156
  regexp_parser (>= 1.8, < 3.0)
149
- rexml
150
- rubocop-ast (>= 1.7.0, < 2.0)
157
+ rexml (>= 3.2.5, < 4.0)
158
+ rubocop-ast (>= 1.18.0, < 2.0)
151
159
  ruby-progressbar (~> 1.7)
152
160
  unicode-display_width (>= 1.4.0, < 3.0)
153
- rubocop-ast (1.15.0)
154
- parser (>= 3.0.1.1)
155
- rubocop-config-umbrellio (1.17.0.53)
156
- rubocop (= 1.17.0)
157
- rubocop-performance (= 1.10.0)
158
- rubocop-rails (= 2.9.1)
159
- rubocop-rake (= 0.5.1)
160
- rubocop-rspec (= 2.2.0)
161
- rubocop-sequel (= 0.2.0)
162
- rubocop-performance (1.10.0)
163
- rubocop (>= 0.90.0, < 2.0)
161
+ rubocop-ast (1.19.1)
162
+ parser (>= 3.1.1.0)
163
+ rubocop-config-umbrellio (1.30.0.65)
164
+ rubocop (~> 1.30.0)
165
+ rubocop-performance (~> 1.14.0)
166
+ rubocop-rails (~> 2.14.2)
167
+ rubocop-rake (~> 0.6.0)
168
+ rubocop-rspec (~> 2.11.1)
169
+ rubocop-sequel (~> 0.3.3)
170
+ rubocop-performance (1.14.3)
171
+ rubocop (>= 1.7.0, < 2.0)
164
172
  rubocop-ast (>= 0.4.0)
165
- rubocop-rails (2.9.1)
173
+ rubocop-rails (2.14.2)
166
174
  activesupport (>= 4.2.0)
167
175
  rack (>= 1.1)
168
- rubocop (>= 0.90.0, < 2.0)
169
- rubocop-rake (0.5.1)
170
- rubocop
171
- rubocop-rspec (2.2.0)
176
+ rubocop (>= 1.7.0, < 2.0)
177
+ rubocop-rake (0.6.0)
172
178
  rubocop (~> 1.0)
173
- rubocop-ast (>= 1.1.0)
174
- rubocop-sequel (0.2.0)
179
+ rubocop-rspec (2.11.1)
180
+ rubocop (~> 1.19)
181
+ rubocop-sequel (0.3.4)
175
182
  rubocop (~> 1.0)
176
183
  ruby-progressbar (1.11.0)
177
184
  simplecov (0.21.2)
@@ -181,18 +188,18 @@ GEM
181
188
  simplecov-html (0.12.3)
182
189
  simplecov-lcov (0.8.0)
183
190
  simplecov_json_formatter (0.1.3)
184
- slop (4.9.1)
185
- thor (1.1.0)
186
- thrift (0.15.0)
191
+ slop (4.9.2)
192
+ thor (1.2.1)
193
+ thrift (0.16.0)
187
194
  thwait (0.2.0)
188
195
  e2mmap
189
- tzinfo (2.0.4)
196
+ tzinfo (2.0.5)
190
197
  concurrent-ruby (~> 1.0)
191
198
  unf (0.1.4)
192
199
  unf_ext
193
200
  unf_ext (0.0.8)
194
- unicode-display_width (2.1.0)
195
- zeitwerk (2.5.1)
201
+ unicode-display_width (2.2.0)
202
+ zeitwerk (2.6.0)
196
203
 
197
204
  PLATFORMS
198
205
  ruby
@@ -202,6 +209,7 @@ PLATFORMS
202
209
  DEPENDENCIES
203
210
  bundler
204
211
  bundler-audit
212
+ gruf
205
213
  http
206
214
  http-parser
207
215
  jcw!
@@ -215,4 +223,4 @@ DEPENDENCIES
215
223
  simplecov-lcov
216
224
 
217
225
  BUNDLED WITH
218
- 2.2.27
226
+ 2.3.18
data/README.md CHANGED
@@ -43,6 +43,7 @@ UDP Sender(default):
43
43
  custom_tag: "custom-tag-value",
44
44
  }
45
45
  config.rack_ignore_path_patterns = ["/api/test", %r{/sidekiq}]
46
+ config.logger = Logger.new($stdout)
46
47
  end
47
48
 
48
49
  # Set middleware for wrapping all requests
@@ -61,6 +62,7 @@ TCP Sender:
61
62
  custom_tag: "custom-tag-value",
62
63
  }
63
64
  config.rack_ignore_path_patterns = ["/api/test", %r{/sidekiq}]
65
+ config.logger = Logger.new($stdout)
64
66
  end
65
67
 
66
68
  # Set middleware for wrapping all requests
data/jcw.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Wrapper for the gem 'jaeger-client' with simpler customization."
13
13
  spec.homepage = "https://github.com/Cado-Labs/jcw"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
17
17
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "activesupport", ">= 5.0", "< 7.0.0"
26
- spec.add_dependency "gruf", "~> 2.10"
27
26
  spec.add_dependency "httprb-opentracing", "~> 0.4.0"
28
- spec.add_dependency "jaeger-client", "~> 1.1.0"
27
+ spec.add_dependency "jaeger-client", "~> 1.3.0"
29
28
 
30
29
  spec.add_development_dependency "bundler"
31
30
  spec.add_development_dependency "bundler-audit"
31
+ spec.add_development_dependency "gruf"
32
32
  spec.add_development_dependency "http"
33
33
  spec.add_development_dependency "http-parser"
34
34
  spec.add_development_dependency "opentracing_test_tracer"
data/lib/jcw/config.rb CHANGED
@@ -9,7 +9,8 @@ module JCW
9
9
  :flush_interval,
10
10
  :tags,
11
11
  :grpc_ignore_methods,
12
- :rack_ignore_path_patterns
12
+ :rack_ignore_path_patterns,
13
+ :logger
13
14
 
14
15
  def enabled
15
16
  @enabled ||= false
@@ -44,5 +45,9 @@ module JCW
44
45
  def rack_ignore_path_patterns
45
46
  @rack_ignore_path_patterns ||= []
46
47
  end
48
+
49
+ def logger
50
+ @logger ||= ::Logger.new($stdout)
51
+ end
47
52
  end
48
53
  end
data/lib/jcw/init.rb CHANGED
@@ -34,6 +34,7 @@ module JCW
34
34
  encoder: Jaeger::Encoders::ThriftEncoder.new(
35
35
  service_name: config.service_name,
36
36
  tags: config.tags,
37
+ logger: config.logger,
37
38
  ),
38
39
  ),
39
40
  flush_interval: config.flush_interval,
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "gruf"
4
-
5
3
  module JCW
6
4
  module Interceptors
7
5
  module Gruf
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "gruf"
4
-
5
3
  module JCW
6
4
  module Interceptors
7
5
  module Gruf
@@ -7,12 +7,12 @@ module JCW
7
7
  IGNORED_PAYLOAD_KEYS = %i[request response headers exception exception_object].freeze
8
8
 
9
9
  def subscribe_to_event!(event)
10
- ActiveSupport::Notifications.subscribe(event) do |name, _start, _finish, _uid, payload|
11
- add(name, payload)
10
+ ActiveSupport::Notifications.subscribe(event) do |name, start, finish, _uid, payload|
11
+ add(name, payload, finish - start)
12
12
  end
13
13
  end
14
14
 
15
- def add(name, payload)
15
+ def add(name, payload, duration)
16
16
  # skip Rails internal events
17
17
  return if name.start_with?("!")
18
18
 
@@ -25,7 +25,8 @@ module JCW
25
25
  IGNORED_PAYLOAD_KEYS.each { |key| payload.delete(key) if payload.key?(key) }
26
26
  end
27
27
 
28
- span.log_kv(message: name, context: JSON.dump(payload))
28
+ duration = format("%0.3fms", duration * 1000)
29
+ span.log_kv(message: name, context: JSON.dump(payload), duration: duration)
29
30
  end
30
31
  end
31
32
  end
data/lib/jcw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JCW
4
- VERSION = "0.2.4"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/jcw/wrapper.rb CHANGED
@@ -21,8 +21,14 @@ require_relative "init"
21
21
  require_relative "subscriber"
22
22
  require_relative "http_tracer"
23
23
  require_relative "rack_tracer"
24
- require_relative "interceptors/gruf/client"
25
- require_relative "interceptors/gruf/server"
26
- require_relative "interceptors/gruf/hpack"
27
24
  require_relative "logger"
28
25
  require_relative "logger_extension"
26
+
27
+ begin
28
+ require "gruf"
29
+
30
+ require_relative "interceptors/gruf/client"
31
+ require_relative "interceptors/gruf/server"
32
+ require_relative "interceptors/gruf/hpack"
33
+ rescue LoadError
34
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Starovojtov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -31,49 +31,49 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 7.0.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: gruf
34
+ name: httprb-opentracing
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.10'
39
+ version: 0.4.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.10'
46
+ version: 0.4.0
47
47
  - !ruby/object:Gem::Dependency
48
- name: httprb-opentracing
48
+ name: jaeger-client
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.4.0
53
+ version: 1.3.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.4.0
60
+ version: 1.3.0
61
61
  - !ruby/object:Gem::Dependency
62
- name: jaeger-client
62
+ name: bundler
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 1.1.0
68
- type: :runtime
67
+ version: '0'
68
+ type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 1.1.0
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: bundler
76
+ name: bundler-audit
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
@@ -87,7 +87,7 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: bundler-audit
90
+ name: gruf
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
@@ -286,14 +286,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
286
286
  requirements:
287
287
  - - ">="
288
288
  - !ruby/object:Gem::Version
289
- version: 2.6.0
289
+ version: 2.7.0
290
290
  required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  requirements:
292
292
  - - ">="
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.1.6
296
+ rubygems_version: 3.3.7
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: Wrapper for jaeger-client