inner_performance 0.1.3 → 0.1.4

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: 53088317c2b4b7c73dfd80fc3483333d6a20cd2016c9898a14ddbff4ae351cfd
4
- data.tar.gz: eca7db5ab49eb2fc2b17826a882e3490333a84b686eecf9da053ffe7064da55b
3
+ metadata.gz: 761ab8ec52713467243aa93a5b2f82804f4d70f5fcbe8a571f1873e38ad289af
4
+ data.tar.gz: b05a53a01997aee49f40e0bfc488d34d5257e2edb9c26fac038461b13a811190
5
5
  SHA512:
6
- metadata.gz: 885de0b3cd67f4447fc9a66b134f08b91872bb66bce3edfe3c6c8d81ee402e0c519949328cd55557fab364051097bacd9ef6b3de24d6581bf2aebe23b0452c22
7
- data.tar.gz: f4e2d87b9c5cd8a730f11ec9457436aba89db3803ed7e8b504272388ee6746701d5199c91ff9090b322819d93d4627ca76c60d02eb58c1cab01356ace21c05ec
6
+ metadata.gz: 6754adf03e924da656a5b0c44b492071a8f28772919b989ca5581ea21d82530485f0a9edfc71e8c6609002fcc881ee07670ce5b5bd42adaa04e14b2a99683649
7
+ data.tar.gz: f6805d89fa9b98230567799fd3db2e4217c99fd36d535938cbd5390908a5f1cb0bca16f001663e734d42d3a733a4d266b161cc0094960b2f60cdb41a7fdb8abc
data/README.md CHANGED
@@ -43,7 +43,7 @@ InnerPerformance.configure do |config|
43
43
  # approx. 170 requests per minute, keeping it at default 2%
44
44
  # provides me more than enough data to analyze and locate the
45
45
  # bottlenecks.
46
- 'process_action.action_controller' => 2,
46
+ 'process_action.action_controller' => (Rails.env.production? ? 2 : 100),
47
47
 
48
48
  # 100% of all the jobs will be stored and analyzed.
49
49
  'perform.active_job' => 100
@@ -72,9 +72,12 @@ InnerPerformance.configure do |config|
72
72
  end
