rails_performance 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -13
  3. data/Rakefile +14 -14
  4. data/app/assets/images/download.svg +3 -0
  5. data/app/controllers/rails_performance/base_controller.rb +21 -21
  6. data/app/controllers/rails_performance/concerns/csv_exportable.rb +29 -0
  7. data/app/controllers/rails_performance/rails_performance_controller.rb +95 -49
  8. data/app/helpers/rails_performance/rails_performance_helper.rb +152 -156
  9. data/app/views/rails_performance/javascripts/app.js +2 -2
  10. data/app/views/rails_performance/rails_performance/_export.html.erb +3 -0
  11. data/app/views/rails_performance/rails_performance/crashes.html.erb +8 -1
  12. data/app/views/rails_performance/rails_performance/recent.html.erb +8 -6
  13. data/app/views/rails_performance/rails_performance/requests.html.erb +8 -1
  14. data/app/views/rails_performance/rails_performance/slow.html.erb +3 -0
  15. data/app/views/rails_performance/shared/_header.html.erb +0 -1
  16. data/app/views/rails_performance/stylesheets/style.css +6 -0
  17. data/config/routes.rb +16 -18
  18. data/lib/generators/rails_performance/install/install_generator.rb +1 -1
  19. data/lib/generators/rails_performance/install/templates/initializer.rb +56 -42
  20. data/lib/rails_performance/data_source.rb +120 -121
  21. data/lib/rails_performance/engine.rb +8 -8
  22. data/lib/rails_performance/extensions/trace.rb +32 -33
  23. data/lib/rails_performance/gems/custom_ext.rb +31 -34
  24. data/lib/rails_performance/gems/delayed_job_ext.rb +50 -54
  25. data/lib/rails_performance/gems/grape_ext.rb +33 -35
  26. data/lib/rails_performance/gems/rake_ext.rb +41 -44
  27. data/lib/rails_performance/gems/sidekiq_ext.rb +34 -37
  28. data/lib/rails_performance/instrument/metrics_collector.rb +50 -50
  29. data/lib/rails_performance/models/base_record.rb +33 -36
  30. data/lib/rails_performance/models/collection.rb +35 -36
  31. data/lib/rails_performance/models/custom_record.rb +47 -48
  32. data/lib/rails_performance/models/delayed_job_record.rb +61 -62
  33. data/lib/rails_performance/models/grape_record.rb +60 -61
  34. data/lib/rails_performance/models/rake_record.rb +48 -49
  35. data/lib/rails_performance/models/request_record.rb +123 -120
  36. data/lib/rails_performance/models/sidekiq_record.rb +65 -66
  37. data/lib/rails_performance/models/trace_record.rb +18 -19
  38. data/lib/rails_performance/rails/middleware.rb +75 -76
  39. data/lib/rails_performance/rails/query_builder.rb +18 -20
  40. data/lib/rails_performance/reports/base_report.rb +60 -60
  41. data/lib/rails_performance/reports/breakdown_report.rb +15 -18
  42. data/lib/rails_performance/reports/crash_report.rb +15 -17
  43. data/lib/rails_performance/reports/recent_requests_report.rb +24 -24
  44. data/lib/rails_performance/reports/requests_report.rb +27 -27
  45. data/lib/rails_performance/reports/response_time_report.rb +17 -17
  46. data/lib/rails_performance/reports/slow_requests_report.rb +4 -4
  47. data/lib/rails_performance/reports/throughput_report.rb +15 -17
  48. data/lib/rails_performance/reports/trace_report.rb +16 -18
  49. data/lib/rails_performance/thread/current_request.rb +33 -34
  50. data/lib/rails_performance/utils.rb +53 -54
  51. data/lib/rails_performance/version.rb +2 -2
  52. data/lib/rails_performance.rb +33 -34
  53. metadata +20 -3
