Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkasyanchuk committed May 6, 2024
1 parent 969b71e commit e0fdbc7
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
- Unreleased

- 1.2.2
- fixed issue with undefined helpers https://github.com/igorkasyanchuk/rails_performance/pull/78
- configuration for include_rake_tasks, include_custom_events monitoring

- 1.2.1
- Depend only on railties instead of rails https://github.com/igorkasyanchuk/rails_performance/pull/63
- Delete unused .travis.yml https://github.com/igorkasyanchuk/rails_performance/pull/62
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rails_performance (1.2.1)
rails_performance (1.2.2)
browser
railties
redis
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ RailsPerformance.setup do |config|
# config home button link
config.home_link = '/'

# To skip some Rake tasks from monitoring
config.skipable_rake_tasks = ['webpacker:compile']

# To monitor rake tasks performance, you need to include rake tasks
# config.include_rake_tasks = false

# To monitor custom events with `RailsPerformance.measure` block
# config.include_custom_events = true
end if defined?(RailsPerformance)
```

Expand Down Expand Up @@ -241,6 +248,7 @@ If "schema" how records are stored i Redis is changed, and this is a breaking ch
- https://github.com/carl-printreleaf
- https://github.com/langalex
- https://github.com/olleolleolle
- https://github.com/desheikh

[<img src="https://opensource-heroes.com/svg/embed/igorkasyanchuk/rails_performance"
/>](https://opensource-heroes.com/r/igorkasyanchuk/rails_performance)
Expand Down
8 changes: 6 additions & 2 deletions app/views/rails_performance/shared/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
<% if defined?(Grape) %>
<%= link_to 'Grape', rails_performance.rails_performance_grape_url, class: "navbar-item #{active?(:grape)}" %>
<% end %>
<%= link_to 'Rake', rails_performance.rails_performance_rake_url, class: "navbar-item #{active?(:rake)}" %>
<%= link_to 'Custom Events', rails_performance.rails_performance_custom_url, class: "navbar-item #{active?(:custom)}" %>
<% if RailsPerformance.include_rake_tasks %>
<%= link_to 'Rake', rails_performance.rails_performance_rake_url, class: "navbar-item #{active?(:rake)}" %>
<% end %>
<% if RailsPerformance.include_custom_events %>
<%= link_to 'Custom Events', rails_performance.rails_performance_custom_url, class: "navbar-item #{active?(:custom)}" %>
<% end %>
</div>

<div class="navbar-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@

# config home button link
config.home_link = '/'
config.skipable_rake_tasks = ['webpacker:compile']
config.include_rake_tasks = false
config.include_custom_events = true
end if defined?(RailsPerformance)
8 changes: 8 additions & 0 deletions lib/rails_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def RailsPerformance.ignored_endpoints=(endpoints)
mattr_accessor :custom_data_proc
@@custom_data_proc = nil

# include rake tasks
mattr_accessor :include_rake_tasks
@@include_rake_tasks = false

# include custom events
mattr_accessor :include_custom_events
@@include_custom_events = true

def RailsPerformance.setup
yield(self)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_performance/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Engine < ::Rails::Engine
ActionView::LogSubscriber.send :prepend, RailsPerformance::Extensions::View
ActiveRecord::LogSubscriber.send :prepend, RailsPerformance::Extensions::Db if defined?(ActiveRecord)

if defined?(::Rake::Task)
if defined?(::Rake::Task) && RailsPerformance.include_rake_tasks
require_relative './gems/rake_ext.rb'
RailsPerformance::Gems::RakeExt.init
end
Expand Down
1 change: 1 addition & 0 deletions lib/rails_performance/gems/custom_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module CustomExtension

def measure(tag_name, namespace_name = nil)
return yield unless RailsPerformance.enabled
return yield unless RailsPerformance.include_custom_events

begin
now = Time.current
Expand Down
4 changes: 3 additions & 1 deletion lib/rails_performance/gems/rake_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def invoke_with_rails_performance(*args)
raise(ex)
ensure
if !RailsPerformance.skipable_rake_tasks.include?(self.name)
task_info = RailsPerformance::Gems::RakeExt.find_task_name(*args)
task_info = [self.name] if task_info.empty?
RailsPerformance::Models::RakeRecord.new(
task: RailsPerformance::Gems::RakeExt.find_task_name(*args),
task: task_info,
datetime: now.strftime(RailsPerformance::FORMAT),
datetimei: now.to_i,
duration: (Time.current - now) * 1000,
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_performance/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module RailsPerformance
VERSION = '1.2.1'
VERSION = '1.2.2'
SCHEMA = '1.0.1'
end
3 changes: 3 additions & 0 deletions test/dummy/config/initializers/rails_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@

# config home button link
config.home_link = '/'

config.include_rake_tasks = true
config.include_custom_events = false
end if defined?(RailsPerformance)
21 changes: 10 additions & 11 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_04_01_083434) do

ActiveRecord::Schema[7.0].define(version: 2023_04_01_083434) do
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "handler", null: false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.datetime "run_at", precision: nil
t.datetime "locked_at", precision: nil
t.datetime "failed_at", precision: nil
t.string "locked_by"
t.string "queue"
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.datetime "created_at"
t.datetime "updated_at"
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
end

create_table "users", force: :cascade do |t|
t.string "first_name"
t.integer "age"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "reset_password_sent_at", precision: nil
t.datetime "remember_created_at", precision: nil
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end

Expand Down

0 comments on commit e0fdbc7

Please sign in to comment.