jcw 0.2.3 → 0.4.0

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: 2b1e12954a296bbc3e7413110a7b151fe38c0d422e156cebbd5ae7157bbe111b
4
- data.tar.gz: '00488dffa129ca3c4a2b45fb3f8f947f1dec9b4310b8a900813426afa397fc92'
3
+ metadata.gz: b28827609084bf816de36fb6707419d9da55dd83856a669992933e44412614ef
4
+ data.tar.gz: 63063414a4a39e7b1a89705c3135ae9feb1fefc998f6de642225ea881b2e8ea4
5
5
  SHA512:
6
- metadata.gz: 61b7221435873848d3bb19e0e9ca30157c127601633fb4ca129fbc150fe5da98f2013bdc334139c455801fcb7fe90db8fb47809a4b1bba86f4e58d8ab1034162
7
- data.tar.gz: 1140c437317341c6836f196711496f9dedb0e0959571d7f882c9750f6c690ca3026dd807916fd958c7a7628587cea5e985da1b55631f9b4fcbc15691a8cf7e49
6
+ metadata.gz: 84baaa8e3d2acd65376ffa606009c1b6ce08490b0631fff47fc76b9a2215655a0c8fd06ab00697f1fa9026b6acd55e2a6da5302c07db0b6368dee48421a68e81
7
+ data.tar.gz: 95e34bfcd7c274dc049eef0f7763945cb8ee55911679ef5dc7fb5360ea54ccc2aad361ccd6bfb4f09a3cf656ccb70895f9e34ab5bb7b015b5062ad1bba77f860
@@ -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.4, 3.0.0, 3.0.1, 3.0.2, 3.1.0]
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
@@ -11,6 +11,9 @@ RSpec/EmptyLineAfterHook:
11
11
  Naming/RescuedExceptionsVariableName:
12
12
  Enabled: false
13
13
 
14
+ Style/CaseEquality:
15
+ Enabled: false
16
+
14
17
  Style/HashConversion:
15
18
  Exclude:
16
19
  - spec/**/*_spec.rb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jcw (0.2.3)
4
+ jcw (0.4.0)
5
5
  activesupport (>= 5.0, < 7.0.0)
6
6
  gruf (~> 2.10)
7
7
  httprb-opentracing (~> 0.4.0)
@@ -10,20 +10,20 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actionpack (6.1.4.4)
14
- actionview (= 6.1.4.4)
15
- activesupport (= 6.1.4.4)
13
+ actionpack (6.1.6.1)
14
+ actionview (= 6.1.6.1)
15
+ activesupport (= 6.1.6.1)
16
16
  rack (~> 2.0, >= 2.0.9)
17
17
  rack-test (>= 0.6.3)
18
18
  rails-dom-testing (~> 2.0)
19
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.1.4.4)
21
- activesupport (= 6.1.4.4)
20
+ actionview (6.1.6.1)
21
+ activesupport (= 6.1.6.1)
22
22
  builder (~> 3.1)
23
23
  erubi (~> 1.4)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activesupport (6.1.4.4)
26
+ activesupport (6.1.6.1)
27
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
28
  i18n (>= 1.6, < 2)
29
29
  minitest (>= 5.1)
@@ -37,7 +37,7 @@ GEM
37
37
  bundler (>= 1.2.0, < 3)
38
38
  thor (~> 1.0)
39
39
  coderay (1.1.3)
40
- concurrent-ruby (1.1.9)
40
+ concurrent-ruby (1.1.10)
41
41
  crass (1.0.6)
42
42
  diff-lcs (1.4.4)
43
43
  docile (1.4.0)
@@ -49,22 +49,31 @@ GEM
49
49
  ffi-compiler (1.0.1)
50
50
  ffi (>= 1.0.0)
51
51
  rake
52
- google-protobuf (3.19.2)
53
- googleapis-common-protos-types (1.3.0)
52
+ google-protobuf (3.21.3)
53
+ google-protobuf (3.21.3-x86_64-darwin)
54
+ google-protobuf (3.21.3-x86_64-linux)
55
+ googleapis-common-protos-types (1.3.2)
54
56
  google-protobuf (~> 3.14)
