dial 0.2.2 → 0.2.3
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 +5 -0
- data/README.md +12 -0
- data/lib/dial/configuration.rb +36 -0
- data/lib/dial/constants.rb +1 -1
- data/lib/dial/middleware.rb +3 -1
- data/lib/dial/railtie.rb +16 -8
- data/lib/dial/version.rb +1 -1
- data/lib/dial.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edead8fe405ee09b2ece6be004f6200ddd9394707a41da3509cbd168f3b88c67
|
4
|
+
data.tar.gz: 506f4b258c2b0acf117b1f4885ede6cf93ec739c1f21e0dc82b1f3da086f9a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f6c3705814f0cc0ae49bddf462741cf74d6de0733bd08280f6b01123368afb6ad46a1f7bf09329ee1c16c53a1d651c34b39d7277efce651f72550cd8e06557
|
7
|
+
data.tar.gz: 22236134d9731d47eacbc6d931ed2484b4e5451c875e554dcd5fc5fea3db84e3aaaf429db3f318939de30d52aa49ff49251f5300fc8243bf41e247d40c11c555
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,18 @@ bundle install
|
|
33
33
|
mount Dial::Engine, at: "/" if Rails.env.development?
|
34
34
|
```
|
35
35
|
|
36
|
+
4. (Optional) Configure the gem in an initializer:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# config/initializers/dial.rb
|
40
|
+
|
41
|
+
Dial.configure do |config|
|
42
|
+
config.vernier_interval = 100 # default: 200
|
43
|
+
config.vernier_allocation_interval = 10_000 # default: 20_000
|
44
|
+
config.prosopite_ignore_queries += [/pg_sleep/i] # default: [/schema_migrations/i]
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
36
48
|
## Development
|
37
49
|
|
38
50
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dial
|
4
|
+
def self.configure
|
5
|
+
yield _configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def self._configuration
|
9
|
+
@_configuration ||= Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
def initialize
|
14
|
+
@options = {
|
15
|
+
vernier_interval: VERNIER_INTERVAL,
|
16
|
+
vernier_allocation_interval: VERNIER_ALLOCATION_INTERVAL,
|
17
|
+
prosopite_ignore_queries: PROSOPITE_IGNORE_QUERIES,
|
18
|
+
}
|
19
|
+
|
20
|
+
@options.keys.each do |key|
|
21
|
+
define_singleton_method(key) do
|
22
|
+
@options[key]
|
23
|
+
end
|
24
|
+
|
25
|
+
define_singleton_method("#{key}=") do |value|
|
26
|
+
@options[key] = value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def freeze
|
32
|
+
@options.freeze
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/dial/constants.rb
CHANGED
@@ -18,7 +18,7 @@ module Dial
|
|
18
18
|
VERNIER_ALLOCATION_INTERVAL = 20_000
|
19
19
|
VERNIER_PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/profiles"
|
20
20
|
|
21
|
-
PROSOPITE_IGNORE_QUERIES = [/schema_migrations/].freeze
|
21
|
+
PROSOPITE_IGNORE_QUERIES = [/schema_migrations/i].freeze
|
22
22
|
PROSOPITE_LOG_RELATIVE_DIRNAME = "log/dial"
|
23
23
|
PROSOPITE_LOG_FILENAME = "#{Util.uuid}_prosopite_#{PROGRAM_ID}.log".freeze
|
24
24
|
end
|
data/lib/dial/middleware.rb
CHANGED
@@ -28,7 +28,9 @@ module Dial
|
|
28
28
|
|
29
29
|
status, headers, rack_body, ruby_vm_stat, gc_stat, gc_stat_heap, vernier_result = nil
|
30
30
|
::Prosopite.scan do
|
31
|
-
vernier_result = ::Vernier.profile interval:
|
31
|
+
vernier_result = ::Vernier.profile interval: Dial._configuration.vernier_interval, \
|
32
|
+
allocation_interval: Dial._configuration.vernier_allocation_interval, \
|
33
|
+
hooks: [:memory_usage, :rails] do
|
32
34
|
ruby_vm_stat, gc_stat, gc_stat_heap = with_diffed_ruby_stats do
|
33
35
|
status, headers, rack_body = @app.call env
|
34
36
|
end
|
data/lib/dial/railtie.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails"
|
4
|
+
require "active_record"
|
4
5
|
require "prosopite"
|
5
6
|
|
6
7
|
require_relative "middleware"
|
@@ -8,25 +9,25 @@ require_relative "prosopite_logger"
|
|
8
9
|
|
9
10
|
module Dial
|
10
11
|
class Railtie < ::Rails::Railtie
|
11
|
-
initializer "dial.use_middleware" do |app|
|
12
|
+
initializer "dial.use_middleware", after: :load_config_initializers do |app|
|
12
13
|
app.middleware.insert_before 0, Middleware
|
13
14
|
end
|
14
15
|
|
15
|
-
initializer "dial.set_up_vernier" do |app|
|
16
|
+
initializer "dial.set_up_vernier", after: :load_config_initializers do |app|
|
16
17
|
app.config.after_initialize do
|
17
18
|
FileUtils.mkdir_p ::Rails.root.join VERNIER_PROFILE_OUT_RELATIVE_DIRNAME
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
initializer "dial.clean_up_vernier_profile_out_files" do |app|
|
22
|
+
initializer "dial.clean_up_vernier_profile_out_files", after: :load_config_initializers do |app|
|
22
23
|
stale_files("#{profile_out_dir_pathname}/*.json.gz").each do |profile_out_file|
|
23
24
|
File.delete profile_out_file rescue nil
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
initializer "dial.set_up_prosopite" do |app|
|
28
|
+
initializer "dial.set_up_prosopite", after: :load_config_initializers do |app|
|
28
29
|
app.config.after_initialize do
|
29
|
-
if ::ActiveRecord::Base.
|
30
|
+
if ::ActiveRecord::Base.configurations.configurations.any? { |config| config.adapter == "postgresql" }
|
30
31
|
require "pg_query"
|
31
32
|
end
|
32
33
|
|
@@ -34,17 +35,24 @@ module Dial
|
|
34
35
|
FileUtils.mkdir_p File.dirname prosopite_log_pathname
|
35
36
|
FileUtils.touch prosopite_log_pathname
|
36
37
|
::Prosopite.custom_logger = ProsopiteLogger.new prosopite_log_pathname
|
37
|
-
|
38
|
-
::Prosopite.ignore_queries = PROSOPITE_IGNORE_QUERIES
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
initializer "dial.clean_up_prosopite_log_files" do |app|
|
41
|
+
initializer "dial.clean_up_prosopite_log_files", after: :load_config_initializers do |app|
|
43
42
|
stale_files("#{query_log_dir_pathname}/*.log").each do |query_log_file|
|
44
43
|
File.delete query_log_file rescue nil
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
47
|
+
initializer "dial.setup", after: :load_config_initializers do |app|
|
48
|
+
app.config.after_initialize do
|
49
|
+
Dial._configuration.freeze
|
50
|
+
|
51
|
+
# set static configuration options
|
52
|
+
::Prosopite.ignore_queries = Dial._configuration.prosopite_ignore_queries
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
48
56
|
private
|
49
57
|
|
50
58
|
def stale_files glob_pattern
|
data/lib/dial/version.rb
CHANGED
data/lib/dial.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Young
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: railties
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- README.md
|
124
124
|
- dial.gemspec
|
125
125
|
- lib/dial.rb
|
126
|
+
- lib/dial/configuration.rb
|
126
127
|
- lib/dial/constants.rb
|
127
128
|
- lib/dial/engine.rb
|
128
129
|
- lib/dial/engine/routes.rb
|