@@ -1,34 +1,33 @@
1
- module RailsPerformance
2
- class CurrentRequest
3
- attr_reader :request_id, :tracings, :ignore
4
- attr_accessor :data
5
- attr_accessor :record
6
-
7
- def CurrentRequest.init
8
- Thread.current[:rp_current_request] ||= CurrentRequest.new(SecureRandom.hex(16))
9
- end
10
-
11
- def CurrentRequest.current
12
- CurrentRequest.init
13
- end
14
-
15
- def CurrentRequest.cleanup
16
- RailsPerformance.log "----------------------------------------------------> CurrentRequest.cleanup !!!!!!!!!!!! -------------------------\n\n"
17
- RailsPerformance.skip = false
18
- Thread.current[:rp_current_request] = nil
19
- end
20
-
21
- def initialize(request_id)
22
- @request_id = request_id
23
- @tracings = []
24
- @ignore = Set.new
25
- @data = nil
26
- @record = nil
27
- end
28
-
29
- def trace(options = {})
30
- @tracings << options.merge(time: Time.current.to_i)
31
- end
32
-
33
- end
34
- end
1
+ module RailsPerformance
2
+ class CurrentRequest
3
+ attr_reader :request_id, :tracings, :ignore
4
+ attr_accessor :data
5
+ attr_accessor :record
6
+
7
+ def self.init
8
+ Thread.current[:rp_current_request] ||= CurrentRequest.new(SecureRandom.hex(16))
9
+ end
10
+
11
+ def self.current
12
+ CurrentRequest.init
13
+ end
14
+
15
+ def self.cleanup
16
+ RailsPerformance.log "----------------------------------------------------> CurrentRequest.cleanup !!!!!!!!!!!! -------------------------\n\n"
17
+ RailsPerformance.skip = false
18
+ Thread.current[:rp_current_request] = nil
19
+ end
20
+
21
+ def initialize(request_id)
22
+ @request_id = request_id
23
+ @tracings = []
24
+ @ignore = Set.new
25
+ @data = nil
26
+ @record = nil
27
+ end
28
+
29
+ def trace(options = {})
30
+ @tracings << options.merge(time: Time.current.to_i)
31
+ end
32
+ end
33
+ end
@@ -1,54 +1,53 @@
1
- module RailsPerformance
2
-
3
- class Utils
4
- # date key in redis store
5
- def Utils.cache_key(now = Date.today)
6
- "date-#{now}"
7
- end
8
-
9
- # write to current slot
10
- # time - date -minute
11
- def Utils.field_key(now = Time.current)
12
- now.strftime("%H:%M")
13
- end
14
-
15
- def Utils.fetch_from_redis(query)
16
- RailsPerformance.log "\n\n [REDIS QUERY] --> #{query}\n\n"
17
-
18
- keys = RailsPerformance.redis.keys(query)
19
- return [] if keys.blank?
20
- values = RailsPerformance.redis.mget(keys)
21
-
22
- RailsPerformance.log "\n\n [FOUND] --> #{values.size}\n\n"
23
-
24
- [keys, values]
25
- end
26
-
27
- def Utils.save_to_redis(key, value, expire = RailsPerformance.duration.to_i)
28
- # TODO think here if add return
29
- #return if value.empty?
30
-
31
- RailsPerformance.log " [SAVE] key ---> #{key}\n"
32
- RailsPerformance.log " [SAVE] value ---> #{value.to_json}\n\n"
33
- RailsPerformance.redis.set(key, value.to_json, ex: expire.to_i)
34
- end
35
-
36
- def Utils.days
37
- (RailsPerformance.duration / 1.day) + 1
38
- end
39
-
40
- def Utils.median(array)
41
- sorted = array.sort
42
- size = sorted.size
43
- center = size / 2
44
-
45
- if size == 0
46
- nil
47
- elsif size.even?
48
- (sorted[center - 1] + sorted[center]) / 2.0
49
- else
50
- sorted[center]
51
- end
52
- end
53
- end
54
- end
1
+ module RailsPerformance
2
+ class Utils
3
+ # date key in redis store
4
+ def self.cache_key(now = Date.today)
5
+ "date-#{now}"
6
+ end
7
+
8
+ # write to current slot
9
+ # time - date -minute
10
+ def self.field_key(now = Time.current)
11
+ now.strftime("%H:%M")
12
+ end
13
+
14
+ def self.fetch_from_redis(query)
15
+ RailsPerformance.log "\n\n [REDIS QUERY] --> #{query}\n\n"
16
+
17
+ keys = RailsPerformance.redis.keys(query)
18
+ return [] if keys.blank?
19
+ values = RailsPerformance.redis.mget(keys)
20
+
21
+ RailsPerformance.log "\n\n [FOUND] --> #{values.size}\n\n"
22
+
23
+ [keys, values]
24
+ end
25
+
26
+ def self.save_to_redis(key, value, expire = RailsPerformance.duration.to_i)
27
+ # TODO think here if add return
28
+ # return if value.empty?
29
+
30
+ RailsPerformance.log " [SAVE] key ---> #{key}\n"
31
+ RailsPerformance.log " [SAVE] value ---> #{value.to_json}\n\n"
32
+ RailsPerformance.redis.set(key, value.to_json, ex: expire.to_i)
33
+ end
34
+
35
+ def self.days
36
+ (RailsPerformance.duration / 1.day) + 1
37
+ end
38
+
39
+ def self.median(array)
40
+ sorted = array.sort
41
+ size = sorted.size
42
+ center = size / 2
43
+
44
+ if size == 0
45
+ nil
46
+ elsif size.even?
47
+ (sorted[center - 1] + sorted[center]) / 2.0
48
+ else
49
+ sorted[center]
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = '1.2.3'
3
- SCHEMA = '1.0.1'
2
+ VERSION = "1.3.0"
3
+ SCHEMA = "1.0.1"
4
4
  end
