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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204280e63f9f71fe949ccc5497b5e12e207ae681314caf73063163f785b7126b
4
- data.tar.gz: 21c70e61114ef47f38e194b812c3b0f52aba68ba7976972b13700db90e1451a8
3
+ metadata.gz: d4f60345ab5528878505773aa1b5875d4e00164ac9e94968584a40ecbb18b251
4
+ data.tar.gz: 5d2d5399d37be584ed2dd17f39cd98ed45af05a66e2eb8609fd340ef54dbeeb9
5
5
  SHA512:
6
- metadata.gz: e94c02266b0abd60727413d95bf7ec6238466dfa03725c904dac9443d1be63c448e05e7099d2c5ea44f7c153b155f8dd6176ca972103a0a3778bd8d7076b2f6e
7
- data.tar.gz: a6207c9decc7cdd7c009e6d85b38745a53c49b9703740ea35c143ebbbe9f347784136c718f902de4050e9f7dbc02d9b339b3f0a3e28332db3d43c1105d25191a
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.sampling_percentage = 50
45
- config.storage = Dial::Storage::RedisAdapter
46
- config.storage_options = { client: Redis.new(url: ENV["REDIS_URL"]), ttl: 86400 }
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`
@@ -12,8 +12,10 @@ module Dial
12
12
  class Configuration
13
13
  def initialize
14
14
  @options = {
15
- sampling_percentage: default_sampling_percentage,
16
- storage: default_storage,
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
@@ -16,6 +16,7 @@ module Dial
16
16
  NONCE = ::ActionDispatch::ContentSecurityPolicy::Request::NONCE
17
17
  REQUEST_TIMING = "dial_request_timing"
18
18
 
19
+ FORCE_PARAM = "dial_force"
19
20
  SAMPLING_PERCENTAGE_DEV = 100
20
21
  SAMPLING_PERCENTAGE_PROD = 1
21
22
  STORAGE_TTL = 60 * 60
@@ -22,7 +22,8 @@ module Dial
22
22
  return @app.call env
23
23
  end
24
24
 
25
- unless should_profile?
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
- rand(100) < Dial._configuration.sampling_percentage
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dial
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young