dial 0.5.0 → 0.5.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 +5 -0
- data/README.md +13 -5
- data/lib/dial/configuration.rb +4 -12
- data/lib/dial/constants.rb +1 -0
- data/lib/dial/middleware.rb +8 -3
- data/lib/dial/railtie.rb +0 -3
- data/lib/dial/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4f60345ab5528878505773aa1b5875d4e00164ac9e94968584a40ecbb18b251
|
4
|
+
data.tar.gz: 5d2d5399d37be584ed2dd17f39cd98ed45af05a66e2eb8609fd340ef54dbeeb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78cf96c6482b571710c49363e00e7ffb5e65f8e07f180d9e5d99ce862af4d28c2032ff8757b565dc053699e0d4d044dfae26346de297b310c4324c659101216
|
7
|
+
data.tar.gz: 522ab5c9d3f3e556a71f440256a36d6f2bedc0abb5dccab05c147bc21a50332da581683188fcb1f672c58fc05773782d65fb575995d6adc0f0a856b9e78d6e8c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.5.1] - 2025-09-27
|
4
|
+
|
5
|
+
- Don't clean up stale storage data in railtie
|
6
|
+
- Add enabled configuration option and force parameter for per-request profiling
|
7
|
+
|
3
8
|
## [0.5.0] - 2025-09-21
|
4
9
|
|
5
10
|
- Add storage interface with Redis cluster and Memcached adapters for distributed deployments
|
data/README.md
CHANGED
@@ -41,9 +41,15 @@ mount Dial::Engine, at: "/"
|
|
41
41
|
# config/initializers/dial.rb
|
42
42
|
|
43
43
|
Dial.configure do |config|
|
44
|
-
config.
|
45
|
-
config.
|
46
|
-
|
44
|
+
config.enabled = !Rails.env.production? # disable by default in production, use force_param to enable per request
|
45
|
+
config.force_param = "profile" # override param name to force profiling
|
46
|
+
if Rails.env.staging?
|
47
|
+
config.sampling_percentage = 50 # override sampling percentage in staging for A/B testing profiler impact
|
48
|
+
end
|
49
|
+
unless Rails.env.development?
|
50
|
+
config.storage = Dial::Storage::RedisAdapter # use Redis storage in non-development environments
|
51
|
+
config.storage_options = { client: Redis.new(url: ENV["REDIS_URL"]), ttl: 86400 }
|
52
|
+
end
|
47
53
|
config.vernier_interval = 100
|
48
54
|
config.vernier_allocation_interval = 10_000
|
49
55
|
config.prosopite_ignore_queries += [/pg_sleep/i]
|
@@ -54,9 +60,11 @@ end
|
|
54
60
|
|
55
61
|
Option | Description | Default
|
56
62
|
:- | :- | :-
|
63
|
+
`enabled` | Whether profiling is enabled. | `true`
|
64
|
+
`force_param` | Request parameter name to force profiling even when disabled. Always profiles (bypasses sampling). | `"dial_force"`
|
57
65
|
`sampling_percentage` | Percentage of requests to profile. | `100` in development, `1` in production
|
58
|
-
`storage` | Storage adapter class for profile data | `Dial::Storage::FileAdapter`
|
59
|
-
`storage_options` | Options hash passed to storage adapter | `{ ttl: 3600 }`
|
66
|
+
`storage` | Storage adapter class for profile data. | `Dial::Storage::FileAdapter`
|
67
|
+
`storage_options` | Options hash passed to storage adapter. | `{ ttl: 3600 }`
|
60
68
|
`content_security_policy_nonce` | Sets the content security policy nonce to use when inserting Dial's script. Can be a string, or a Proc which receives `env` and response `headers` as arguments and returns the nonce string. | Rails generated nonce or `nil`
|
61
69
|
`vernier_interval` | Sets the `interval` option for vernier. | `200`
|
62
70
|
`vernier_allocation_interval` | Sets the `allocation_interval` option for vernier. | `2_000`
|
data/lib/dial/configuration.rb
CHANGED
@@ -12,8 +12,10 @@ module Dial
|
|
12
12
|
class Configuration
|
13
13
|
def initialize
|
14
14
|
@options = {
|
15
|
-
|
16
|
-
|
15
|
+
enabled: true,
|
16
|
+
force_param: FORCE_PARAM,
|
17
|
+
sampling_percentage: ::Rails.env.development? ? SAMPLING_PERCENTAGE_DEV : SAMPLING_PERCENTAGE_PROD,
|
18
|
+
storage: Storage::FileAdapter,
|
17
19
|
storage_options: { ttl: STORAGE_TTL },
|
18
20
|
content_security_policy_nonce: -> env, _headers { env[NONCE] || EMPTY_NONCE },
|
19
21
|
vernier_interval: VERNIER_INTERVAL,
|
@@ -37,15 +39,5 @@ module Dial
|
|
37
39
|
|
38
40
|
super
|
39
41
|
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def default_sampling_percentage
|
44
|
-
::Rails.env.development? ? SAMPLING_PERCENTAGE_DEV : SAMPLING_PERCENTAGE_PROD
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_storage
|
48
|
-
Storage::FileAdapter
|
49
|
-
end
|
50
42
|
end
|
51
43
|
end
|
data/lib/dial/constants.rb
CHANGED
data/lib/dial/middleware.rb
CHANGED
@@ -22,7 +22,8 @@ module Dial
|
|
22
22
|
return @app.call env
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
request = ::Rack::Request.new env
|
26
|
+
unless should_profile? request
|
26
27
|
return @app.call env
|
27
28
|
end
|
28
29
|
|
@@ -125,8 +126,12 @@ module Dial
|
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
128
|
-
def should_profile?
|
129
|
-
|
129
|
+
def should_profile? request
|
130
|
+
force_param = Dial._configuration.force_param
|
131
|
+
return true if request.params[force_param]
|
132
|
+
|
133
|
+
Dial._configuration.enabled &&
|
134
|
+
rand(100) < Dial._configuration.sampling_percentage
|
130
135
|
end
|
131
136
|
end
|
132
137
|
|
data/lib/dial/railtie.rb
CHANGED
@@ -10,9 +10,6 @@ require_relative "prosopite_logger"
|
|
10
10
|
module Dial
|
11
11
|
class Railtie < ::Rails::Railtie
|
12
12
|
initializer "dial.setup", after: :load_config_initializers do |app|
|
13
|
-
# clean up stale storage data
|
14
|
-
Storage.cleanup
|
15
|
-
|
16
13
|
app.config.after_initialize do
|
17
14
|
# set up prosopite
|
18
15
|
if ::ActiveRecord::Base.configurations.configurations.any? { |config| config.adapter == "postgresql" }
|
data/lib/dial/version.rb
CHANGED