@@ -1,31 +1,31 @@
1
1
  require "redis"
2
2
  require "redis-namespace"
3
3
  require "browser"
4
- require 'active_support/core_ext/integer'
5
- require_relative "./rails_performance/version.rb"
6
- require_relative "rails_performance/rails/query_builder.rb"
7
- require_relative "rails_performance/rails/middleware.rb"
8
- require_relative "rails_performance/models/base_record.rb"
9
- require_relative "rails_performance/models/request_record.rb"
10
- require_relative "rails_performance/models/sidekiq_record.rb"
11
- require_relative "rails_performance/models/delayed_job_record.rb"
12
- require_relative "rails_performance/models/grape_record.rb"
13
- require_relative "rails_performance/models/trace_record.rb"
14
- require_relative "rails_performance/models/rake_record.rb"
15
- require_relative "rails_performance/models/custom_record.rb"
16
- require_relative "rails_performance/data_source.rb"
17
- require_relative "rails_performance/utils.rb"
18
- require_relative "rails_performance/reports/base_report.rb"
19
- require_relative "rails_performance/reports/requests_report.rb"
20
- require_relative "rails_performance/reports/crash_report.rb"
21
- require_relative "rails_performance/reports/response_time_report.rb"
22
- require_relative "rails_performance/reports/throughput_report.rb"
23
- require_relative "rails_performance/reports/recent_requests_report.rb"
24
- require_relative "rails_performance/reports/slow_requests_report.rb"
25
- require_relative "rails_performance/reports/breakdown_report.rb"
26
- require_relative "rails_performance/reports/trace_report.rb"
27
- require_relative "rails_performance/extensions/trace.rb"
28
- require_relative "rails_performance/thread/current_request.rb"
4
+ require "active_support/core_ext/integer"
5
+ require_relative "rails_performance/version"
6
+ require_relative "rails_performance/rails/query_builder"
7
+ require_relative "rails_performance/rails/middleware"
8
+ require_relative "rails_performance/models/base_record"
9
+ require_relative "rails_performance/models/request_record"
10
+ require_relative "rails_performance/models/sidekiq_record"
11
+ require_relative "rails_performance/models/delayed_job_record"
12
+ require_relative "rails_performance/models/grape_record"
13
+ require_relative "rails_performance/models/trace_record"
14
+ require_relative "rails_performance/models/rake_record"
15
+ require_relative "rails_performance/models/custom_record"
16
+ require_relative "rails_performance/data_source"
17
+ require_relative "rails_performance/utils"
18
+ require_relative "rails_performance/reports/base_report"
19
+ require_relative "rails_performance/reports/requests_report"
20
+ require_relative "rails_performance/reports/crash_report"
21
+ require_relative "rails_performance/reports/response_time_report"
22
+ require_relative "rails_performance/reports/throughput_report"
23
+ require_relative "rails_performance/reports/recent_requests_report"
24
+ require_relative "rails_performance/reports/slow_requests_report"
25
+ require_relative "rails_performance/reports/breakdown_report"
26
+ require_relative "rails_performance/reports/trace_report"
27
+ require_relative "rails_performance/extensions/trace"
28
+ require_relative "rails_performance/thread/current_request"
29
29
 
30
30
  module RailsPerformance
31
31
  FORMAT = "%Y%m%dT%H%M"
@@ -67,24 +67,24 @@ module RailsPerformance
67
67
 
68
68
  # Enable http basic authentication
69
69
  mattr_accessor :http_basic_authentication_user_name
