rails_pulse 0.1.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.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +638 -0
  4. data/Rakefile +207 -0
  5. data/app/assets/images/rails_pulse/dashboard.png +0 -0
  6. data/app/assets/images/rails_pulse/menu.svg +1 -0
  7. data/app/assets/images/rails_pulse/rails-pulse-logo.png +0 -0
  8. data/app/assets/images/rails_pulse/request.png +0 -0
  9. data/app/assets/images/rails_pulse/routes.png +0 -0
  10. data/app/assets/stylesheets/rails_pulse/application.css +102 -0
  11. data/app/assets/stylesheets/rails_pulse/components/alert.css +24 -0
  12. data/app/assets/stylesheets/rails_pulse/components/badge.css +58 -0
  13. data/app/assets/stylesheets/rails_pulse/components/base.css +79 -0
  14. data/app/assets/stylesheets/rails_pulse/components/breadcrumb.css +31 -0
  15. data/app/assets/stylesheets/rails_pulse/components/button.css +99 -0
  16. data/app/assets/stylesheets/rails_pulse/components/card.css +19 -0
  17. data/app/assets/stylesheets/rails_pulse/components/chart.css +18 -0
  18. data/app/assets/stylesheets/rails_pulse/components/csp_safe_positioning.css +86 -0
  19. data/app/assets/stylesheets/rails_pulse/components/descriptive_list.css +9 -0
  20. data/app/assets/stylesheets/rails_pulse/components/dialog.css +56 -0
  21. data/app/assets/stylesheets/rails_pulse/components/flash.css +47 -0
  22. data/app/assets/stylesheets/rails_pulse/components/input.css +80 -0
  23. data/app/assets/stylesheets/rails_pulse/components/layouts.css +63 -0
  24. data/app/assets/stylesheets/rails_pulse/components/menu.css +43 -0
  25. data/app/assets/stylesheets/rails_pulse/components/popover.css +36 -0
  26. data/app/assets/stylesheets/rails_pulse/components/prose.css +144 -0
  27. data/app/assets/stylesheets/rails_pulse/components/row.css +24 -0
  28. data/app/assets/stylesheets/rails_pulse/components/sidebar_menu.css +79 -0
  29. data/app/assets/stylesheets/rails_pulse/components/skeleton.css +5 -0
  30. data/app/assets/stylesheets/rails_pulse/components/table.css +37 -0
  31. data/app/assets/stylesheets/rails_pulse/components/utilities.css +36 -0
  32. data/app/controllers/concerns/chart_table_concern.rb +82 -0
  33. data/app/controllers/concerns/response_range_concern.rb +24 -0
  34. data/app/controllers/concerns/time_range_concern.rb +67 -0
  35. data/app/controllers/concerns/zoom_range_concern.rb +40 -0
  36. data/app/controllers/rails_pulse/application_controller.rb +67 -0
  37. data/app/controllers/rails_pulse/assets_controller.rb +33 -0
  38. data/app/controllers/rails_pulse/caches_controller.rb +115 -0
  39. data/app/controllers/rails_pulse/csp_test_controller.rb +57 -0
  40. data/app/controllers/rails_pulse/dashboard_controller.rb +6 -0
  41. data/app/controllers/rails_pulse/operations_controller.rb +219 -0
  42. data/app/controllers/rails_pulse/queries_controller.rb +121 -0
  43. data/app/controllers/rails_pulse/requests_controller.rb +69 -0
  44. data/app/controllers/rails_pulse/routes_controller.rb +99 -0
  45. data/app/helpers/rails_pulse/application_helper.rb +111 -0
  46. data/app/helpers/rails_pulse/breadcrumbs_helper.rb +62 -0
  47. data/app/helpers/rails_pulse/cached_component_helper.rb +73 -0
  48. data/app/helpers/rails_pulse/chart_formatters.rb +43 -0
  49. data/app/helpers/rails_pulse/chart_helper.rb +140 -0
  50. data/app/helpers/rails_pulse/formatting_helper.rb +29 -0
  51. data/app/helpers/rails_pulse/status_helper.rb +279 -0
  52. data/app/helpers/rails_pulse/table_helper.rb +54 -0
  53. data/app/javascript/rails_pulse/application.js +119 -0
  54. data/app/javascript/rails_pulse/controllers/color_scheme_controller.js +20 -0
  55. data/app/javascript/rails_pulse/controllers/context_menu_controller.js +16 -0
  56. data/app/javascript/rails_pulse/controllers/dialog_controller.js +21 -0
  57. data/app/javascript/rails_pulse/controllers/expandable_row_controller.js +67 -0
  58. data/app/javascript/rails_pulse/controllers/form_controller.js +39 -0
  59. data/app/javascript/rails_pulse/controllers/icon_controller.js +170 -0
  60. data/app/javascript/rails_pulse/controllers/index_controller.js +230 -0
  61. data/app/javascript/rails_pulse/controllers/menu_controller.js +60 -0
  62. data/app/javascript/rails_pulse/controllers/pagination_controller.js +69 -0
  63. data/app/javascript/rails_pulse/controllers/popover_controller.js +91 -0
  64. data/app/javascript/rails_pulse/controllers/timezone_controller.js +106 -0
  65. data/app/javascript/rails_pulse/theme.js +416 -0
  66. data/app/jobs/rails_pulse/application_job.rb +4 -0
  67. data/app/jobs/rails_pulse/cleanup_job.rb +21 -0
  68. data/app/mailers/rails_pulse/application_mailer.rb +6 -0
  69. data/app/models/rails_pulse/application_record.rb +7 -0
  70. data/app/models/rails_pulse/component_cache_key.rb +33 -0
  71. data/app/models/rails_pulse/dashboard/charts/average_response_time.rb +27 -0
  72. data/app/models/rails_pulse/dashboard/charts/p95_response_time.rb +37 -0
  73. data/app/models/rails_pulse/dashboard/tables/slow_queries.rb +59 -0
  74. data/app/models/rails_pulse/dashboard/tables/slow_routes.rb +45 -0
  75. data/app/models/rails_pulse/operation.rb +87 -0
  76. data/app/models/rails_pulse/queries/cards/average_query_times.rb +52 -0
  77. data/app/models/rails_pulse/queries/cards/execution_rate.rb +57 -0
  78. data/app/models/rails_pulse/queries/cards/percentile_query_times.rb +71 -0
  79. data/app/models/rails_pulse/queries/charts/average_query_times.rb +112 -0
  80. data/app/models/rails_pulse/query.rb +58 -0
  81. data/app/models/rails_pulse/request.rb +64 -0
  82. data/app/models/rails_pulse/requests/charts/average_response_times.rb +99 -0
  83. data/app/models/rails_pulse/requests/charts/operations_chart.rb +35 -0
  84. data/app/models/rails_pulse/route.rb +77 -0
  85. data/app/models/rails_pulse/routes/cards/average_response_times.rb +54 -0
  86. data/app/models/rails_pulse/routes/cards/error_rate_per_route.rb +73 -0
  87. data/app/models/rails_pulse/routes/cards/percentile_response_times.rb +73 -0
  88. data/app/models/rails_pulse/routes/cards/request_count_totals.rb +59 -0
  89. data/app/models/rails_pulse/routes/charts/average_response_times.rb +115 -0
  90. data/app/models/rails_pulse/routes/tables/index.rb +63 -0
  91. data/app/services/rails_pulse/sql_query_normalizer.rb +124 -0
  92. data/app/views/layouts/rails_pulse/_menu_items.html.erb +19 -0
  93. data/app/views/layouts/rails_pulse/_sidebar_menu.html.erb +44 -0
  94. data/app/views/layouts/rails_pulse/application.html.erb +72 -0
  95. data/app/views/rails_pulse/caches/show.html.erb +9 -0
  96. data/app/views/rails_pulse/components/_breadcrumbs.html.erb +12 -0
  97. data/app/views/rails_pulse/components/_code_panel.html.erb +12 -0
  98. data/app/views/rails_pulse/components/_metric_card.html.erb +55 -0
  99. data/app/views/rails_pulse/components/_metric_row.html.erb +9 -0
  100. data/app/views/rails_pulse/components/_operation_details_popover.html.erb +241 -0
  101. data/app/views/rails_pulse/components/_panel.html.erb +56 -0
  102. data/app/views/rails_pulse/components/_sparkline_stats.html.erb +15 -0
  103. data/app/views/rails_pulse/components/_table.html.erb +50 -0
  104. data/app/views/rails_pulse/components/_table_head.html.erb +20 -0
  105. data/app/views/rails_pulse/components/_table_pagination.html.erb +45 -0
  106. data/app/views/rails_pulse/components/_time_period.html.erb +16 -0
  107. data/app/views/rails_pulse/csp_test/show.html.erb +207 -0
  108. data/app/views/rails_pulse/dashboard/charts/_bar_chart.html.erb +1 -0
  109. data/app/views/rails_pulse/dashboard/index.html.erb +64 -0
  110. data/app/views/rails_pulse/dashboard/tables/_routes_table.html.erb +32 -0
  111. data/app/views/rails_pulse/dashboard/tables/_standard_table.html.erb +1 -0
  112. data/app/views/rails_pulse/operations/_operation_analysis_application.html.erb +43 -0
  113. data/app/views/rails_pulse/operations/_operation_analysis_database.html.erb +12 -0
  114. data/app/views/rails_pulse/operations/_operation_analysis_generic.html.erb +15 -0
  115. data/app/views/rails_pulse/operations/_operation_analysis_other.html.erb +69 -0
  116. data/app/views/rails_pulse/operations/_operation_analysis_view.html.erb +39 -0
  117. data/app/views/rails_pulse/operations/show.html.erb +79 -0
  118. data/app/views/rails_pulse/queries/_show_table.html.erb +19 -0
  119. data/app/views/rails_pulse/queries/_table.html.erb +31 -0
  120. data/app/views/rails_pulse/queries/index.html.erb +64 -0
  121. data/app/views/rails_pulse/queries/show.html.erb +86 -0
  122. data/app/views/rails_pulse/requests/_operations.html.erb +85 -0
  123. data/app/views/rails_pulse/requests/_table.html.erb +31 -0
  124. data/app/views/rails_pulse/requests/index.html.erb +64 -0
  125. data/app/views/rails_pulse/requests/show.html.erb +44 -0
  126. data/app/views/rails_pulse/routes/_table.html.erb +29 -0
  127. data/app/views/rails_pulse/routes/index.html.erb +65 -0
  128. data/app/views/rails_pulse/routes/show.html.erb +67 -0
  129. data/app/views/rails_pulse/skeletons/_chart.html.erb +3 -0
  130. data/app/views/rails_pulse/skeletons/_metric_card.html.erb +20 -0
  131. data/app/views/rails_pulse/skeletons/_panel.html.erb +19 -0
  132. data/app/views/rails_pulse/skeletons/_table.html.erb +8 -0
  133. data/config/importmap.rb +12 -0
  134. data/config/initializers/rails_charts_csp_patch.rb +83 -0
  135. data/config/initializers/rails_pulse.rb +198 -0
  136. data/config/routes.rb +16 -0
  137. data/db/migrate/20250227235904_create_routes.rb +12 -0
  138. data/db/migrate/20250227235915_create_requests.rb +19 -0
  139. data/db/migrate/20250228000000_create_queries.rb +14 -0
  140. data/db/migrate/20250228000056_create_operations.rb +24 -0
  141. data/lib/generators/rails_pulse/install_generator.rb +17 -0
  142. data/lib/generators/rails_pulse/templates/rails_pulse.rb +198 -0
  143. data/lib/rails_pulse/cleanup_service.rb +212 -0
  144. data/lib/rails_pulse/configuration.rb +176 -0
  145. data/lib/rails_pulse/engine.rb +88 -0
  146. data/lib/rails_pulse/middleware/asset_server.rb +84 -0
  147. data/lib/rails_pulse/middleware/request_collector.rb +120 -0
  148. data/lib/rails_pulse/migration.rb +29 -0
  149. data/lib/rails_pulse/subscribers/operation_subscriber.rb +280 -0
  150. data/lib/rails_pulse/version.rb +3 -0
  151. data/lib/rails_pulse.rb +38 -0
  152. data/lib/tasks/rails_pulse_tasks.rake +138 -0
  153. data/public/rails-pulse-assets/csp-test.js +110 -0
  154. data/public/rails-pulse-assets/rails-pulse-icons.js +89 -0
  155. data/public/rails-pulse-assets/rails-pulse-icons.js.map +13 -0
  156. data/public/rails-pulse-assets/rails-pulse.css +1 -0
  157. data/public/rails-pulse-assets/rails-pulse.css.map +1 -0
  158. data/public/rails-pulse-assets/rails-pulse.js +183 -0
  159. data/public/rails-pulse-assets/rails-pulse.js.map +7 -0
  160. metadata +339 -0
