getaround_utils 0.2.22 → 0.2.23
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 +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +27 -27
- data/README.md +27 -2
- data/getaround_utils.gemspec +4 -4
- data/lib/getaround_utils/mixins/loggable.rb +34 -0
- data/lib/getaround_utils/version.rb +1 -1
- metadata +19 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d0f45f64d93dc7e5b83b2ee8612dff306880d7953c3e9026edcafe40925e7127
|
|
4
|
+
data.tar.gz: 5bcd057a886ff3a7423841f5bc29fb491501fa3c9226658a4b17801ae6eee189
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98f5f63856cc9319be1d3f04e69bcf8aa5a165c48ad982ebf058a9e0faf92e31bf6dbeb1b5311f8ea89512156e508a7d3e070fbf0cfc22897958bc7279d58c06
|
|
7
|
+
data.tar.gz: ae985999bf28745645966d3108fd0dce14fba751f4a2e53aace72f5089515ddd94d6765ae3ae3349972b69cbcd72ac73b9f5083a4ec8acbf1a3c0d532938e8f7
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.
|
|
1
|
+
ruby-2.7.4
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
getaround_utils (0.2.
|
|
4
|
+
getaround_utils (0.2.23)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -70,28 +70,28 @@ GEM
|
|
|
70
70
|
ast (2.4.2)
|
|
71
71
|
builder (3.2.4)
|
|
72
72
|
coderay (1.1.3)
|
|
73
|
-
concurrent-ruby (1.1.
|
|
73
|
+
concurrent-ruby (1.1.10)
|
|
74
74
|
connection_pool (2.2.5)
|
|
75
75
|
crack (0.4.5)
|
|
76
76
|
rexml
|
|
77
77
|
crass (1.0.6)
|
|
78
78
|
diff-lcs (1.5.0)
|
|
79
79
|
erubi (1.10.0)
|
|
80
|
-
getaround-rubocop (0.2.
|
|
80
|
+
getaround-rubocop (0.2.7)
|
|
81
81
|
relaxed-rubocop (= 2.5)
|
|
82
|
-
rubocop (= 1.
|
|
82
|
+
rubocop (= 1.25.1)
|
|
83
83
|
rubocop-rspec (= 2.4.0)
|
|
84
84
|
globalid (1.0.0)
|
|
85
85
|
activesupport (>= 5.0)
|
|
86
86
|
hashdiff (1.0.1)
|
|
87
87
|
i18n (1.10.0)
|
|
88
88
|
concurrent-ruby (~> 1.0)
|
|
89
|
-
lograge (0.
|
|
89
|
+
lograge (0.12.0)
|
|
90
90
|
actionpack (>= 4)
|
|
91
91
|
activesupport (>= 4)
|
|
92
92
|
railties (>= 4)
|
|
93
93
|
request_store (~> 1.0)
|
|
94
|
-
loofah (2.
|
|
94
|
+
loofah (2.18.0)
|
|
95
95
|
crass (~> 1.0.2)
|
|
96
96
|
nokogiri (>= 1.5.9)
|
|
97
97
|
mail (2.7.1)
|
|
@@ -102,21 +102,21 @@ GEM
|
|
|
102
102
|
mini_portile2 (2.8.0)
|
|
103
103
|
minitest (5.15.0)
|
|
104
104
|
nio4r (2.5.8)
|
|
105
|
-
nokogiri (1.13.
|
|
105
|
+
nokogiri (1.13.6)
|
|
106
106
|
mini_portile2 (~> 2.8.0)
|
|
107
107
|
racc (~> 1.4)
|
|
108
108
|
oj (3.11.3)
|
|
109
109
|
ougai (2.0.0)
|
|
110
110
|
oj (~> 3.10)
|
|
111
|
-
parallel (1.
|
|
112
|
-
parser (3.
|
|
111
|
+
parallel (1.21.0)
|
|
112
|
+
parser (3.1.1.0)
|
|
113
113
|
ast (~> 2.4.1)
|
|
114
114
|
pry (0.14.1)
|
|
115
115
|
coderay (~> 1.1)
|
|
116
116
|
method_source (~> 1.0)
|
|
117
117
|
public_suffix (4.0.6)
|
|
118
118
|
racc (1.6.0)
|
|
119
|
-
rack (2.2.3)
|
|
119
|
+
rack (2.2.3.1)
|
|
120
120
|
rack-test (1.1.0)
|
|
121
121
|
rack (>= 1.0, < 3)
|
|
122
122
|
rails (6.1.4.6)
|
|
@@ -137,7 +137,7 @@ GEM
|
|
|
137
137
|
rails-dom-testing (2.0.3)
|
|
138
138
|
activesupport (>= 4.2.0)
|
|
139
139
|
nokogiri (>= 1.6)
|
|
140
|
-
rails-html-sanitizer (1.4.
|
|
140
|
+
rails-html-sanitizer (1.4.3)
|
|
141
141
|
loofah (~> 2.3)
|
|
142
142
|
railties (6.1.4.6)
|
|
143
143
|
actionpack (= 6.1.4.6)
|
|
@@ -145,12 +145,12 @@ GEM
|
|
|
145
145
|
method_source
|
|
146
146
|
rake (>= 0.13)
|
|
147
147
|
thor (~> 1.0)
|
|
148
|
-
rainbow (3.
|
|
148
|
+
rainbow (3.1.1)
|
|
149
149
|
rake (13.0.6)
|
|
150
150
|
redis (4.6.0)
|
|
151
|
-
regexp_parser (2.
|
|
151
|
+
regexp_parser (2.2.1)
|
|
152
152
|
relaxed-rubocop (2.5)
|
|
153
|
-
request_store (1.5.
|
|
153
|
+
request_store (1.5.1)
|
|
154
154
|
rack (>= 1.4)
|
|
155
155
|
request_store_rails (2.0.0)
|
|
156
156
|
concurrent-ruby (~> 1.0)
|
|
@@ -164,10 +164,10 @@ GEM
|
|
|
164
164
|
rspec-expectations (3.11.0)
|
|
165
165
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
166
166
|
rspec-support (~> 3.11.0)
|
|
167
|
-
rspec-mocks (3.11.
|
|
167
|
+
rspec-mocks (3.11.1)
|
|
168
168
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
169
169
|
rspec-support (~> 3.11.0)
|
|
170
|
-
rspec-rails (5.1.
|
|
170
|
+
rspec-rails (5.1.2)
|
|
171
171
|
actionpack (>= 5.2)
|
|
172
172
|
activesupport (>= 5.2)
|
|
173
173
|
railties (>= 5.2)
|
|
@@ -176,22 +176,22 @@ GEM
|
|
|
176
176
|
rspec-mocks (~> 3.10)
|
|
177
177
|
rspec-support (~> 3.10)
|
|
178
178
|
rspec-support (3.11.0)
|
|
179
|
-
rubocop (1.
|
|
179
|
+
rubocop (1.25.1)
|
|
180
180
|
parallel (~> 1.10)
|
|
181
|
-
parser (>= 3.
|
|
181
|
+
parser (>= 3.1.0.0)
|
|
182
182
|
rainbow (>= 2.2.2, < 4.0)
|
|
183
183
|
regexp_parser (>= 1.8, < 3.0)
|
|
184
184
|
rexml
|
|
185
|
-
rubocop-ast (>= 1.
|
|
185
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
|
186
186
|
ruby-progressbar (~> 1.7)
|
|
187
187
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
188
|
-
rubocop-ast (1.
|
|
189
|
-
parser (>= 3.
|
|
188
|
+
rubocop-ast (1.16.0)
|
|
189
|
+
parser (>= 3.1.1.0)
|
|
190
190
|
rubocop-rspec (2.4.0)
|
|
191
191
|
rubocop (~> 1.0)
|
|
192
192
|
rubocop-ast (>= 1.1.0)
|
|
193
193
|
ruby-progressbar (1.11.0)
|
|
194
|
-
sidekiq (6.
|
|
194
|
+
sidekiq (6.5.0)
|
|
195
195
|
connection_pool (>= 2.2.2)
|
|
196
196
|
rack (~> 2.0)
|
|
197
197
|
redis (>= 4.2.0)
|
|
@@ -205,7 +205,7 @@ GEM
|
|
|
205
205
|
thor (1.2.1)
|
|
206
206
|
tzinfo (2.0.4)
|
|
207
207
|
concurrent-ruby (~> 1.0)
|
|
208
|
-
unicode-display_width (2.
|
|
208
|
+
unicode-display_width (2.1.0)
|
|
209
209
|
webmock (3.14.0)
|
|
210
210
|
addressable (>= 2.8.0)
|
|
211
211
|
crack (>= 0.3.2)
|
|
@@ -220,9 +220,9 @@ PLATFORMS
|
|
|
220
220
|
|
|
221
221
|
DEPENDENCIES
|
|
222
222
|
bundler (~> 2.0)
|
|
223
|
-
getaround-rubocop (= 0.2.
|
|
223
|
+
getaround-rubocop (= 0.2.7)
|
|
224
224
|
getaround_utils!
|
|
225
|
-
lograge (~> 0.
|
|
225
|
+
lograge (~> 0.12.0)
|
|
226
226
|
ougai (~> 2.0)
|
|
227
227
|
pry (~> 0.14.0)
|
|
228
228
|
rails (~> 6.0)
|
|
@@ -230,9 +230,9 @@ DEPENDENCIES
|
|
|
230
230
|
request_store_rails (~> 2.0)
|
|
231
231
|
rspec (~> 3.9, >= 3.9.0)
|
|
232
232
|
rspec-rails (~> 5.0)
|
|
233
|
-
rubocop (= 1.
|
|
233
|
+
rubocop (= 1.25.1)
|
|
234
234
|
sidekiq (~> 6.0)
|
|
235
235
|
webmock (~> 3.7)
|
|
236
236
|
|
|
237
237
|
BUNDLED WITH
|
|
238
|
-
2.
|
|
238
|
+
2.3.4
|
data/README.md
CHANGED
|
@@ -28,8 +28,8 @@ For more details, [read the spec](spec/getaround_utils/railties/ougai_spec.rb)
|
|
|
28
28
|
|
|
29
29
|
### GetaroundUtils::Mixins::Loggable
|
|
30
30
|
|
|
31
|
-
Enables lograge (http logs) with favored default.
|
|
32
|
-
```
|
|
31
|
+
- Enables lograge (http logs) with favored default.
|
|
32
|
+
```ruby
|
|
33
33
|
class MyClass
|
|
34
34
|
include GetaroundUtils::Mixins::Loggable
|
|
35
35
|
|
|
@@ -48,6 +48,31 @@ MyClass.new.action # :info message="hello" origin="MyClass" static="value" dynam
|
|
|
48
48
|
|
|
49
49
|
For more details, [read the spec](spec/getaround_utils/mixins/loggable_spec.rb)
|
|
50
50
|
|
|
51
|
+
- Offers an abstraction to log messages with a configurable `alert_threshold` attribute
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
class MyClass
|
|
55
|
+
include GetaroundUtils::Mixins::Loggable
|
|
56
|
+
|
|
57
|
+
def action
|
|
58
|
+
monitorable_log(:my_event_to_be_monitored, dynamic: 'value')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
MyClass.new.action # :info message="monitorable_log__my_event_to_be_monitored" origin="MyClass" dynamic="value", threshold=10
|
|
63
|
+
```
|
|
64
|
+
The threshold is configured in the relevant Rails configuration (eg `config/environments/production.rb`)
|
|
65
|
+
```ruby
|
|
66
|
+
# ...
|
|
67
|
+
config.monitorable_log_thresholds = {
|
|
68
|
+
my_event_to_be_monitored: 10
|
|
69
|
+
}
|
|
70
|
+
# ...
|
|
71
|
+
```
|
|
72
|
+
You may set / override the configured thresholds with an environment variable of the event name prefixed with `MONITORABLE_LOG__`, for instance `MONITORABLE_LOG__MY_EVENT_TO_BE_MONITORED`.
|
|
73
|
+
|
|
74
|
+
For more details, [read the spec](spec/getaround_utils/mixins/loggable_spec.rb#L171)
|
|
75
|
+
|
|
51
76
|
## Misc
|
|
52
77
|
|
|
53
78
|
### GetaroundUtils::LogFormatters::DeepKeyValue
|
data/getaround_utils.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
|
11
11
|
gem.email = ['oss@drivy.com']
|
|
12
12
|
gem.homepage = 'https://github.com/drivy'
|
|
13
13
|
gem.license = 'MIT'
|
|
14
|
-
gem.required_ruby_version = '>= 2.
|
|
14
|
+
gem.required_ruby_version = '>= 2.7'
|
|
15
15
|
|
|
16
16
|
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
17
17
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
|
@@ -19,16 +19,16 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
|
|
20
20
|
# Development dependencies
|
|
21
21
|
gem.add_development_dependency 'bundler', '~> 2.0'
|
|
22
|
-
gem.add_development_dependency 'getaround-rubocop', '= 0.2.
|
|
22
|
+
gem.add_development_dependency 'getaround-rubocop', '= 0.2.7'
|
|
23
23
|
gem.add_development_dependency 'pry', '~> 0.14.0'
|
|
24
24
|
gem.add_development_dependency 'rake', '~> 13.0'
|
|
25
25
|
gem.add_development_dependency 'rspec', '~> 3.9', '>= 3.9.0'
|
|
26
26
|
gem.add_development_dependency 'rspec-rails', '~> 5.0'
|
|
27
|
-
gem.add_development_dependency 'rubocop', '= 1.
|
|
27
|
+
gem.add_development_dependency 'rubocop', '= 1.25.1'
|
|
28
28
|
gem.add_development_dependency 'webmock', '~> 3.7'
|
|
29
29
|
|
|
30
30
|
# Functional (optional) dependencies
|
|
31
|
-
gem.add_development_dependency 'lograge', '~> 0.
|
|
31
|
+
gem.add_development_dependency 'lograge', '~> 0.12.0'
|
|
32
32
|
gem.add_development_dependency 'ougai', '~> 2.0'
|
|
33
33
|
gem.add_development_dependency 'rails', '~> 6.0'
|
|
34
34
|
gem.add_development_dependency 'request_store_rails', '~> 2.0'
|
|
@@ -29,4 +29,38 @@ module GetaroundUtils::Mixins::Loggable
|
|
|
29
29
|
base_append_infos_to_loggable(payload)
|
|
30
30
|
loggable_logger.send(severity.to_sym, msg: message, **payload)
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
MONITORABLE_LOG_PREFIX = "monitorable_log__"
|
|
34
|
+
|
|
35
|
+
def monitorable_log(event_name, **options)
|
|
36
|
+
monitorable_threshold = monitorable_threshold(event_name)
|
|
37
|
+
return if monitorable_threshold.blank?
|
|
38
|
+
|
|
39
|
+
loggable_log(
|
|
40
|
+
:info,
|
|
41
|
+
log_message(event_name),
|
|
42
|
+
alert_threshold: monitorable_threshold,
|
|
43
|
+
**options
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def monitorable_threshold(event_name)
|
|
48
|
+
monitorable_threshold = ENV["#{log_message(event_name)}_threshold".upcase]&.to_i
|
|
49
|
+
if monitorable_threshold.nil? && rails_config_defined?
|
|
50
|
+
monitorable_threshold = Rails.application.config.monitorable_log_thresholds&.dig(event_name.to_sym)
|
|
51
|
+
end
|
|
52
|
+
monitorable_threshold
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def log_message(event_name)
|
|
56
|
+
MONITORABLE_LOG_PREFIX + event_name
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def rails_config_defined?
|
|
62
|
+
defined?(Rails) &&
|
|
63
|
+
Rails.application.config.respond_to?(:monitorable_log_thresholds) &&
|
|
64
|
+
Rails.application.config.monitorable_log_thresholds.respond_to?(:dig)
|
|
65
|
+
end
|
|
32
66
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: getaround_utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drivy
|
|
8
8
|
- Laurent Humez
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2022-
|
|
12
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -31,14 +31,14 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - '='
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 0.2.
|
|
34
|
+
version: 0.2.7
|
|
35
35
|
type: :development
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - '='
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 0.2.
|
|
41
|
+
version: 0.2.7
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: pry
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,22 +71,22 @@ dependencies:
|
|
|
71
71
|
name: rspec
|
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: 3.9.0
|
|
77
74
|
- - "~>"
|
|
78
75
|
- !ruby/object:Gem::Version
|
|
79
76
|
version: '3.9'
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: 3.9.0
|
|
80
80
|
type: :development
|
|
81
81
|
prerelease: false
|
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
|
84
|
-
- - ">="
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: 3.9.0
|
|
87
84
|
- - "~>"
|
|
88
85
|
- !ruby/object:Gem::Version
|
|
89
86
|
version: '3.9'
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 3.9.0
|
|
90
90
|
- !ruby/object:Gem::Dependency
|
|
91
91
|
name: rspec-rails
|
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -107,14 +107,14 @@ dependencies:
|
|
|
107
107
|
requirements:
|
|
108
108
|
- - '='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 1.
|
|
110
|
+
version: 1.25.1
|
|
111
111
|
type: :development
|
|
112
112
|
prerelease: false
|
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - '='
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.
|
|
117
|
+
version: 1.25.1
|
|
118
118
|
- !ruby/object:Gem::Dependency
|
|
119
119
|
name: webmock
|
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,14 +135,14 @@ dependencies:
|
|
|
135
135
|
requirements:
|
|
136
136
|
- - "~>"
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 0.
|
|
138
|
+
version: 0.12.0
|
|
139
139
|
type: :development
|
|
140
140
|
prerelease: false
|
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 0.
|
|
145
|
+
version: 0.12.0
|
|
146
146
|
- !ruby/object:Gem::Dependency
|
|
147
147
|
name: ougai
|
|
148
148
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -227,7 +227,7 @@ homepage: https://github.com/drivy
|
|
|
227
227
|
licenses:
|
|
228
228
|
- MIT
|
|
229
229
|
metadata: {}
|
|
230
|
-
post_install_message:
|
|
230
|
+
post_install_message:
|
|
231
231
|
rdoc_options: []
|
|
232
232
|
require_paths:
|
|
233
233
|
- lib
|
|
@@ -235,15 +235,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
235
235
|
requirements:
|
|
236
236
|
- - ">="
|
|
237
237
|
- !ruby/object:Gem::Version
|
|
238
|
-
version: '2.
|
|
238
|
+
version: '2.7'
|
|
239
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
240
|
requirements:
|
|
241
241
|
- - ">="
|
|
242
242
|
- !ruby/object:Gem::Version
|
|
243
243
|
version: '0'
|
|
244
244
|
requirements: []
|
|
245
|
-
rubygems_version: 3.
|
|
246
|
-
signing_key:
|
|
245
|
+
rubygems_version: 3.1.6
|
|
246
|
+
signing_key:
|
|
247
247
|
specification_version: 4
|
|
248
248
|
summary: Backend shared utility classes
|
|
249
249
|
test_files: []
|