70
- @@http_basic_authentication_user_name = 'rails_performance'
70
+ @@http_basic_authentication_user_name = "rails_performance"
71
71
 
72
72
  # Enable http basic authentication
73
73
  mattr_accessor :http_basic_authentication_password
74
- @@http_basic_authentication_password = 'password12'
74
+ @@http_basic_authentication_password = "password12"
75
75
 
76
76
  # If you want to enable access by specific conditions
77
77
  mattr_accessor :verify_access_proc
78
78
  @@verify_access_proc = proc { |controller| true }
79
79
 
80
80
  mattr_reader :ignored_endpoints
81
- def RailsPerformance.ignored_endpoints=(endpoints)
81
+ def self.ignored_endpoints=(endpoints)
82
82
  @@ignored_endpoints = Set.new(endpoints)
83
83
  end
84
84
  @@ignored_endpoints = []
85
85
 
86
86
  mattr_reader :ignored_paths
87
- def RailsPerformance.ignored_paths=(paths)
87
+ def self.ignored_paths=(paths)
88
88
  @@ignored_paths = Set.new(paths)
89
89
  end
90
90
  @@ignored_paths = []
@@ -95,7 +95,7 @@ module RailsPerformance
95
95
 
96
96
  # config home button link
97
97
  mattr_accessor :home_link
98
- @@home_link = '/'
98
+ @@home_link = "/"
99
99
 
100
100
  # skip performance tracking for these rake tasks
101
101
  mattr_accessor :skipable_rake_tasks
@@ -113,11 +113,11 @@ module RailsPerformance
113
113
  mattr_accessor :include_custom_events
114
114
  @@include_custom_events = true
115
115
 
116
- def RailsPerformance.setup
116
+ def self.setup
117
117
  yield(self)
118
118
  end
119
119
 
120
- def RailsPerformance.log(message)
120
+ def self.log(message)
121
121
  return unless RailsPerformance.debug
122
122
 
123
123
  if ::Rails.logger
@@ -127,10 +127,9 @@ module RailsPerformance
127
127
  puts(message)
128
128
  end
129
129
  end
130
-
131
130
  end
132
131
 
133
132
  require "rails_performance/engine"
134
133
 
135
- require_relative './rails_performance/gems/custom_ext.rb'
134
+ require_relative "rails_performance/gems/custom_ext"
136
135
  RailsPerformance.send :extend, RailsPerformance::Gems::CustomExtension
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.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
11
+ date: 2024-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: standardrb
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
251
265
  description: 3rd party dependency-free solution how to monitor performance of your
252
266
  Rails applications.
253
267
  email:
@@ -263,6 +277,7 @@ files:
263
277
  - app/assets/images/activity.svg
264
278
  - app/assets/images/bot.svg
265
279
  - app/assets/images/close.svg
280
+ - app/assets/images/download.svg
266
281
  - app/assets/images/export.svg
267
282
  - app/assets/images/git.svg
268
283
  - app/assets/images/github.svg
@@ -272,6 +287,7 @@ files:
272
287
  - app/assets/images/stat.svg
273
288
  - app/assets/images/user.svg
274
289
  - app/controllers/rails_performance/base_controller.rb
290
+ - app/controllers/rails_performance/concerns/csv_exportable.rb
275
291
  - app/controllers/rails_performance/rails_performance_controller.rb
276
292
  - app/helpers/rails_performance/rails_performance_helper.rb
277
293
  - app/views/rails_performance/_panel.html.erb
@@ -284,6 +300,7 @@ files:
284
300
  - app/views/rails_performance/javascripts/stupidtable.min.js
285
301
  - app/views/rails_performance/javascripts/table.js
286
302
  - app/views/rails_performance/layouts/rails_performance.html.erb
303
+ - app/views/rails_performance/rails_performance/_export.html.erb
287
304
  - app/views/rails_performance/rails_performance/_recent_row.html.erb
288
305
  - app/views/rails_performance/rails_performance/_summary.html.erb
289
306
  - app/views/rails_performance/rails_performance/_trace.html.erb
@@ -362,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
379
  - !ruby/object:Gem::Version
363
380
  version: '0'
364
381
  requirements: []
365
- rubygems_version: 3.5.11
382
+ rubygems_version: 3.5.16
366
383
  signing_key:
367
384
  specification_version: 4
368
385
  summary: Simple Rails Performance tracker. Alternative to the NewRelic, Datadog or