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 +4 -4
- data/README.md +2 -2
- data/app/assets/stylesheets/rails_memory_profiler/_02_layout.css +24 -0
- data/app/controllers/rails_memory_profiler/reports_controller.rb +5 -0
- data/app/views/rails_memory_profiler/reports/index.html.erb +11 -2
- data/config/routes.rb +6 -2
- data/lib/rails_memory_profiler/engine.rb +15 -0
- data/lib/rails_memory_profiler/middleware.rb +3 -0
- data/lib/rails_memory_profiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ecc5cf3944827bacd93b4ba2609cf46516c1a2ecf54ff922e1b36d36e7e1592
|
|
4
|
+
data.tar.gz: 50de3643fab494e8d03a494d4c776914c234469844b095deb0964efbf94036ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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` | `[]` |
|
|
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 = ["/
|
|
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
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
<div class="rmp-header">
|
|
2
|
-
<
|
|
3
|
-
|
|
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
|
@@ -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
|