73
73
  ```
74
74
 
75
- `InnerPerformance` will produce an infinite amount of event records so in order
76
- to clean them up, you should periodically run
77
- `InnerPerformance::CleanupJob.perform_later`.
75
+ ## Regular Housekeeping
76
+ To ensure optimal performance and avoid data bloat, remember to schedule the cleanup job:
77
+
78
+ ```ruby
79
+ InnerPerformance::CleanupJob.perform_later
80
+ ```
78
81
 
79
82
  # Alternatives
80
83
 
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
- require "bundler/setup"
1
+ # frozen_string_literal: true
2
2
 
3
- APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
- load "rails/tasks/engine.rake"
3
+ require 'bundler/setup'
5
4
 
6
- load "rails/tasks/statistics.rake"
5
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
6
+ load 'rails/tasks/engine.rake'
7
7
 
8
- require "bundler/gem_tasks"
8
+ load 'rails/tasks/statistics.rake'
9
+
10
+ require 'bundler/gem_tasks'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class ApplicationController < ActionController::Base
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class DashboardController < ApplicationController
3
5
  def index
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class EventsController < ApplicationController
3
5
  include Pagy::Backend
4
6
 
5
7
  def index
6
8
  @q = InnerPerformance::Event.all.ransack(params[:q])
7
- @q.sorts = "created_at desc" if @q.sorts.empty?
9
+ @q.sorts = 'created_at desc' if @q.sorts.empty?
8
10
  @pagy, @events = pagy(@q.result)
9
11
  end
10
12
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  module ApplicationHelper
3
5
  include Pagy::Frontend
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class ApplicationJob < ActiveJob::Base
3
5
  end
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class CleanupJob < ApplicationJob
3
5
  def perform
4
- InnerPerformance::Event.where('created_at >= ?', InnerPerformance.configuration.events_retention)
6
+ InnerPerformance::Event
7
+ .where('created_at < ?', InnerPerformance.configuration.events_retention.ago)
8
+ .destroy_all
5
9
  end
6
10
  end
7
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class SaveEventJob < ApplicationJob
3
5
  def perform(type:, created_at:, event:, name:, duration:, db_runtime:, properties: {})
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
4
- layout "mailer"
5
+ default from: 'from@example.com'
6
+ layout 'mailer'
5
7
  end
6
8
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class ApplicationRecord < ActiveRecord::Base
3
5
  self.abstract_class = true
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class Event < ApplicationRecord
3
5
  serialize :properties, coder: JSON
4
6
 
5
- def self.ransackable_attributes(auth_object = nil)
6
- ["created_at", "db_runtime", "duration", "event", "format", "id", "name"]
7
+ def self.ransackable_attributes(_auth_object = nil)
8
+ %w[created_at db_runtime duration event format id name]
7
9
  end
8
10
 
9
- def self.ransackable_associations(auth_object = nil)
11
+ def self.ransackable_associations(_auth_object = nil)
10
12
  []
11
13
  end
12
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  module Events
3
5
  class PerformActiveJob < InnerPerformance::Event
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  module Events
3
5
  class ProcessActionActionController < InnerPerformance::Event
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
- InnerPerformance::Engine.routes.draw do
2
- mount InnerPerformance::Engine, at: '/performance'
1
+ # frozen_string_literal: true
3
2
 
3
+ InnerPerformance::Engine.routes.draw do
4
4
  resources :events, only: [:index]
5
5
 
6
- root to: "dashboard#index"
6
+ root to: 'dashboard#index'
7
7
  end
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateInnerPerformanceEvents < ActiveRecord::Migration[7.1]
2
4
  def change
3
5
  create_table :inner_performance_events, force: :cascade do |t|
4
- t.string "event"
5
- t.string "name"
6
- t.decimal "duration"
7
- t.decimal "db_runtime"
8
- t.datetime "created_at", null: false
9
- t.datetime "updated_at", null: false
10
- t.text "properties", default: "{}"
6
+ t.string 'event'
7
+ t.string 'name'
8
+ t.decimal 'duration'
9
+ t.decimal 'db_runtime'
10
+ t.datetime 'created_at', null: false
11
+ t.datetime 'updated_at', null: false
12
+ t.text 'properties', default: '{}'
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddTypeToInnerPerformanceEvents < ActiveRecord::Migration[7.1]
2
4
  def change
3
5
  add_column :inner_performance_events, :type, :string
@@ -1,9 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class Configuration
3
- attr_accessor :sample_rates
4
- attr_accessor :events_retention
5
- attr_accessor :medium_duration_range
6
- attr_accessor :ignore_rules
5
+ attr_accessor :sample_rates, :events_retention, :medium_duration_range, :ignore_rules
7
6
 
8
7
  def initialize
9
8
  @sample_rates = {
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
4
  class Engine < ::Rails::Engine
3
5
  isolate_namespace InnerPerformance
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InnerPerformance
2
- VERSION = "0.1.3"
4
+ VERSION = '0.1.4'
3
5
  end
@@ -1,9 +1,11 @@
1
- require "inner_performance/version"
2
- require "inner_performance/engine"
3
- require "inner_performance/configuration"
1
+ # frozen_string_literal: true
4
2
 
5
- require "ransack"
6
- require "pagy"
3
+ require 'inner_performance/version'
4
+ require 'inner_performance/engine'
5
+ require 'inner_performance/configuration'
6
+
7
+ require 'ransack'
8
+ require 'pagy'
7
9
 
8
10
  module InnerPerformance
9
11
  class << self
@@ -16,7 +18,7 @@ module InnerPerformance
16
18
  end
17
19
 
18
20
  def install!
19
- ActiveSupport::Notifications.subscribe "process_action.action_controller" do |event|
21
+ ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |event|
20
22
  if save_event?(event)
21
23
  InnerPerformance::SaveEventJob.perform_later(
22
24
  type: InnerPerformance::Events::ProcessActionActionController.name,
@@ -32,7 +34,7 @@ module InnerPerformance
32
34
  end
33
35
  end
34
36
 
35
- ActiveSupport::Notifications.subscribe "perform.active_job" do |event|
37
+ ActiveSupport::Notifications.subscribe 'perform.active_job' do |event|
36
38
  if save_event?(event)
37
39
  InnerPerformance::SaveEventJob.perform_later(
38
40
  type: InnerPerformance::Events::PerformActiveJob.name,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :inner_performance do
3
5
  # # Task goes here
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inner_performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbajur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-24 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: activejob
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.1.5
27
27
  - !ruby/object:Gem::Dependency
28
- name: activejob
28
+ name: pagy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 9.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 9.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -53,19 +67,19 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: 4.2.1
55
69
  - !ruby/object:Gem::Dependency
56
- name: pagy
70
+ name: factory_bot
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 9.3.1
62
- type: :runtime
75
+ version: '0'
76
+ type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 9.3.1
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec-rails
71
85
  requirement: !ruby/object:Gem::Requirement