rails_performance 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b7357f736b95447fdaaf95de2db6042794148a17b87ef517b8a8b7bda19212f
4
- data.tar.gz: 189eb4cb2151d20e00f18494768299b5ff8060c41e086db752af9360343f94d7
3
+ metadata.gz: f62ed6d90c59a10854568fb3cbfc0ad3b6aa4335be471b9b44d2512a1e517bd8
4
+ data.tar.gz: 48660eb209b4d1ad1824e73e3766e9e5b15e6391d687d617162babdd1c4df4f1
5
5
  SHA512:
6
- metadata.gz: 075f60cbc47d2df3baa13259cae71230a3395afc9095f6cd48d6cd5fd15f1f15619c12c0ba5dbcb296fdc2ab6f9b4c89888db836a97066c2b2157f4f14e01058
7
- data.tar.gz: 1289acb796e6fc71a98fc36ceed9dc6cc709253725d73cd2be58220e265f05e8db34c977222d8f67e8cfe130a376ebbfe061221c8e6cc541a51ba9239273fd43
6
+ metadata.gz: 232da3c634a49b94aab7c934a22df9583b12785c7cd5b880bceaa055207367fe615d41c6bf5e314e548877bbb16280a732ee4863a402dd306f68b684a8f89001
7
+ data.tar.gz: 89980a1267b46b18548545837041abdaa2544c88fc0f7343fb9d3d8e825a5f69fd33e5f56662c5852c7dd4b6c33edac323a6e08d90f14254543689fd1718c896
data/README.md CHANGED
@@ -2,7 +2,6 @@
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
- [![https://www.patreon.com/igorkasyanchuk](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/patron.svg?raw=true)](https://www.patreon.com/igorkasyanchuk)
6
5
  [![Listed on OpenSource-Heroes.com](https://opensource-heroes.com/badge-v1.svg)](https://opensource-heroes.com/r/igorkasyanchuk/rails_performance)
7
6
 
8
7
  A self-hosted tool to monitor the performance of your Ruby on Rails application.
@@ -81,6 +80,13 @@ RailsPerformance.setup do |config|
81
80
  # for example when you have `current_user`
82
81
  # config.verify_access_proc = proc { |controller| controller.current_user && controller.current_user.admin? }
83
82
 
83
+ # You can ignore endpoints with Rails standard notation controller#action
84
+ # config.ignored_endpoints = ['HomeController#contact']
85
+
86
+ # You can ignore request paths by specifying the beginning of the path.
87
+ # For example, all routes starting with '/admin' can be ignored:
88
+ # config.ignored_paths = ['/admin']
89
+
84
90
  # store custom data for the request
85
91
  # config.custom_data_proc = proc do |env|
86
92
  # request = Rack::Request.new(env)
@@ -93,7 +99,14 @@ RailsPerformance.setup do |config|
93
99
  # config home button link
94
100
  config.home_link = '/'
95
101
 
102
+ # To skip some Rake tasks from monitoring
96
103
  config.skipable_rake_tasks = ['webpacker:compile']
104
+
105
+ # To monitor rake tasks performance, you need to include rake tasks
106
+ # config.include_rake_tasks = false
107
+
108
+ # To monitor custom events with `RailsPerformance.measure` block
109
+ # config.include_custom_events = true
97
110
  end if defined?(RailsPerformance)
98
111
  ```
99
112
 
@@ -241,6 +254,7 @@ If "schema" how records are stored i Redis is changed, and this is a breaking ch
241
254
  - https://github.com/carl-printreleaf
242
255
  - https://github.com/langalex
243
256
  - https://github.com/olleolleolle
257
+ - https://github.com/desheikh
244
258
 
245
259
  [<img src="https://opensource-heroes.com/svg/embed/igorkasyanchuk/rails_performance"
246
260
  />](https://opensource-heroes.com/r/igorkasyanchuk/rails_performance)
@@ -2,7 +2,6 @@ require_relative './base_controller.rb'
2
2
 
3
3
  module RailsPerformance
4
4
  class RailsPerformanceController < RailsPerformance::BaseController
5
- include RailsPerformance::ApplicationHelper
6
5
 
7
6
  protect_from_forgery except: :recent
8
7
 
@@ -1,5 +1,5 @@
1
1
  module RailsPerformance
2
- module ApplicationHelper
2
+ module RailsPerformanceHelper
3
3
 
4
4
  def round_it(value, limit = 1)
5
5
  return nil unless value
@@ -4,7 +4,7 @@
4
4
  <div class="card-content">
5
5
  <div class="columns">
6
6
  <div class="column">
7
- <h2 class="subtitle">Slow Requests (last <%= RailsPerformance.slow_requests_time_window / 60 %> minutes + slower then <%= RailsPerformance.slow_requests_threshold %>ms)<h2>
7
+ <h2 class="subtitle">Slow Requests (last <%= RailsPerformance.slow_requests_time_window / 60 %> minutes + slower than <%= RailsPerformance.slow_requests_threshold %>ms)<h2>
8
8
  </div>
9
9
  </div>
10
10
 
@@ -28,8 +28,12 @@
28
28
  <% if defined?(Grape) %>
29
29
  <%= link_to 'Grape', rails_performance.rails_performance_grape_url, class: "navbar-item #{active?(:grape)}" %>
30
30
  <% end %>
31
- <%= link_to 'Rake', rails_performance.rails_performance_rake_url, class: "navbar-item #{active?(:rake)}" %>
32
- <%= link_to 'Custom Events', rails_performance.rails_performance_custom_url, class: "navbar-item #{active?(:custom)}" %>
31
+ <% if RailsPerformance.include_rake_tasks %>
32
+ <%= link_to 'Rake', rails_performance.rails_performance_rake_url, class: "navbar-item #{active?(:rake)}" %>
33
+ <% end %>
34
+ <% if RailsPerformance.include_custom_events %>
35
+ <%= link_to 'Custom Events', rails_performance.rails_performance_custom_url, class: "navbar-item #{active?(:custom)}" %>
36
+ <% end %>
33
37
  </div>
34
38
 
35
39
  <div class="navbar-end">
@@ -21,6 +21,10 @@ RailsPerformance.setup do |config|
21
21
  # You can ignore endpoints with Rails standard notation controller#action
22
22
  # config.ignored_endpoints = ['HomeController#contact']
23
23
 
24
+ # You can ignore request paths by specifying the beginning of the path.
25
+ # For example, all routes starting with '/admin' can be ignored:
26
+ # config.ignored_paths = ['/admin']
27
+
24
28
  # store custom data for the request
25
29
  # config.custom_data_proc = proc do |env|
26
30
  # request = Rack::Request.new(env)
@@ -32,4 +36,7 @@ RailsPerformance.setup do |config|
32
36
 
33
37
  # config home button link
34
38
  config.home_link = '/'
39
+ config.skipable_rake_tasks = ['webpacker:compile']
40
+ config.include_rake_tasks = false
41
+ config.include_custom_events = true
35
42
  end if defined?(RailsPerformance)
@@ -57,7 +57,7 @@ module RailsPerformance
57
57
  ActionView::LogSubscriber.send :prepend, RailsPerformance::Extensions::View
58
58
  ActiveRecord::LogSubscriber.send :prepend, RailsPerformance::Extensions::Db if defined?(ActiveRecord)
59
59
 
60
- if defined?(::Rake::Task)
60
+ if defined?(::Rake::Task) && RailsPerformance.include_rake_tasks
61
61
  require_relative './gems/rake_ext.rb'
62
62
  RailsPerformance::Gems::RakeExt.init
63
63
  end
@@ -5,6 +5,7 @@ module RailsPerformance
5
5
 
6
6
  def measure(tag_name, namespace_name = nil)
7
7
  return yield unless RailsPerformance.enabled
8
+ return yield unless RailsPerformance.include_custom_events
8
9
 
9
10
  begin
10
11
  now = Time.current
@@ -14,8 +14,10 @@ module RailsPerformance
14
14
  raise(ex)
15
15
  ensure
16
16
  if !RailsPerformance.skipable_rake_tasks.include?(self.name)
17
+ task_info = RailsPerformance::Gems::RakeExt.find_task_name(*args)
18
+ task_info = [self.name] if task_info.empty?
17
19
  RailsPerformance::Models::RakeRecord.new(
18
- task: RailsPerformance::Gems::RakeExt.find_task_name(*args),
20
+ task: task_info,
19
21
  datetime: now.strftime(RailsPerformance::FORMAT),
20
22
  datetimei: now.to_i,
21
23
  duration: (Time.current - now) * 1000,
@@ -23,6 +23,7 @@ module RailsPerformance
23
23
  event = ActiveSupport::Notifications::Event.new(event_name, started, finished, event_id, payload)
24
24
 
25
25
  return if RailsPerformance.ignored_endpoints.include? "#{event.payload[:controller]}##{event.payload[:action]}"
26
+ return if RailsPerformance.ignored_paths.any? { |p| event.payload[:path].start_with?(p) }
26
27
 
27
28
  record = {
28
29
  controller: event.payload[:controller],
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.3'
3
3
  SCHEMA = '1.0.1'
4
4
  end
@@ -83,6 +83,12 @@ module RailsPerformance
83
83
  end
84
84
  @@ignored_endpoints = []
85
85
 
86
+ mattr_reader :ignored_paths
87
+ def RailsPerformance.ignored_paths=(paths)
88
+ @@ignored_paths = Set.new(paths)
89
+ end
90
+ @@ignored_paths = []
91
+
86
92
  # skip requests if it's inside Rails Performance view
87
93
  mattr_accessor :skip
88
94
  @@skip = false
@@ -99,6 +105,14 @@ module RailsPerformance
99
105
  mattr_accessor :custom_data_proc
100
106
  @@custom_data_proc = nil
101
107
 
108
+ # include rake tasks
109
+ mattr_accessor :include_rake_tasks
110
+ @@include_rake_tasks = false
111
+
112
+ # include custom events
113
+ mattr_accessor :include_custom_events
114
+ @@include_custom_events = true
115
+
102
116
  def RailsPerformance.setup
103
117
  yield(self)
104
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-29 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -273,7 +273,7 @@ files:
273
273
  - app/assets/images/user.svg
274
274
  - app/controllers/rails_performance/base_controller.rb
275
275
  - app/controllers/rails_performance/rails_performance_controller.rb
276
- - app/helpers/rails_performance/application_helper.rb
276
+ - app/helpers/rails_performance/rails_performance_helper.rb
277
277
  - app/views/rails_performance/_panel.html.erb
278
278
  - app/views/rails_performance/javascripts/_javascripts.html.erb
279
279
  - app/views/rails_performance/javascripts/app.js
@@ -362,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
362
  - !ruby/object:Gem::Version
363
363
  version: '0'
364
364
  requirements: []
365
- rubygems_version: 3.4.10
365
+ rubygems_version: 3.5.11
366
366
  signing_key:
367
367
  specification_version: 4
368
368
  summary: Simple Rails Performance tracker. Alternative to the NewRelic, Datadog or