rails_memory_profiler 0.4.0 → 0.5.0

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: fa527a002dfe7bdf8307360e9eded859fa51622ca28d1b99ca53fcadda61bc78
4
- data.tar.gz: b85c978f7ec9c9cd2120ed48edc6d5edf5bc639bd4ea95af5b9847bca58c4cba
3
+ metadata.gz: 0ecc5cf3944827bacd93b4ba2609cf46516c1a2ecf54ff922e1b36d36e7e1592
4
+ data.tar.gz: 50de3643fab494e8d03a494d4c776914c234469844b095deb0964efbf94036ce
5
5
  SHA512:
6
- metadata.gz: cd8f69ff8d967c67e029f8fe5d7b8ac193e1974262fa11a95faa2404b447d62af0fd2d9c6105df08e6d24abcfc08ca31926bce26b1812a61d2eb114aebd865bd
7
- data.tar.gz: 32ed317544cf8e552044ff309d27138010aa9759cd4ae0cbf7ee69b699dcca59a9b40c61d2ad37bb201d6c9ccd7f7e2e0317d47df66412b370ac277b5184e4c4
6
+ metadata.gz: '091da3ac58edfd24e7fb0c8090e782a9af30d08dd2f5d59054b9f8108704c99f2c7ac238def2004730c22a77442ece51375ed221694666b828b76cb589e8dd0c'
7
+ data.tar.gz: 8bd3e45989fe1cac7bb15b02304d8e846977fa643652d949f2b4ba683019074334678d364dd81cc7ab939f453c6418f6a6f8556142685cf00fb7c65675912416
data/README.md CHANGED
@@ -74,7 +74,7 @@ All options and their defaults:
74
74
  | `store_size` | `100` | Max reports in the ring buffer; oldest are evicted when full |
75
75
  | `dashboard_enabled` | `true` in development | Enable the dashboard endpoint |
76
76
  | `min_allocated_objects` | `0` | Skip requests that allocate fewer objects than this |
77
- | `ignore_paths` | `[]` | Paths to skip — strings (prefix) or regexes |
77
+ | `ignore_paths` | `[]` | Additional paths to skip — strings (prefix) or regexes (the dashboard's own mount path is auto-ignored) |
78
78
  | `ignore_controllers` | `[]` | Controller names to skip (e.g. `"rails/health"`) |
79
79
  | `detailed_reports` | `false` | Capture full `MemoryProfiler.report` breakdowns; requires `gem "memory_profiler"` in your Gemfile |
80
80
  | `detailed_sample_rate` | `10` | When `detailed_reports` is enabled, capture a full report every Nth profiled request |
@@ -88,7 +88,7 @@ Example:
88
88
  RailsMemoryProfiler.configure do |config|
89
89
  config.sample_rate = 5
90
90
  config.min_allocated_objects = 1_000
91
- config.ignore_paths = ["/rails/memory", "/up"]
91
+ config.ignore_paths = ["/up"] # dashboard mount path is auto-ignored
92
92
  config.ignore_controllers = ["rails/health"]
93
93
  config.notifiers = [RailsMemoryProfiler::Notifiers::Console.new]
94
94
  config.log_file = Rails.root.join("log/memory_profiler.jsonl")
@@ -2,6 +2,30 @@
2
2
  .rmp-header h1 { font-size: 1.4rem; font-weight: 600; }
3
3
  .rmp-header p { color: var(--muted); margin-top: 0.2rem; }
4
4
 
5
+ .rmp-header-row {
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ gap: 1rem;
10
+ }
11
+
12
+ .rmp-btn-danger {
13
+ font-family: inherit;
14
+ font-size: 12px;
15
+ padding: 0.3rem 0.8rem;
16
+ border: 1px solid #dc3545;
17
+ border-radius: var(--radius);
18
+ background: transparent;
19
+ color: #dc3545;
20
+ cursor: pointer;
21
+ white-space: nowrap;
22
+ }
23
+
24
+ .rmp-btn-danger:hover {
25
+ background: #dc3545;
26
+ color: #fff;
27
+ }
28
+
5
29
  .rmp-empty { color: var(--muted); font-style: italic; margin-top: 1rem; }
6
30
  .rmp-summary { margin-bottom: 0.5rem; }
7
31
 
@@ -15,6 +15,11 @@ module RailsMemoryProfiler
15
15
  end
16
16
  end
17
17
 
18
+ def clear
19
+ ReportStore.clear
20
+ redirect_to reports_path
21
+ end
22
+
18
23
  def show
19
24
  @report = ReportStore.find(params[:id])
20
25
 
@@ -1,6 +1,15 @@
1
1
  <div class="rmp-header">
2
- <h1>Memory Profiler</h1>
3
- <p><%= @reports.size %> request<%= "s" unless @reports.size == 1 %> captured</p>
2
+ <div class="rmp-header-row">
3
+ <div>
4
+ <h1>Memory Profiler</h1>
5
+ <p><%= @reports.size %> request<%= "s" unless @reports.size == 1 %> captured</p>
6
+ </div>
7
+ <% unless @reports.empty? %>
8
+ <%= button_to "Clear All", clear_reports_path, method: :delete,
9
+ class: "rmp-btn-danger",
10
+ form: { data: { turbo_confirm: "Clear all reports? This cannot be undone." } } %>
11
+ <% end %>
12
+ </div>
4
13
  </div>
5
14
 
6
15
  <div data-controller="filter compare" data-compare-path-value="<%= comparison_path %>">
data/config/routes.rb CHANGED
@@ -1,4 +1,8 @@
1
1
  RailsMemoryProfiler::Engine.routes.draw do
2
- resources :reports, only: [:index, :show]
3
- resource :comparison, only: [:show]
2
+ resources :reports, only: [:index, :show] do
3
+ collection do
4
+ delete :clear
5
+ end
6
+ end
7
+ resource :comparison, only: [:show]
4
8
  end
@@ -6,6 +6,21 @@ module RailsMemoryProfiler
6
6
  isolate_namespace RailsMemoryProfiler
7
7
  config.generators.api_only = true
8
8
 
9
+ class << self
10
+ def mount_path
11
+ @mount_path ||= begin
12
+ mounted = Rails.application.routes.routes.find do |route|
13
+ route.app.app == self rescue false
14
+ end
15
+ mounted&.path&.spec&.to_s&.gsub(/\([^)]*\)/, "")
16
+ end
17
+ end
18
+
19
+ def reset_mount_path!
20
+ @mount_path = nil
21
+ end
22
+ end
23
+
9
24
  initializer "rails_memory_profiler.assets" do |app|
10
25
  if app.config.respond_to?(:assets)
11
26
  app.config.assets.paths << root.join("app/javascript")
@@ -143,6 +143,9 @@ module RailsMemoryProfiler
143
143
  end
144
144
 
145
145
  def ignored_path?(path)
146
+ mount = RailsMemoryProfiler::Engine.mount_path
147
+ return true if mount && path.start_with?(mount)
148
+
146
149
  RailsMemoryProfiler.config.ignore_paths.any? do |pattern|
147
150
  pattern.is_a?(Regexp) ? pattern.match?(path) : path.start_with?(pattern.to_s)
148
151
  end
@@ -1,3 +1,3 @@
1
1
  module RailsMemoryProfiler
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_memory_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuck Smith