rails_performance 1.4.1.alpha1 → 1.4.2

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: 396fc3be3ee247b19fac4d412b3f4d88f6adb508e6f05448a0f0973181b4180d
4
- data.tar.gz: 07de788ff089b86b59d2dd8aeafcbd3a194a364061123e2b48d422ee2a294134
3
+ metadata.gz: d387037eea90f299a14499105f68cd78794ee7a36122d45081c488b9ca3fb6dd
4
+ data.tar.gz: 1c49de1b612f86f8089fdd2765b53bcbdddb2bb65d4890eacdf068f0ca14ecc3
5
5
  SHA512:
6
- metadata.gz: 9482d9b4bca7be7b8bb8377ab4ccde7b88dba36aecc8fa2373f6e1cb1d515c872c9026f98fe310ce981df35abcab0821340f308bca326414ad7674b310a491c2
7
- data.tar.gz: d0f73c518afc4b0b3160bd23c19b07a3cee865900fb91058a9cce67e5323e591f69248fd3b05151918f13592e49cb7b409215872e206067c85d3b3895556a8a5
6
+ metadata.gz: 208578b1cc4a8a4b261c9607d89b045983ab2be0cc1ef811059be38a3c02dd4f9b333a0937900733b04ad8058c1c920c02f333bc31b9fae13c1629123456a99d
7
+ data.tar.gz: 9066e380c0d9309554e7574298d8bda95570e4f0851fdfa586c675f998bcdfaed993decd336d9de4c6b1b6ed55b0065fc368aba8ba23c7627690db18bedae36b
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![Tests](https://github.com/igorkasyanchuk/rails_performance/actions/workflows/ruby.yml/badge.svg)](https://github.com/igorkasyanchuk/rails_performance/actions/workflows/ruby.yml)
4
4
  [![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
5
- [![Listed on OpenSource-Heroes.com](https://opensource-heroes.com/badge-v1.svg)](https://opensource-heroes.com/r/igorkasyanchuk/rails_performance)
5
+ [My Cheatsheets](https://cheatsheetshero.com/user/igor-kasyanchuk)
6
+
7
+ [!["Buy Me A Coffee"](https://github.com/igorkasyanchuk/get-smart/blob/main/docs/snapshot-bmc-button-small.png?raw=true)](https://buymeacoffee.com/igorkasyanchuk)
6
8
 
7
9
  A self-hosted tool to monitor the performance of your Ruby on Rails application.
8
10
 
@@ -242,7 +244,7 @@ RailsPerformance.measure("some label", "some namespace") do
242
244
  end
243
245
  ```
244
246
 
245
- ## Using with Rails Namespace
247
+ ## Using with Redis Namespace
246
248
 
247
249
  If you want to use Redis namespace (for example when you have multiple apps running on the same server), you can configure it like this:
248
250
 
@@ -332,14 +334,11 @@ If "schema" how records are stored i Redis is changed, and this is a breaking ch
332
334
 
333
335
  https://github.com/igorkasyanchuk/rails_performance/graphs/contributors
334
336
 
335
- ## Other
336
-
337
- [<img src="https://opensource-heroes.com/svg/embed/igorkasyanchuk/rails_performance"
338
- />](https://opensource-heroes.com/r/igorkasyanchuk/rails_performance)
339
-
340
337
  ## License
341
338
 
342
339
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
343
340
 
344
341
  [<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
345
342
  />](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=rails_performance)
343
+
344
+ [!["Buy Me A Coffee"](https://github.com/igorkasyanchuk/get-smart/blob/main/docs/snapshot-bmc-button.png?raw=true)](https://buymeacoffee.com/igorkasyanchuk)
@@ -4,6 +4,7 @@ module RailsPerformance
4
4
  layout "rails_performance/layouts/rails_performance"
5
5
 
6
6
  before_action :verify_access
7
+ after_action :set_permissive_csp
7
8
 
8
9
  if RailsPerformance.http_basic_authentication_enabled
9
10
  http_basic_authenticate_with \
@@ -17,5 +18,9 @@ module RailsPerformance
17
18
  result = RailsPerformance.verify_access_proc.call(self)
18
19
  redirect_to("/", error: "Access Denied", status: 401) unless result
19
20
  end
21
+
22
+ def set_permissive_csp
23
+ response.headers["Content-Security-Policy"] = "default-src 'self' https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; style-src 'self' 'unsafe-inline' https:"
24
+ end
20
25
  end
21
26
  end
@@ -23,6 +23,10 @@ module RailsPerformance
23
23
  end
24
24
 
25
25
  def extract_duration(str)
26
+ if str.is_a?(Hash)
27
+ return str[:duration].to_s if str[:duration]
28
+ end
29
+
26
30
  if str =~ /Duration: (\d+.?\d+?ms)/i
27
31
  $1
28
32
  else
@@ -73,7 +73,6 @@ function tooltipOptions(formatter) {
73
73
  }
74
74
 
75
75
  function showTIRChart(element_id, data, addon, name) {
76
- console.dir(data);
77
76
  showChart(element_id, 'area', 'RPM', {
78
77
  tooltip: tooltipOptions(value => (value ? value + addon : undefined)),
79
78
  series: [{
@@ -8,11 +8,11 @@ if defined?(RailsPerformance)
8
8
 
9
9
  # Recent Requests configuration
10
10
  config.recent_requests_time_window = 60.minutes
11
- # confog.recent_requests_limit = nil # numnber of recent requests
11
+ # config.recent_requests_limit = nil # number of recent requests
12
12
 
13
13
  # Slow Requests configuration
14
14
  config.slow_requests_time_window = 4.hours
15
- # config.slow_requests_limit = 500 # numnber of slow requests
15
+ # config.slow_requests_limit = 500 # number of slow requests
16
16
  config.slow_requests_threshold = 500 # ms
17
17
 
18
18
  config.debug = false # currently not used>
@@ -25,15 +25,7 @@ module RailsPerformance
25
25
  initializer "rails_performance.middleware" do |app|
26
26
  next unless RailsPerformance.enabled
27
27
 
28
- if ::Rails::VERSION::MAJOR.to_i >= 5
29
- app.middleware.insert_after ActionDispatch::Executor, RailsPerformance::Rails::Middleware
30
- else
31
- begin
32
- app.middleware.insert_after ActionDispatch::Static, RailsPerformance::Rails::Middleware
33
- rescue
34
- app.middleware.insert_after Rack::SendFile, RailsPerformance::Rails::Middleware
35
- end
36
- end
28
+ app.middleware.insert_after ActionDispatch::Executor, RailsPerformance::Rails::Middleware
37
29
  # look like it works in reverse order?
38
30
  app.middleware.insert_before RailsPerformance::Rails::Middleware, RailsPerformance::Rails::MiddlewareTraceStorerAndCleanup
39
31
 
@@ -44,7 +44,7 @@ module RailsPerformance
44
44
  memory = fetch_process_memory_usage
45
45
  disk = fetch_disk_usage
46
46
 
47
- store_data({cpu:, memory:, disk:})
47
+ store_data({cpu: cpu, memory: memory, disk: disk})
48
48
  end
49
49
 
50
50
  def fetch_process_cpu_usage
@@ -10,7 +10,7 @@ module RailsPerformance
10
10
  .collect { |e| e.record_hash }
11
11
  .select { |e| e if e[sort] > RailsPerformance.slow_requests_time_window.ago.to_i }
12
12
  .sort { |a, b| b[sort] <=> a[sort] }
13
- .filter { |e| e[:duration] > RailsPerformance.slow_requests_threshold.to_i }
13
+ .filter { |e| e[:duration].to_f > RailsPerformance.slow_requests_threshold.to_i }
14
14
  .first(limit)
15
15
  end
16
16
 
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = "1.4.1.alpha1"
2
+ VERSION = "1.4.2"
3
3
  SCHEMA = "1.0.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1.alpha1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-26 00:00:00.000000000 Z
10
+ date: 2025-05-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -122,20 +121,6 @@ dependencies:
122
121
  - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: otr-activerecord
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
124
  - !ruby/object:Gem::Dependency
140
125
  name: sidekiq
141
126
  requirement: !ruby/object:Gem::Requirement
@@ -398,7 +383,6 @@ homepage: https://github.com/igorkasyanchuk/rails_performance
398
383
  licenses:
399
384
  - MIT
400
385
  metadata: {}
401
- post_install_message:
402
386
  rdoc_options: []
403
387
  require_paths:
404
388
  - lib
@@ -413,8 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
413
397
  - !ruby/object:Gem::Version
414
398
  version: '0'
415
399
  requirements: []
416
- rubygems_version: 3.5.22
417
- signing_key:
400
+ rubygems_version: 3.6.3
418
401
  specification_version: 4
419
402
  summary: Simple Rails Performance tracker. Alternative to the NewRelic, Datadog or
420
403
  other services.