jcw 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +9 -6
- data/lib/jcw/init.rb +3 -4
- data/lib/jcw/subscriber.rb +21 -16
- data/lib/jcw/version.rb +1 -1
- data/lib/jcw/wrapper.rb +0 -1
- metadata +2 -3
- data/lib/jcw/tracing.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7621b3db92b4172f29ae46a914d6f5a33611f276dfaa17d1effeff36f16c68b
|
4
|
+
data.tar.gz: c9ac2ea12ee2862fcb762673dd5285e7422b86fe91c38a39f9fa66bd890fa83c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6558c6b64a50a283c6e9a97024ee8191fd595bb73b071ae84259ec7a61d51ab4046b6f70e33f335bedf7888f791f170375e2b7f3ab428a373259716c9acfe19
|
7
|
+
data.tar.gz: c5d6da1d532632920fdce571c254737654d0e37c7aca2d89bf8852126ae15882c3f4965461b341ecfcbf04add3a366010b103d5cd83cf2fe1df8b9c71860e15d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jcw (0.1.
|
4
|
+
jcw (0.1.3)
|
5
5
|
activesupport (>= 5.0)
|
6
6
|
httprb-opentracing (~> 0.4.0)
|
7
7
|
jaeger-client (~> 1.1.0)
|
@@ -74,12 +74,12 @@ GEM
|
|
74
74
|
method_source (1.0.0)
|
75
75
|
mini_portile2 (2.6.1)
|
76
76
|
minitest (5.14.4)
|
77
|
-
nokogiri (1.12.
|
77
|
+
nokogiri (1.12.5)
|
78
78
|
mini_portile2 (~> 2.6.1)
|
79
79
|
racc (~> 1.4)
|
80
|
-
nokogiri (1.12.
|
80
|
+
nokogiri (1.12.5-x86_64-darwin)
|
81
81
|
racc (~> 1.4)
|
82
|
-
nokogiri (1.12.
|
82
|
+
nokogiri (1.12.5-x86_64-linux)
|
83
83
|
racc (~> 1.4)
|
84
84
|
opentracing (0.5.0)
|
85
85
|
parallel (1.20.1)
|
@@ -164,7 +164,7 @@ GEM
|
|
164
164
|
simplecov-lcov (0.8.0)
|
165
165
|
simplecov_json_formatter (0.1.3)
|
166
166
|
thor (1.1.0)
|
167
|
-
thrift (0.
|
167
|
+
thrift (0.15.0)
|
168
168
|
tzinfo (2.0.4)
|
169
169
|
concurrent-ruby (~> 1.0)
|
170
170
|
unf (0.1.4)
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ gem install jcw
|
|
25
25
|
```
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
require 'jcw'
|
28
|
+
require 'jcw'
|
29
29
|
```
|
30
30
|
|
31
31
|
## Usage
|
@@ -68,17 +68,20 @@ Rails.application.middleware.use(JCW::RackTracer)
|
|
68
68
|
# Not recommended for UDP sender, because default max packet size is 65,000 bytes.
|
69
69
|
Rails.application.config.tap do |config|
|
70
70
|
config.middleware.use(
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
JCW::RackTracer,
|
72
|
+
on_finish_span: lambda do |span|
|
73
|
+
JCW::Logger.current.logs.each { |log| span.log_kv(**log) }
|
74
|
+
JCW::Logger.current.clear # Do not forget to avoid memory leaks
|
75
|
+
end,
|
74
76
|
)
|
75
|
-
|
77
|
+
|
78
|
+
config.logger.extend(JCW::LoggerExtension)
|
76
79
|
end
|
77
80
|
```
|
78
81
|
- `config.subscribe_to` - not recommended for UDP sender, because default max packet size is 65,000 bytes.
|
79
82
|
|
80
83
|
### Contributing
|
81
|
-
|
84
|
+
|
82
85
|
- Fork it ( https://github.com/Cado-Labs/jcw )
|
83
86
|
- Create your feature branch (`git checkout -b feature/my-new-feature`)
|
84
87
|
- Commit your changes (`git commit -am '[feature_context] Add some feature'`)
|
data/lib/jcw/init.rb
CHANGED
@@ -41,11 +41,10 @@ module JCW
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def activate_subscribers
|
44
|
-
|
45
|
-
return if
|
44
|
+
events = config.subscribe_to
|
45
|
+
return if events.blank?
|
46
46
|
|
47
|
-
|
48
|
-
Tracing.subscribe_tracing_events
|
47
|
+
events.each { |event| JCW::Subscriber.subscribe_to_event!(event) }
|
49
48
|
end
|
50
49
|
|
51
50
|
def init_http_tracer
|
data/lib/jcw/subscriber.rb
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module JCW
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module Subscriber
|
5
|
+
extend self
|
6
|
+
|
7
|
+
IGNORED_PAYLOAD_KEYS = %i[request response headers exception exception_object].freeze
|
8
|
+
|
9
|
+
def subscribe_to_event!(event)
|
10
|
+
ActiveSupport::Notifications.subscribe(event) do |name, _start, _finish, _uid, payload|
|
11
|
+
add(name, payload)
|
12
12
|
end
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
def add(name, payload)
|
16
|
+
# skip Rails internal events
|
17
|
+
return if name.start_with?("!")
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
19
|
+
span = OpenTracing.scope_manager.active&.span
|
20
|
+
return if span.blank?
|
21
|
+
|
22
|
+
if payload.is_a?(Hash)
|
23
|
+
# we should only mutate the copy of the payload
|
24
|
+
payload = payload.dup
|
25
|
+
IGNORED_PAYLOAD_KEYS.each { |key| payload.delete(key) if payload.key?(key) }
|
23
26
|
end
|
27
|
+
|
28
|
+
span.log_kv(message: name, context: JSON.dump(payload))
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/jcw/version.rb
CHANGED
data/lib/jcw/wrapper.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Starovojtov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -248,7 +248,6 @@ files:
|
|
248
248
|
- lib/jcw/logger_extension.rb
|
249
249
|
- lib/jcw/rack_tracer.rb
|
250
250
|
- lib/jcw/subscriber.rb
|
251
|
-
- lib/jcw/tracing.rb
|
252
251
|
- lib/jcw/version.rb
|
253
252
|
- lib/jcw/wrapper.rb
|
254
253
|
homepage: https://github.com/Cado-Labs/jcw
|
data/lib/jcw/tracing.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module JCW
|
4
|
-
module Tracing
|
5
|
-
class << self
|
6
|
-
attr_reader :subscribers
|
7
|
-
|
8
|
-
def register_subscribers(subscribers)
|
9
|
-
@subscribers = subscribers
|
10
|
-
end
|
11
|
-
|
12
|
-
def subscribe_tracing_events
|
13
|
-
subscribers.each { |subscriber| Subscriber.subscribe_to_event!(subscriber) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|