55
- grpc (1.41.0)
56
- google-protobuf (~> 3.17)
57
+ grpc (1.48.0)
58
+ google-protobuf (~> 3.19)
57
59
  googleapis-common-protos-types (~> 1.0)
58
- grpc-tools (1.41.0)
59
- gruf (2.12.0)
60
+ grpc (1.48.0-x86_64-darwin)
61
+ google-protobuf (~> 3.19)
62
+ googleapis-common-protos-types (~> 1.0)
63
+ grpc (1.48.0-x86_64-linux)
64
+ google-protobuf (~> 3.19)
65
+ googleapis-common-protos-types (~> 1.0)
66
+ grpc-tools (1.48.0)
67
+ gruf (2.15.1)
60
68
  activesupport (> 4)
61
69
  concurrent-ruby (> 1)
62
70
  e2mmap (>= 0.1)
63
- grpc (~> 1.10, <= 1.41.0)
64
- grpc-tools (~> 1.10, <= 1.41.0)
71
+ grpc (~> 1.10)
72
+ grpc-tools (~> 1.10)
65
73
  json (>= 2.3)
66
74
  slop (>= 4.6)
67
75
  thwait (>= 0.1)
76
+ zeitwerk (>= 2)
68
77
  http (5.0.4)
69
78
  addressable (~> 2.8)
70
79
  http-cookie (~> 1.0)
@@ -77,56 +86,56 @@ GEM
77
86
  ffi-compiler (>= 1.0, < 2.0)
78
87
  httprb-opentracing (0.4.0)
79
88
  opentracing (~> 0.5.0)
80
- i18n (1.8.11)
89
+ i18n (1.12.0)
81
90
  concurrent-ruby (~> 1.0)
82
91
  jaeger-client (1.1.0)
83
92
  opentracing (~> 0.3)
84
93
  thrift
85
- json (2.6.1)
94
+ json (2.6.2)
86
95
  llhttp-ffi (0.4.0)
87
96
  ffi-compiler (~> 1.0)
88
97
  rake (~> 13.0)
89
- loofah (2.13.0)
98
+ loofah (2.18.0)
90
99
  crass (~> 1.0.2)
91
100
  nokogiri (>= 1.5.9)
92
101
  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)
102
+ mini_portile2 (2.8.0)
103
+ minitest (5.16.2)
104
+ nokogiri (1.13.8)
105
+ mini_portile2 (~> 2.8.0)
97
106
  racc (~> 1.4)
98
- nokogiri (1.12.5-x86_64-darwin)
107
+ nokogiri (1.13.8-x86_64-darwin)
99
108
  racc (~> 1.4)
100
- nokogiri (1.12.5-x86_64-linux)
109
+ nokogiri (1.13.8-x86_64-linux)
101
110
  racc (~> 1.4)
102
111
  opentracing (0.5.0)
103
112
  opentracing_test_tracer (0.1.1)
104
113
  opentracing
105
- parallel (1.21.0)
106
- parser (3.0.3.2)
114
+ parallel (1.22.1)
115
+ parser (3.1.2.0)
107
116
  ast (~> 2.4.1)
108
117
  pry (0.14.1)
109
118
  coderay (~> 1.1)
110
119
  method_source (~> 1.0)
111
120
  public_suffix (4.0.6)
112
121
  racc (1.6.0)
113
- rack (2.2.3)
114
- rack-test (1.1.0)
115
- rack (>= 1.0, < 3)
122
+ rack (2.2.4)
123
+ rack-test (2.0.2)
124
+ rack (>= 1.3)
116
125
  rails-dom-testing (2.0.3)
117
126
  activesupport (>= 4.2.0)
118
127
  nokogiri (>= 1.6)
119
- rails-html-sanitizer (1.4.2)
128
+ rails-html-sanitizer (1.4.3)
120
129
  loofah (~> 2.3)
