nobrainer 0.44.0 → 0.44.1
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/CHANGELOG.md +6 -1
- data/lib/no_brainer/config.rb +5 -1
- data/lib/no_brainer/profiler/slow_queries.rb +3 -6
- data/lib/rails/generators/templates/nobrainer.rb +17 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ba987cddbf9e6eb6864dbd6dc244f4b6dac2a5303e8c858a5f4f8f17cb82ee0
|
4
|
+
data.tar.gz: 127c6a0c7f1f3e5b25ad455adb7bf3a7f846481eec34cf1f420c8f52b199627b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a696b8919a347bc903d4d95f0700a1cea0d605b370349f171ace0505d0a07ff74663a249a98bad1cc7f9bec5aa9fd6c91ff279f908807d38831521684d9db04
|
7
|
+
data.tar.gz: 74f06144598fbc1706430dbceddd97712d0d3be7d0d1d08474289ce59defdd25c32832b1a4be1bd77fb142d2642744240259294c7f85ec74f8f7b0d0945436a2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.44.1] - 2023-08-02
|
10
|
+
### Changed
|
11
|
+
- Allows one to change what should be done with the slow query log message
|
12
|
+
|
9
13
|
## [0.44.0] - 2023-07-31
|
10
14
|
### Added
|
11
15
|
- Slow Queries Logger feature logging slow queries in a dedicated log file
|
@@ -134,7 +138,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
134
138
|
- Locks: bug fix: allow small timeouts in lock()
|
135
139
|
- Fix reentrant lock counter on steals
|
136
140
|
|
137
|
-
[Unreleased]: https://github.com/nobrainerorm/nobrainer/compare/v0.44.
|
141
|
+
[Unreleased]: https://github.com/nobrainerorm/nobrainer/compare/v0.44.1...HEAD
|
142
|
+
[0.44.1]: https://github.com/nobrainerorm/nobrainer/compare/v0.44.0...v0.44.1
|
138
143
|
[0.44.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.43.0...v0.44.0
|
139
144
|
[0.43.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.42.0...v0.43.0
|
140
145
|
[0.42.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.41.1...v0.42.0
|
data/lib/no_brainer/config.rb
CHANGED
@@ -22,7 +22,7 @@ module NoBrainer::Config
|
|
22
22
|
per_thread_connection: { default: -> { false }, valid_values: [true, false] },
|
23
23
|
rethinkdb_urls: { default: -> { [default_rethinkdb_url] } },
|
24
24
|
run_options: { default: -> { { durability: default_durability } } },
|
25
|
-
|
25
|
+
on_slow_query: { default: -> { nil } },
|
26
26
|
ssl_options: { default: -> {} },
|
27
27
|
table_options: {
|
28
28
|
default: -> { { shards: 1, replicas: 1, write_acks: :majority } },
|
@@ -55,6 +55,10 @@ module NoBrainer::Config
|
|
55
55
|
@applied_defaults_for.each { |k| __send__("#{k}=", SETTINGS[k][:default].call) }
|
56
56
|
end
|
57
57
|
|
58
|
+
def on_slow_query=(callback)
|
59
|
+
@on_slow_query = callback
|
60
|
+
end
|
61
|
+
|
58
62
|
def geo_options=(value)
|
59
63
|
@geo_options = value.try(:symbolize_keys)
|
60
64
|
end
|
@@ -4,17 +4,14 @@ module NoBrainer
|
|
4
4
|
module Profiler
|
5
5
|
class SlowQueries < Logger
|
6
6
|
def on_query(env)
|
7
|
-
return unless NoBrainer::Config.
|
7
|
+
return unless NoBrainer::Config.on_slow_query
|
8
8
|
|
9
9
|
query_duration = (env[:duration] * 1000.0).round(1)
|
10
10
|
|
11
11
|
return unless query_duration > NoBrainer::Config.long_query_time
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
build_message(env),
|
16
|
-
mode: 'a'
|
17
|
-
)
|
13
|
+
message = build_message(env)
|
14
|
+
NoBrainer::Config.on_slow_query.call(message)
|
18
15
|
end
|
19
16
|
|
20
17
|
NoBrainer::Profiler.register(new)
|
@@ -97,15 +97,26 @@ NoBrainer.configure do |config|
|
|
97
97
|
# out of memory issues.
|
98
98
|
# config.criteria_cache_max_entries = 10_000
|
99
99
|
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
# config.log_slow_queries = true
|
100
|
+
#
|
101
|
+
# Slow queries
|
102
|
+
#
|
104
103
|
|
105
104
|
# Queries running longer than the bellow value will be logged in a log file if
|
106
105
|
# the above `config.log_slow_queries` is `true`.
|
107
106
|
# config.long_query_time = 10 # seconds
|
108
107
|
|
109
|
-
#
|
110
|
-
#
|
108
|
+
# Uncomment the following block in order to do something with slow query log
|
109
|
+
# message.
|
110
|
+
# The example writes the log message in a log file, but you could of course
|
111
|
+
# change it to do something else with that log message.
|
112
|
+
# Nothing happens when `config.on_slow_query` is commented and a slow query is
|
113
|
+
# detected.
|
114
|
+
# config.on_slow_query = lambda do |message|
|
115
|
+
# # Write the log message to /var/log/rethinkdb/slow_queries.log file
|
116
|
+
# File.write(
|
117
|
+
# File.join('/', 'var', 'log', 'rethinkdb', 'slow_queries.log'),
|
118
|
+
# message,
|
119
|
+
# mode: 'a'
|
120
|
+
# )
|
121
|
+
# end
|
111
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nobrainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.44.
|
4
|
+
version: 0.44.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Viennot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|