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 +4 -4
- data/README.md +7 -4
- data/Rakefile +7 -5
- data/app/controllers/inner_performance/application_controller.rb +2 -0
- data/app/controllers/inner_performance/dashboard_controller.rb +2 -0
- data/app/controllers/inner_performance/events_controller.rb +3 -1
- data/app/helpers/inner_performance/application_helper.rb +2 -0
- data/app/jobs/inner_performance/application_job.rb +2 -0
- data/app/jobs/inner_performance/cleanup_job.rb +5 -1
- data/app/jobs/inner_performance/save_event_job.rb +2 -0
- data/app/mailers/inner_performance/application_mailer.rb +4 -2
- data/app/models/inner_performance/application_record.rb +2 -0
- data/app/models/inner_performance/event.rb +5 -3
- data/app/models/inner_performance/events/perform_active_job.rb +2 -0
- data/app/models/inner_performance/events/process_action_action_controller.rb +2 -0
- data/config/routes.rb +3 -3
- data/db/migrate/20241123121600_create_inner_performance_events.rb +9 -7
- data/db/migrate/20241124111458_add_type_to_inner_performance_events.rb +2 -0
- data/lib/inner_performance/configuration.rb +3 -4
- data/lib/inner_performance/engine.rb +2 -0
- data/lib/inner_performance/version.rb +3 -1
- data/lib/inner_performance.rb +9 -7
- data/lib/tasks/inner_performance_tasks.rake +2 -0
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 761ab8ec52713467243aa93a5b2f82804f4d70f5fcbe8a571f1873e38ad289af
|
4
|
+
data.tar.gz: b05a53a01997aee49f40e0bfc488d34d5257e2edb9c26fac038461b13a811190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
load "rails/tasks/engine.rake"
|
3
|
+
require 'bundler/setup'
|
5
4
|
|
6
|
-
|
5
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
6
|
+
load 'rails/tasks/engine.rake'
|
7
7
|
|
8
|
-
|
8
|
+
load 'rails/tasks/statistics.rake'
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
@@ -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 =
|
9
|
+
@q.sorts = 'created_at desc' if @q.sorts.empty?
|
8
10
|
@pagy, @events = pagy(@q.result)
|
9
11
|
end
|
10
12
|
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
|
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,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(
|
6
|
-
[
|
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(
|
11
|
+
def self.ransackable_associations(_auth_object = nil)
|
10
12
|
[]
|
11
13
|
end
|
12
14
|
end
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
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:
|
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
|
5
|
-
t.string
|
6
|
-
t.decimal
|
7
|
-
t.decimal
|
8
|
-
t.datetime
|
9
|
-
t.datetime
|
10
|
-
t.text
|
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,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 = {
|
data/lib/inner_performance.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
require "inner_performance/engine"
|
3
|
-
require "inner_performance/configuration"
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
require
|
6
|
-
require
|
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
|
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
|
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,
|
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.
|
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-
|
11
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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:
|
70
|
+
name: factory_bot
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
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:
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|