121
- railties (6.1.4.4)
122
- actionpack (= 6.1.4.4)
123
- activesupport (= 6.1.4.4)
130
+ railties (6.1.6.1)
131
+ actionpack (= 6.1.6.1)
132
+ activesupport (= 6.1.6.1)
124
133
  method_source
125
- rake (>= 0.13)
134
+ rake (>= 12.2)
126
135
  thor (~> 1.0)
127
- rainbow (3.0.0)
136
+ rainbow (3.1.1)
128
137
  rake (13.0.6)
129
- regexp_parser (2.2.0)
138
+ regexp_parser (2.5.0)
130
139
  rexml (3.2.5)
131
140
  rspec (3.10.0)
132
141
  rspec-core (~> 3.10.0)
@@ -141,37 +150,36 @@ GEM
141
150
  diff-lcs (>= 1.2.0, < 2.0)
142
151
  rspec-support (~> 3.10.0)
143
152
  rspec-support (3.10.3)
144
- rubocop (1.17.0)
153
+ rubocop (1.30.1)
145
154
  parallel (~> 1.10)
146
- parser (>= 3.0.0.0)
155
+ parser (>= 3.1.0.0)
147
156
  rainbow (>= 2.2.2, < 4.0)
148
157
  regexp_parser (>= 1.8, < 3.0)
149
- rexml
150
- rubocop-ast (>= 1.7.0, < 2.0)
158
+ rexml (>= 3.2.5, < 4.0)
159
+ rubocop-ast (>= 1.18.0, < 2.0)
151
160
  ruby-progressbar (~> 1.7)
152
161
  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)
162
+ rubocop-ast (1.19.1)
163
+ parser (>= 3.1.1.0)
164
+ rubocop-config-umbrellio (1.30.0.65)
165
+ rubocop (~> 1.30.0)
166
+ rubocop-performance (~> 1.14.0)
167
+ rubocop-rails (~> 2.14.2)
168
+ rubocop-rake (~> 0.6.0)
169
+ rubocop-rspec (~> 2.11.1)
170
+ rubocop-sequel (~> 0.3.3)
171
+ rubocop-performance (1.14.3)
172
+ rubocop (>= 1.7.0, < 2.0)
164
173
  rubocop-ast (>= 0.4.0)
165
- rubocop-rails (2.9.1)
174
+ rubocop-rails (2.14.2)
166
175
  activesupport (>= 4.2.0)
167
176
  rack (>= 1.1)
168
- rubocop (>= 0.90.0, < 2.0)
169
- rubocop-rake (0.5.1)
170
- rubocop
171
- rubocop-rspec (2.2.0)
177
+ rubocop (>= 1.7.0, < 2.0)
178
+ rubocop-rake (0.6.0)
172
179
  rubocop (~> 1.0)
173
- rubocop-ast (>= 1.1.0)
174
- rubocop-sequel (0.2.0)
180
+ rubocop-rspec (2.11.1)
181
+ rubocop (~> 1.19)
182
+ rubocop-sequel (0.3.4)
175
183
  rubocop (~> 1.0)
176
184
  ruby-progressbar (1.11.0)
177
185
  simplecov (0.21.2)
@@ -181,18 +189,18 @@ GEM
181
189
  simplecov-html (0.12.3)
182
190
  simplecov-lcov (0.8.0)
183
191
  simplecov_json_formatter (0.1.3)
184
- slop (4.9.1)
185
- thor (1.1.0)
186
- thrift (0.15.0)
192
+ slop (4.9.2)
193
+ thor (1.2.1)
194
+ thrift (0.16.0)
187
195
  thwait (0.2.0)
188
196
  e2mmap
189
- tzinfo (2.0.4)
197
+ tzinfo (2.0.5)
190
198
  concurrent-ruby (~> 1.0)
191
199
  unf (0.1.4)
192
200
  unf_ext
193
201
  unf_ext (0.0.8)
194
- unicode-display_width (2.1.0)
195
- zeitwerk (2.5.1)
202
+ unicode-display_width (2.2.0)
203
+ zeitwerk (2.6.0)
196
204
 