@@ -0,0 +1,64 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <div class="row">
4
+ <%= cached_component(component: "metric_card", id: "average_response_times", context: "routes", class: "grid-item block") %>
5
+ <%= cached_component(component: "metric_card", id: "percentile_response_times", context: "routes", class: "grid-item block") %>
6
+ <%= cached_component(component: "metric_card", id: "request_count_totals", context: "routes", class: "grid-item block") %>
7
+ <%= cached_component(component: "metric_card", id: "error_rate_per_route", context: "routes", class: "grid-item block") %>
8
+ </div>
9
+
10
+ <div
11
+ class="row"
12
+ data-controller="rails-pulse--index"
13
+ data-rails-pulse--index-chart-id-value="average_query_times_chart"
14
+ >
15
+ <div class="grid-item">
16
+ <%= render 'rails_pulse/components/panel', { title: 'Average Query Time', } do %>
17
+ <%= search_form_for @ransack_query, url: queries_path, class: "flex items-center justify-between gap mb-4" do |form| %>
18
+ <div class="flex items-center grow gap">
19
+ <%= form.select :occurred_at_range,
20
+ RailsPulse::QueriesController::TIME_RANGE_OPTIONS,
21
+ { selected: @selected_time_range },
22
+ { class: "input" }
23
+ %>
24
+ <%= form.select :duration,
25
+ duration_options(:query),
26
+ { selected: @selected_response_range },
27
+ { class: "input" }
28
+ %>
29
+ <%= link_to "Reset", queries_path, class: "btn btn--borderless show@md" if params.has_key?(:q) %>
30
+ <%= form.submit "Search", class: "btn show@sm" %>
31
+ </div>
32
+ <% end %>
33
+
34
+ <% if @chart_data.present? %>
35
+ <div
36
+ class="chart-container chart-container--slim"
37
+ data-rails-pulse--index-target="chart"
38
+ >
39
+ <%= bar_chart(
40
+ @chart_data,
41
+ code: false,
42
+ id: "average_query_times_chart",
43
+ height: "100%",
44
+ options: bar_chart_options(
45
+ units: "ms",
46
+ zoom: true,
47
+ chart_start: 0,
48
+ chart_end: @chart_data.length - 1,
49
+ xaxis_formatter: @xaxis_formatter,
50
+ tooltip_formatter: @tooltip_formatter,
51
+ zoom_start: @zoom_start,
52
+ zoom_end: @zoom_end,
53
+ chart_data: @chart_data
54
+ )
55
+ ) %>
56
+ </div>
57
+ <% end %>
58
+
59
+ <%= turbo_frame_tag :queries_index_table, data: { rails_pulse__index_target: "indexTable" } do %>
60
+ <%= render 'rails_pulse/queries/table' %>
61
+ <% end %>
62
+ <% end %>
63
+ </div>
64
+ </div>
@@ -0,0 +1,86 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <div class="row">
4
+ <%= cached_component(component: "metric_card", id: "average_query_times", context: "query_#{@query.id}", class: "grid-item block") %>
5
+ <%= cached_component(component: "metric_card", id: "request_count_totals", context: "query_#{@query.id}", class: "grid-item block") %>
6
+ <%= cached_component(component: "metric_card", id: "execution_rate", context: "query_#{@query.id}", class: "grid-item block") %>
7
+ </div>
8
+
9
+ <div class="mb-4">
10
+ <%= render 'rails_pulse/components/code_panel', { title: 'Normalized SQL', value: @query.normalized_sql } %>
11
+ </div>
12
+
13
+ <div
14
+ class="row"
15
+ data-controller="rails-pulse--index"
16
+ data-rails-pulse--index-chart-id-value="query_responses_chart"
17
+ data-rails-pulse--index-occurred-at-param-value="occurred_at"
18
+ >
19
+ <div class="grid-item">
20
+ <%= render 'rails_pulse/components/panel', { title: 'Query Responses' } do %>
21
+ <%= search_form_for @ransack_query, url: query_path(@query), class: "flex items-center justify-between gap mb-4" do |form| %>
22
+ <div class="flex items-center grow gap">
23
+ <%= form.select :occurred_at_range,
24
+ RailsPulse::RoutesController::TIME_RANGE_OPTIONS,
25
+ { selected: @selected_time_range },
26
+ { class: "input" }
27
+ %>
28
+ <%= form.select :duration,
29
+ duration_options(:query),
30
+ { selected: @selected_response_range },
31
+ { class: "input" }
32
+ %>
33
+ <%= link_to "Reset", query_path(@query), class: "btn btn--borderless show@md" if params.has_key?(:q) %>
34
+ <%= form.submit "Search", class: "btn show@sm" %>
35
+ </div>
36
+ <% end %>
37
+
38
+ <% if @chart_data.present? %>
39
+ <div
40
+ class="chart-container chart-container--slim"
41
+ data-rails-pulse--index-target="chart"
42
+ >
43
+ <%= bar_chart(
44
+ @chart_data,
45
+ code: false,
46
+ id: "query_responses_chart",
47
+ height: "100%",
48
+ options: bar_chart_options(
49
+ units: "ms",
50
+ zoom: true,
51
+ chart_start: 0,
52
+ chart_end: @chart_data.length - 1,
53
+ xaxis_formatter: @xaxis_formatter,
54
+ tooltip_formatter: @tooltip_formatter
55
+ )
56
+ ) %>
57
+ </div>
58
+ <% end %>
59
+
60
+ <%= turbo_frame_tag :index_table do %>
61
+ <%= render 'rails_pulse/queries/show_table' %>
62
+ <% end %>
63
+ <% end %>
64
+ </div>
65
+ </div>
66
+
67
+ <%= render 'rails_pulse/components/panel', { title: 'Query Locations' } do %>
68
+ <table class="table">
69
+ <thead>
70
+ <tr>
71
+ <th>Location</th>
72
+ <th>Average Query Time</th>
73
+ <th>Count</th>
74
+ </tr>
75
+ </thead>
76
+ <tbody>
77
+ <% @query.operations.group_by(&:codebase_location).each do |codebase_location, operations| %>
78
+ <tr>
79
+ <td><%= link_to codebase_location, '#' %></td>
80
+ <td><%= (operations.sum(&:duration) / operations.count).round(2) %></td>
81
+ <td><%= operations.count %></td>
82
+ </tr>
83
+ <% end %>
84
+ </tbody>
85
+ </table>
86
+ <% end %>
@@ -0,0 +1,85 @@
1
+ <div class="row">
2
+ <div class="grid-item">
3
+ <%= render 'rails_pulse/components/panel', { title: 'Event Sequence ' } do %>
4
+ <table class="table operations-table">
5
+ <thead>
6
+ <tr>
7
+ <th class="w-8"></th>
8
+ <th class="operations-label-cell">Operation</th>
9
+ <th class="operations-duration-cell">Duration</th>
10
+ <th class="w-20">Impact</th>
11
+ <th class="w-16"></th>
12
+ <th class="operations-event-cell">Timeline</th>
13
+ <th class="w-16">Actions</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% total_request_duration = @request.duration.to_f %>
18
+ <% @operation_timeline.bars.each_with_index do |bar, index| %>
19
+ <tbody data-controller="rails-pulse--expandable-row">
20
+ <!-- Main operation row -->
21
+ <tr
22
+ class="<%= cycle('bg-shade', 'bg-white') %> operation-row"
23
+ data-rails-pulse--expandable-row-target="trigger"
24
+ data-operation-id="<%= bar.operation.id %>"
25
+ >
26
+ <!-- Toggle chevron column -->
27
+ <td class="text-center cursor-pointer"
28
+ data-action="click->rails-pulse--expandable-row#toggle">
29
+ <div data-rails-pulse--expandable-row-target="chevron">
30
+ <%= rails_pulse_icon('chevron-right', width: '16', class: 'transition-transform duration-200') %>
31
+ </div>
32
+ </td>
33
+
34
+ <td class="operations-label-cell">
35
+ <span class="text-link" style="color: <%= event_color(bar.operation.operation_type) %>;">
36
+ <%= html_escape(bar.operation.label) %>
37
+ </span>
38
+ </td>
39
+
40
+ <td class="whitespace-nowrap">
41
+ <%= bar.duration.round(2) %> ms
42
+ </td>
43
+
44
+ <td class="whitespace-nowrap">
45
+ <% impact_percentage = total_request_duration > 0 ? (bar.operation.duration / total_request_duration * 100).round(1) : 0 %>
46
+ <%= impact_percentage %>%
47
+ </td>
48
+
49
+ <td class="whitespace-nowrap text-center">
50
+ <%= operation_status_indicator(bar.operation) %>
51
+ </td>
52
+
53
+ <td class="operations-event-cell">
54
+ <div
55
+ class="operations-event"
56
+ style="left: <%= bar.left_pct %>%; width: <%= bar.width_pct %>%; background-color: <%= event_color(bar.operation.operation_type) %>;">
57
+ </div>
58
+ </td>
59
+
60
+ <td>
61
+ <%= link_to rails_pulse_icon('eye', width: '16', class: 'inline-block mbi-2'), operation_path(bar.operation), title: 'View details', data: { turbo_frame: "_top" } %>
62
+ <% if bar.operation.operation_type == "sql" && bar.operation.query.present? %>
63
+ <%= link_to rails_pulse_icon('database', width: '16', class: 'inline-block'), query_path(bar.operation.query), title: 'View query', data: { turbo_frame: "_top" } %>
64
+ <% end %>
65
+ </td>
66
+ </tr>
67
+
68
+ <!-- Expandable details row -->
69
+ <tr
70
+ class="operation-details-row hidden"
71
+ data-rails-pulse--expandable-row-target="details"
72
+ data-operation-id="<%= bar.operation.id %>"
73
+ >
74
+ <td colspan="7" class="p-4">
75
+ <%= turbo_frame_tag "operation_#{bar.operation.id}_details", data: { "operation-url": operation_path(bar.operation) } do %>
76
+ <% end %>
77
+ </td>
78
+ </tr>
79
+ </tbody>
80
+ <% end %>
81
+ </tbody>
82
+ </table>
83
+ <% end %>
84
+ </div>
85
+ </div>
@@ -0,0 +1,31 @@
1
+ <%
2
+ columns = []
3
+ columns << { field: :route_path, label: 'Route', class: 'w-auto' } if @route.blank?
4
+
5
+ columns += [
6
+ { field: :occurred_at, label: 'Timestamp', class: (@route.present? ? 'w-auto' : 'w-40') },
7
+ { field: :duration, label: 'Duration', class: 'w-24' },
8
+ { field: :status, label: 'HTTP Status', class: 'w-20' },
9
+ { field: :status_indicator, label: 'Status', class: 'w-16' }
10
+ ]
11
+ %>
12
+
13
+ <table class="table mbs-4">
14
+ <%= render "rails_pulse/components/table_head", columns: columns %>
15
+
16
+ <tbody>
17
+ <% @table_data.each do |route_request| %>
18
+ <tr>
19
+ <% if @route.blank? %>
20
+ <td class="whitespace-nowrap"><%= link_to route_request.route.path_and_method, request_path(route_request), data: { turbo_frame: '_top' } %></td>
21
+ <% end %>
22
+ <td class="whitespace-nowrap"><%= link_to human_readable_occurred_at(route_request.occurred_at), request_path(route_request), data: { turbo_frame: '_top' } %></td>
23
+ <td class="whitespace-nowrap"><%= route_request.duration.round(2) %> ms</td>
24
+ <td class="whitespace-nowrap"><%= route_request.status %></td>
25
+ <td class="whitespace-nowrap text-center"><%= request_status_indicator(route_request.duration) %></td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
30
+
31
+ <%= render "rails_pulse/components/table_pagination" %>
@@ -0,0 +1,64 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <div class="row">
4
+ <%= cached_component(component: "metric_card", id: "average_response_times", context: "requests", class: "grid-item block") %>
5
+ <%= cached_component(component: "metric_card", id: "percentile_response_times", context: "requests", class: "grid-item block") %>
6
+ <%= cached_component(component: "metric_card", id: "request_count_totals", context: "requests", class: "grid-item block") %>
7
+ <%= cached_component(component: "metric_card", id: "error_rate_per_route", context: "requests", class: "grid-item block") %>
8
+ </div>
9
+
10
+ <div
11
+ class="row"
12
+ data-controller="rails-pulse--index"
13
+ data-rails-pulse--index-chart-id-value="average_response_times_chart"
14
+ >
15
+ <div class="grid-item">
16
+ <%= render 'rails_pulse/components/panel', { title: 'Average Response Time', } do %>
17
+ <%= search_form_for @ransack_query, url: requests_path, class: "flex items-center justify-between gap mb-4" do |form| %>
18
+ <div class="flex items-center grow gap">
19
+ <%= form.select :occurred_at_range,
20
+ RailsPulse::RequestsController::TIME_RANGE_OPTIONS,
21
+ { selected: @selected_time_range },
22
+ { class: "input" }
23
+ %>
24
+ <%= form.select :duration,
25
+ duration_options(:request),
26
+ { selected: @selected_response_range },
27
+ { class: "input" }
28
+ %>
29
+ <%= link_to "Reset", requests_path, class: "btn btn--borderless show@md" if params.has_key?(:q) %>
30
+ <%= form.submit "Search", class: "btn show@sm" %>
31
+ </div>
32
+ <% end %>
33
+
34
+ <% if @chart_data.present? %>
35
+ <div
36
+ class="chart-container chart-container--slim"
37
+ data-rails-pulse--index-target="chart"
38
+ >
39
+ <%= bar_chart(
40
+ @chart_data,
41
+ code: false,
42
+ id: "average_response_times_chart",
43
+ height: "100%",
44
+ options: bar_chart_options(
45
+ units: "ms",
46
+ zoom: true,
47
+ chart_start: 0,
48
+ chart_end: @chart_data.length - 1,
49
+ xaxis_formatter: @xaxis_formatter,
50
+ tooltip_formatter: @tooltip_formatter,
51
+ zoom_start: @zoom_start,
52
+ zoom_end: @zoom_end,
53
+ chart_data: @chart_data
54
+ )
55
+ ) %>
56
+ </div>
57
+ <% end %>
58
+
59
+ <%= turbo_frame_tag :requests_index_table, data: { rails_pulse__index_target: "indexTable" } do %>
60
+ <%= render 'rails_pulse/requests/table' %>
61
+ <% end %>
62
+ <% end %>
63
+ </div>
64
+ </div>
@@ -0,0 +1,44 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <div class="row">
4
+ <div class="grid-item">
5
+ <%= render 'rails_pulse/components/panel', title: 'Request Details' do %>
6
+ <dl class="descriptive-list mbs-4">
7
+ <dt>Route</dt>
8
+ <dd><%= link_to @request.route.path_and_method, route_path(@request.route) %></dd>
9
+ <dt>Timestamp</dt>
10
+ <dd><%= human_readable_occurred_at(@request.occurred_at) %></dd>
11
+ <dt>Request UUID</dt>
12
+ <dd><code><%= @request.request_uuid %></code></dd>
13
+ <dt>Duration</dt>
14
+ <dd><%= @request.duration.round(2) %> ms</dd>
15
+ <dt>Status</dt>
16
+ <dd><%= @request.status %></dd>
17
+ <dt>Error</dt>
18
+ <dd><%= @request.is_error? ? 'Yes' : 'No' %></dd>
19
+ </dl>
20
+ <% end %>
21
+ </div>
22
+
23
+ <div class="grid-item">
24
+ <%= render 'rails_pulse/components/panel', title: 'Performance Breakdown' do %>
25
+ <% breakdown = operations_performance_breakdown(@request.operations) %>
26
+ <dl class="descriptive-list mbs-4">
27
+ <dt>Database</dt>
28
+ <dd><%= breakdown[:database] %>% (<%= pluralize(@request.operations.by_type('sql').count, 'query') %>)</dd>
29
+ <dt>View Rendering</dt>
30
+ <dd><%= breakdown[:view] %>%</dd>
31
+ <dt>Application Logic</dt>
32
+ <dd><%= breakdown[:application] %>%</dd>
33
+ <dt>Other Operations</dt>
34
+ <dd><%= breakdown[:other] %>%</dd>
35
+ <dt>Total Operations</dt>
36
+ <dd><%= @request.operations.count %></dd>
37
+ <dt>Slowest Operation</dt>
38
+ <dd><%= @request.operations.maximum(:duration)&.round(2) %> ms</dd>
39
+ </dl>
40
+ <% end %>
41
+ </div>
42
+ </div>
43
+
44
+ <%= render 'operations', operations: @request.operations %>
@@ -0,0 +1,29 @@
1
+ <% columns = [
2
+ { field: :path, label: 'Route', class: 'w-auto' },
3
+ { field: :average_response_time_ms, label: 'Average Response Time', class: 'w-36' },
4
+ { field: :max_response_time_ms, label: 'Max Response Time', class: 'w-32' },
5
+ { field: :request_count, label: 'Requests', class: 'w-24' },
6
+ { field: :requests_per_minute, label: 'Requests Per Minute', class: 'w-28' },
7
+ { field: :error_rate_percentage, label: 'Error Rate (%)', class: 'w-20' },
8
+ { field: :status_indicator, label: 'Status', class: 'w-16' }
9
+ ] %>
10
+
11
+ <table class="table mbs-4">
12
+ <%= render "rails_pulse/components/table_head", columns: columns %>
13
+
14
+ <tbody>
15
+ <% @table_data.each do |route| %>
16
+ <tr>
17
+ <td class="whitespace-nowrap"><%= link_to route.path_and_method, route, data: { turbo_frame: '_top' } %></td>
18
+ <td class="whitespace-nowrap"><%= route.average_response_time_ms.to_i %> ms</td>
19
+ <td class="whitespace-nowrap"><%= route.max_response_time_ms.to_i %> ms</td>
20
+ <td class="whitespace-nowrap"><%= number_with_delimiter route.request_count %></td>
21
+ <td class="whitespace-nowrap"><%= route.requests_per_minute < 1 ? '< 1' : route.requests_per_minute.round(2) %></td>
22
+ <td class="whitespace-nowrap"><%= route.error_rate_percentage %>%</td>
23
+ <td class="whitespace-nowrap text-center"><%= route_status_indicator(route.status_indicator) %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <%= render "rails_pulse/components/table_pagination" %>
@@ -0,0 +1,65 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <div class="row">
4
+ <%= cached_component(component: "metric_card", id: "average_response_times", context: "routes", class: "grid-item block") %>
5
+ <%= cached_component(component: "metric_card", id: "percentile_response_times", context: "routes", class: "grid-item block") %>
6
+ <%= cached_component(component: "metric_card", id: "request_count_totals", context: "routes", class: "grid-item block") %>
7
+ <%= cached_component(component: "metric_card", id: "error_rate_per_route", context: "routes", class: "grid-item block") %>
8
+ </div>
9
+
10
+ <div
11
+ class="row"
12
+ data-controller="rails-pulse--index"
13
+ data-rails-pulse--index-chart-id-value="average_response_times_chart"
14
+ >
15
+ <div class="grid-item">
16
+ <%= render 'rails_pulse/components/panel', { title: 'Average Response Time', } do %>
17
+ <%= search_form_for @ransack_query, url: routes_path, class: "flex items-center justify-between gap mb-4" do |form| %>
18
+ <div class="flex items-center grow gap">
19
+ <%= form.search_field :path_cont, placeholder: "Filter by route", autocomplete: "off", class: "input", style: "max-inline-size: 250px" %>
20
+ <%= form.select :occurred_at_range,
21
+ RailsPulse::RoutesController::TIME_RANGE_OPTIONS,
22
+ { selected: @selected_time_range },
23
+ { class: "input" }
24
+ %>
25
+ <%= form.select :duration,
26
+ duration_options(:route),
27
+ { selected: @selected_response_range },
28
+ { class: "input" }
29
+ %>
30
+ <%= link_to "Reset", routes_path, class: "btn btn--borderless show@md" if params.has_key?(:q) %>
31
+ <%= form.submit "Search", class: "btn show@sm" %>
32
+ </div>
33
+ <% end %>
34
+
35
+ <% if @chart_data.present? %>
36
+ <div
37
+ class="chart-container chart-container--slim"
38
+ data-rails-pulse--index-target="chart"
39
+ >
40
+ <%= bar_chart(
41
+ @chart_data,
42
+ code: false,
43
+ id: "average_response_times_chart",
44
+ height: "100%",
45
+ options: bar_chart_options(
46
+ units: "ms",
47
+ zoom: true,
48
+ chart_start: 0,
49
+ chart_end: @chart_data.length - 1,
50
+ xaxis_formatter: @xaxis_formatter,
51
+ tooltip_formatter: @tooltip_formatter,
52
+ zoom_start: @zoom_start,
53
+ zoom_end: @zoom_end,
54
+ chart_data: @chart_data
55
+ )
56
+ ) %>
57
+ </div>
58
+ <% end %>
59
+
60
+ <%= turbo_frame_tag :routes_index_table, data: { rails_pulse__index_target: "indexTable" } do %>
61
+ <%= render 'rails_pulse/routes/table' %>
62
+ <% end %>
63
+ <% end %>
64
+ </div>
65
+ </div>
@@ -0,0 +1,67 @@
1
+ <%= render 'rails_pulse/components/breadcrumbs' %>
2
+
3
+ <h1 class="text-2xl mbe-2"><%= @route.path_and_method %></h1>
4
+
5
+ <div class="row">
6
+ <%= cached_component(component: "metric_card", id: "average_response_times", context: "routes_#{@route.id}", class: "grid-item block") %>
7
+ <%= cached_component(component: "metric_card", id: "percentile_response_times", context: "routes_#{@route.id}", class: "grid-item block") %>
8
+ <%= cached_component(component: "metric_card", id: "request_count_totals", context: "routes_#{@route.id}", class: "grid-item block") %>
9
+ <%= cached_component(component: "metric_card", id: "error_rate_per_route", context: "routes_#{@route.id}", class: "grid-item block") %>
10
+ </div>
11
+
12
+ <div
13
+ class="row"
14
+ data-controller="rails-pulse--index"
15
+ data-rails-pulse--index-chart-id-value="route_repsonses_chart"
16
+ data-rails-pulse--index-occurred-at-param-value="occurred_at"
17
+ >
18
+ <div class="grid-item">
19
+ <%= render 'rails_pulse/components/panel', { title: 'Route Reqeusts', } do %>
20
+ <%= search_form_for @ransack_query, url: route_path(@route), class: "flex items-center justify-between gap mb-4" do |form| %>
21
+ <div class="flex items-center grow gap">
22
+ <%= form.select :occurred_at_range,
23
+ RailsPulse::RoutesController::TIME_RANGE_OPTIONS,
24
+ { selected: @selected_time_range },
25
+ { class: "input" }
26
+ %>
27
+ <%= form.select :duration,
28
+ duration_options(:route),
29
+ { selected: @selected_response_range },
30
+ { class: "input" }
31
+ %>
32
+ <%= link_to "Reset", route_path(@route), class: "btn btn--borderless show@md" if params.has_key?(:q) %>
33
+ <%= form.submit "Search", class: "btn show@sm" %>
34
+ </div>
35
+ <% end %>
36
+
37
+ <% if @chart_data.present? %>
38
+ <div
39
+ class="chart-container chart-container--slim"
40
+ data-rails-pulse--index-target="chart"
41
+ >
42
+ <%= bar_chart(
43
+ @chart_data,
44
+ code: false,
45
+ id: "route_repsonses_chart",
46
+ height: "100%",
47
+ options: bar_chart_options(
48
+ units: "ms",
49
+ zoom: true,
50
+ chart_start: 0,
51
+ chart_end: @chart_data.length - 1,
52
+ xaxis_formatter: @xaxis_formatter,
53
+ tooltip_formatter: @tooltip_formatter,
54
+ zoom_start: @zoom_start,
55
+ zoom_end: @zoom_end,
56
+ chart_data: @chart_data
57
+ )
58
+ ) %>
59
+ </div>
60
+ <% end %>
61
+
62
+ <%= turbo_frame_tag :index_table do %>
63
+ <%= render 'rails_pulse/requests/table' %>
64
+ <% end %>
65
+ <% end %>
66
+ </div>
67
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="skeleton-container">
2
+ <div class="skeleton-chart" style="height: 300px; background: #f5f5f5; border-radius: 4px;"></div>
3
+ </div>
@@ -0,0 +1,20 @@
1
+ <div class="grid-item">
2
+ <div class="card card-compact">
3
+ <div class="flex flex-col">
4
+ <!-- Skeleton for the card title -->
5
+ <div class="flex">
6
+ <h2 class="grow font-semibold leading-none mbe-1 uppercase text-xs skeleton" style="height: 12px; width: 60%;"></h2>
7
+ </div>
8
+ <!-- Skeleton for the main metric value -->
9
+ <div class="row mbs-2" style="height: 50px; margin-bottom: 0;">
10
+ <div class="grid-item">
11
+ <h4 class="text-xl mbs-1 font-bold skeleton" style="height: 24px; width: 80%;"></h4>
12
+ </div>
13
+ </div>
14
+ <!-- Skeleton for the trend badge -->
15
+ <div class="mbs-2" style="height: 10px;">
16
+ <span class="skeleton rounded-full" style="height: 20px; width: 120px; display: inline-block;"></span>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
@@ -0,0 +1,19 @@
1
+ <div class="card">
2
+ <div class="flex flex-col">
3
+ <div class="flex">
4
+ <!-- Skeleton title -->
5
+ <h2 class="grow font-semibold leading-none mie-4 uppercase text-xs skeleton" style="height: 20px; width: 40%;"></h2>
6
+
7
+ <div class="flex gap items-center">
8
+ <!-- Skeleton links -->
9
+ <div class="skeleton" style="height: 20px; width: 20px; border-radius: 4px;"></div>
10
+ <div class="skeleton" style="height: 20px; width: 20px; border-radius: 4px;"></div>
11
+ </div>
12
+ </div>
13
+
14
+ <!-- Skeleton content -->
15
+ <div class="mbs-2">
16
+ <div class="skeleton" style="height: 200px; width: 100%; border-radius: 4px;"></div>
17
+ </div>
18
+ </div>
19
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="skeleton-container">
2
+ <div class="skeleton-header"></div>
3
+ <div class="skeleton-table">
4
+ <div class="skeleton-row"></div>
5
+ <div class="skeleton-row"></div>
6
+ <div class="skeleton-row"></div>
7
+ </div>
8
+ </div>
@@ -0,0 +1,12 @@
1
+ pin "application", to: "rails_pulse/application.js"
2
+
3
+ # echarts is a dependency of the rails_charts gem
4
+ pin "echarts", to: "echarts.min.js"
5
+ # pin "echarts/theme/inspired", to: "echarts/theme/inspired.js"
6
+ pin "rails_pulse/theme", to: "rails_pulse/theme.js"
7
+
8
+ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
9
+
10
+ # pin "@hotwired/stimulus", to: "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
11
+ pin "@hotwired/stimulus", to: "https://cdn.jsdelivr.net/npm/@hotwired/stimulus@3.2.2/dist/stimulus.js"
12
+ pin_all_from File.expand_path("../app/javascript/rails_pulse", __dir__), under: "rails_pulse"