Skip to content

Commit 4ae1dfc

Browse files
Docs: Use rack-mini-profiler for profiling ViewComponent rendering (#1994)
* adding documentation on configuring rack-mini-profiler to use render.view_component notifications * adding htcarr3 to contributors * updating changelog to show rack-mini-profiler documentation changes * fix linting issues for ci * Apply suggestions from code review --------- Co-authored-by: Joel Hawksley <[email protected]>
1 parent 448e431 commit 4ae1dfc

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nav_order: 5
1010

1111
## main
1212

13+
* Document using rack-mini-profiler with ViewComponent.
14+
15+
*Thomas Carr*
16+
1317
* Move dependencies to gemspec.
1418

1519
*Joel Hawksley*

docs/guide/instrumentation.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,21 @@ end
3434
When using `render.view_component` with `config.server_timing = true` (default in development) in Rails 7, the browser developer tools display the sum total timing information in Network > Timing under the key `render.view_component`.
3535

3636
![Browser showing the Server Timing data in the browser dev tools](../images/viewing_instrumentation_sums_in_browser_dev_tools.png "Server Timing data in the browser dev tools")
37+
38+
## Viewing instrumentation breakdowns in rack-mini-profiler
39+
40+
The [rack-mini-profiler gem](https://rubygems.org/gems/rack-mini-profiler) is a popular tool for profiling rack-based Ruby applications.
41+
42+
To profile ViewComponent rendering alongside views and partials:
43+
44+
```ruby
45+
# config/environments/development.rb
46+
# Profile rendering of ViewComponents
47+
Rack::MiniProfilerRails.subscribe("render.view_component") do |_name, start, finish, _id, payload|
48+
Rack::MiniProfilerRails.render_notification_handler(
49+
Rack::MiniProfilerRails.shorten_identifier(payload[:identifier]),
50+
finish,
51+
start
52+
)
53+
end
54+
```

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ ViewComponent is built by over a hundred members of the community, including:
216216
<img src="https://avatars.githubusercontent.com/thomascchen?s=64" alt="thomascchen" width="32" />
217217
<img src="https://avatars.githubusercontent.com/milk1000cc?s=64" alt="milk1000cc" width="32" />
218218
<img src="https://avatars.githubusercontent.com/aduth?s=64" alt="aduth" width="32" />
219+
<img src="https://avatars.githubusercontent.com/htcarr3?s=64" alt="htcarr3" width="32" />
219220

220221
## Who uses ViewComponent?
221222

0 commit comments

Comments
 (0)