197
205
  PLATFORMS
198
206
  ruby
@@ -215,4 +223,4 @@ DEPENDENCIES
215
223
  simplecov-lcov
216
224
 
217
225
  BUNDLED WITH
218
- 2.2.15
226
+ 2.2.31
data/README.md CHANGED
@@ -42,7 +42,7 @@ UDP Sender(default):
42
42
  hostname: "custom-hostname",
43
43
  custom_tag: "custom-tag-value",
44
44
  }
45
- config.rack_ignore_paths = %w[/api/test]
45
+ config.rack_ignore_path_patterns = ["/api/test", %r{/sidekiq}]
46
46
  end
47
47
 
48
48
  # Set middleware for wrapping all requests
@@ -60,7 +60,7 @@ TCP Sender:
60
60
  hostname: "custom-hostname",
61
61
  custom_tag: "custom-tag-value",
62
62
  }
63
- config.rack_ignore_paths = %w[/api/test]
63
+ config.rack_ignore_path_patterns = ["/api/test", %r{/sidekiq}]
64
64
  end
65
65
 
66
66
  # 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)/}) }
data/lib/jcw/config.rb CHANGED
@@ -9,7 +9,7 @@ module JCW
9
9
  :flush_interval,
10
10
  :tags,
11
11
  :grpc_ignore_methods,
12
- :rack_ignore_paths
12
+ :rack_ignore_path_patterns
13
13
 
14
14
  def enabled
15
15
  @enabled ||= false
@@ -41,8 +41,8 @@ module JCW
41
41
  @grpc_ignore_methods ||= []
42
42
  end
43
43
 
44
- def rack_ignore_paths
45
- @rack_ignore_paths ||= []
44
+ def rack_ignore_path_patterns
45
+ @rack_ignore_path_patterns ||= []
46
46
  end
47
47
  end
48
48
  end
@@ -15,7 +15,7 @@ module JCW
15
15
  # is called.
16
16
  # @param on_start_span [Proc, nil] A callback evaluated after a new span is created.
17
17
  # @param on_finish_span [Proc, nil] A callback evaluated after a span is finished.
18
- # @param ignore_paths [Array<Class>] An array of paths to be skiped by the tracer.
18
+ # @param ignore_path_patterns [Array<Class>] An array of paths to be skiped by the tracer.
19
19
  # @param errors [Array<Class>] An array of error classes to be captured by the tracer
20
20
  # as errors. Errors are **not** muted by the middleware, they're re-raised afterwards.
21
21
  def initialize(app, # rubocop:disable Metrics/ParameterLists
@@ -23,7 +23,7 @@ module JCW
23
23
  on_start_span: nil,
24
24
  on_finish_span: nil,
25
25
  trust_incoming_span: true,
26
- ignore_paths: Wrapper.config.rack_ignore_paths,
26
+ ignore_path_patterns: Wrapper.config.rack_ignore_path_patterns,
27
27
  errors: [StandardError])
28
28
  @app = app
29
29
  @tracer = tracer
@@ -31,14 +31,15 @@ module JCW
31
31
  @on_finish_span = on_finish_span
32
32
  @trust_incoming_span = trust_incoming_span
33
33
  @errors = errors
34
- @ignore_paths = ignore_paths
34
+ @ignore_path_patterns = ignore_path_patterns
35
35
  end
36
36
 
37
37
  def call(env)
38
38
  method = env[REQUEST_METHOD]
39
39
  path = env[REQUEST_PATH]
40
40
  url = env[REQUEST_URI]
41
- return @app.call(env) if @ignore_paths.include?(path)
41
+
42
+ return @app.call(env) if @ignore_path_patterns.find { |pattern| pattern === path }
42
43
 
43
44
  set_extract_env(env)
44
45
  context = @tracer.extract(OpenTracing::FORMAT_TEXT_MAP, env) if @trust_incoming_span
@@ -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.3"
4
+ VERSION = "0.4.0"
5
5
  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.3
4
+ version: 0.4.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-11 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
@@ -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