dry-monitor 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/dry-monitor.gemspec +2 -3
- data/lib/dry/monitor/notifications.rb +3 -5
- data/lib/dry/monitor/rack/logger.rb +8 -18
- data/lib/dry/monitor/rack/middleware.rb +1 -3
- data/lib/dry/monitor/sql/colorizers/rouge.rb +1 -2
- data/lib/dry/monitor/sql/logger.rb +3 -7
- data/lib/dry/monitor/version.rb +1 -1
- metadata +11 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d81f64e41a8aefe7efc798b025228ea7c29d7b6228bbf6992f31b3aa2a7ae38d
|
4
|
+
data.tar.gz: b4eb4c4928bb5aacc9f160f7caba9047b2bcac5e77934407697a6f910f5808b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174dbc6c5c059a6a22ddb37b38c211690735de3e9efa97b2826e1f3190123f7a21af54f75ca72d226a18c8671eaa6856b406336217d23326ffc9561a3ed0716a
|
7
|
+
data.tar.gz: e249416fc29c6296d6c6cbe3488e5899a877224cdcc247f06cbd1fc2789c4fa4514575e884b26793947cc92f645816f765e50ccc2f8d31df4f783523f0b8220e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
|
+
|
3
|
+
## 0.4.0
|
4
|
+
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Compatibility with MRI 3.0 (@alex-damian-negru)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v0.3.2...master](https://github.com/dry-rb/dry-monitor/compare/v0.3.2...master)
|
12
|
+
|
1
13
|
## 0.3.2 2020-04-09
|
2
14
|
|
3
15
|
|
@@ -8,7 +20,6 @@
|
|
8
20
|
### Changed
|
9
21
|
|
10
22
|
- Performance improvements (@davydovanton)
|
11
|
-
- Dependency on `dry-events` was bumped to `~> 0.5` (@davydovanton)
|
12
23
|
|
13
24
|
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-monitor/compare/v0.3.1...v0.3.2)
|
14
25
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/dry-monitor.gemspec
CHANGED
@@ -25,12 +25,11 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-monitor'
|
26
26
|
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-monitor/issues'
|
27
27
|
|
28
|
-
spec.required_ruby_version = ">= 2.
|
28
|
+
spec.required_ruby_version = ">= 2.5.0"
|
29
29
|
|
30
30
|
# to update dependencies edit project.yml
|
31
31
|
spec.add_runtime_dependency "dry-configurable", "~> 0.5"
|
32
|
-
spec.add_runtime_dependency "dry-core", "~> 0.
|
33
|
-
spec.add_runtime_dependency "dry-equalizer", "~> 0.2"
|
32
|
+
spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
|
34
33
|
spec.add_runtime_dependency "dry-events", "~> 0.2"
|
35
34
|
|
36
35
|
spec.add_development_dependency "bundler"
|
@@ -22,9 +22,7 @@ module Dry
|
|
22
22
|
class Notifications
|
23
23
|
include Events::Publisher["Dry::Monitor::Notifications"]
|
24
24
|
|
25
|
-
attr_reader :id
|
26
|
-
|
27
|
-
attr_reader :clock
|
25
|
+
attr_reader :id, :clock
|
28
26
|
|
29
27
|
def initialize(id)
|
30
28
|
@id = id
|
@@ -39,8 +37,8 @@ module Dry
|
|
39
37
|
instrument(event_id, payload)
|
40
38
|
end
|
41
39
|
|
42
|
-
def instrument(event_id, payload = EMPTY_HASH)
|
43
|
-
result, time = @clock.measure
|
40
|
+
def instrument(event_id, payload = EMPTY_HASH, &block)
|
41
|
+
result, time = @clock.measure(&block) if block_given?
|
44
42
|
|
45
43
|
process(event_id, payload) do |event, listener|
|
46
44
|
if time
|
@@ -21,9 +21,7 @@ module Dry
|
|
21
21
|
QUERY_MSG = %( Query parameters )
|
22
22
|
FILTERED = "[FILTERED]"
|
23
23
|
|
24
|
-
attr_reader :logger
|
25
|
-
|
26
|
-
attr_reader :config
|
24
|
+
attr_reader :logger, :config
|
27
25
|
|
28
26
|
def initialize(logger, config = self.class.config)
|
29
27
|
@logger = logger
|
@@ -31,17 +29,9 @@ module Dry
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def attach(rack_monitor)
|
34
|
-
rack_monitor.on(:start)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
rack_monitor.on(:stop) do |env:, status:, time:|
|
39
|
-
log_stop_request(env, status, time)
|
40
|
-
end
|
41
|
-
|
42
|
-
rack_monitor.on(:error) do |event|
|
43
|
-
log_exception(event[:exception])
|
44
|
-
end
|
32
|
+
rack_monitor.on(:start) { |params| log_start_request(params[:env]) }
|
33
|
+
rack_monitor.on(:stop) { |params| log_stop_request(**params) }
|
34
|
+
rack_monitor.on(:error) { |event| log_exception(event[:exception]) }
|
45
35
|
end
|
46
36
|
|
47
37
|
def log_exception(err)
|
@@ -59,11 +49,11 @@ module Dry
|
|
59
49
|
log_request_params(request)
|
60
50
|
end
|
61
51
|
|
62
|
-
def log_stop_request(
|
52
|
+
def log_stop_request(env:, status:, time:)
|
63
53
|
logger.info STOP_MSG % [
|
64
|
-
|
65
|
-
|
66
|
-
|
54
|
+
env[REQUEST_METHOD],
|
55
|
+
env[PATH_INFO],
|
56
|
+
env[REMOTE_ADDR],
|
67
57
|
time,
|
68
58
|
status
|
69
59
|
]
|
@@ -15,8 +15,7 @@ module Dry
|
|
15
15
|
module SQL
|
16
16
|
module Colorizers
|
17
17
|
class Rouge
|
18
|
-
attr_reader :formatter
|
19
|
-
attr_reader :lexer
|
18
|
+
attr_reader :formatter, :lexer
|
20
19
|
|
21
20
|
def initialize(theme)
|
22
21
|
@formatter = ::Rouge::Formatters::Terminal256.new(theme || ::Rouge::Themes::Gruvbox.new)
|
@@ -40,9 +40,7 @@ module Dry
|
|
40
40
|
setting :theme, nil
|
41
41
|
setting :message_template, %( Loaded %s in %sms %s)
|
42
42
|
|
43
|
-
attr_reader :config
|
44
|
-
attr_reader :logger
|
45
|
-
attr_reader :template
|
43
|
+
attr_reader :config, :logger, :template
|
46
44
|
|
47
45
|
load_extensions(:default_colorizer)
|
48
46
|
|
@@ -53,12 +51,10 @@ module Dry
|
|
53
51
|
end
|
54
52
|
|
55
53
|
def subscribe(notifications)
|
56
|
-
notifications.subscribe(:sql)
|
57
|
-
log_query(time, name, query)
|
58
|
-
end
|
54
|
+
notifications.subscribe(:sql) { |params| log_query(**params) }
|
59
55
|
end
|
60
56
|
|
61
|
-
def log_query(time
|
57
|
+
def log_query(time:, name:, query:)
|
62
58
|
logger.info template % [name.inspect, time, colorizer.call(query)]
|
63
59
|
end
|
64
60
|
end
|
data/lib/dry/monitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -30,28 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.4'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-equalizer
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
33
|
+
version: '0.5'
|
34
|
+
- - ">="
|
46
35
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
36
|
+
version: '0.5'
|
48
37
|
type: :runtime
|
49
38
|
prerelease: false
|
50
39
|
version_requirements: !ruby/object:Gem::Requirement
|
51
40
|
requirements:
|
52
41
|
- - "~>"
|
53
42
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
43
|
+
version: '0.5'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.5'
|
55
47
|
- !ruby/object:Gem::Dependency
|
56
48
|
name: dry-events
|
57
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,14 +158,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
158
|
requirements:
|
167
159
|
- - ">="
|
168
160
|
- !ruby/object:Gem::Version
|
169
|
-
version: 2.
|
161
|
+
version: 2.5.0
|
170
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
163
|
requirements:
|
172
164
|
- - ">="
|
173
165
|
- !ruby/object:Gem::Version
|
174
166
|
version: '0'
|
175
167
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
168
|
+
rubygems_version: 3.1.6
|
177
169
|
signing_key:
|
178
170
|
specification_version: 4
|
179
171
|
summary: Monitoring and instrumentation APIs
|