simple_apm 1.1.0 → 1.1.2

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.
@@ -1,52 +1,66 @@
1
+ <nav class="apm-breadcrumb" aria-label="<%= t('simple_apm.show.title') %>">
2
+ <%= link_to t('simple_apm.common.back_requests'), index_path(apm_date: apm_date) %>
3
+ <span aria-hidden="true">/</span>
4
+ <%= link_to @request.action_name, action_info_path(action_name: @request.action_name, apm_date: apm_date) %>
5
+ </nav>
1
6
  <div class="apm-page-header">
2
7
  <div>
3
- <h1 class="apm-page-title">请求详情</h1>
4
- <p class="apm-page-subtitle"><%= @request.action_name %>.<%= @request.format %>(<%= @request.method %>)</p>
8
+ <h1 class="apm-page-title"><%= t("simple_apm.show.title") %></h1>
9
+ <p class="apm-page-subtitle apm-mono"><%= @request.action_name %> · <%= @request.method %> · <%= @request.format %></p>
5
10
  </div>
11
+ <span class="apm-status <%= @request.status.to_i >= 400 ? 'apm-status-danger' : 'apm-status-neutral' %>"><%= t('simple_apm.common.status') %>: <%= @request.status.presence || t('simple_apm.common.unknown') %></span>
6
12
  </div>
7
13
 
8
14
  <div class="apm-metrics">
9
15
  <div class="apm-stat">
10
- <p class="apm-stat-label">Total</p>
16
+ <p class="apm-stat-label"><%= t("simple_apm.common.total") %></p>
11
17
  <div class="apm-stat-value"><%= sec_str @request.during %></div>
12
18
  </div>
13
19
  <div class="apm-stat">
14
- <p class="apm-stat-label">DB</p>
20
+ <p class="apm-stat-label"><%= t("simple_apm.common.db") %></p>
15
21
  <div class="apm-stat-value"><%= sec_str @request.db_runtime %></div>
16
22
  </div>
17
23
  <div class="apm-stat">
18
- <p class="apm-stat-label">SQL</p>
24
+ <p class="apm-stat-label"><%= t("simple_apm.common.sql") %></p>
19
25
  <div class="apm-stat-value"><%= @request.queries_count.to_i %></div>
20
- <div class="apm-stat-meta">缓存 <%= @request.cached_queries_count.to_i %></div>
26
+ <div class="apm-stat-meta"><%= t("simple_apm.show.cached") %> <%= @request.cached_queries_count.to_i %></div>
21
27
  </div>
22
28
  <div class="apm-stat">
23
- <p class="apm-stat-label">View</p>
29
+ <p class="apm-stat-label"><%= t("simple_apm.common.view") %></p>
24
30
  <div class="apm-stat-value"><%= sec_str @request.view_runtime %></div>
25
31
  </div>
26
32
  <div class="apm-stat">
27
- <p class="apm-stat-label">HTTP</p>
33
+ <p class="apm-stat-label"><%= t("simple_apm.common.http") %></p>
28
34
  <div class="apm-stat-value"><%= sec_str @request.net_http_during %></div>
29
35
  </div>
30
36
  </div>
31
37
 
38
+ <%= render 'diagnostic_export', report: SimpleApm::DiagnosticReport.for_request(@request, date: apm_date) %>
39
+
40
+ <%= render 'timings', total: @request.during, parts: [[t('simple_apm.common.db'), @request.db_runtime], [t('simple_apm.common.view'), @request.view_runtime], [t('simple_apm.common.http'), @request.net_http_during]] %>
41
+
32
42
  <section class="apm-panel">
33
43
  <div class="apm-panel-header">
34
44
  <div>
35
- <h2 class="apm-panel-title">基础信息</h2>
36
- <p class="apm-panel-subtitle">请求来源、时间和内存变化。</p>
45
+ <h2 class="apm-panel-title"><%= t("simple_apm.show.basic_info") %></h2>
46
+ <p class="apm-panel-subtitle"><%= t("simple_apm.show.basic_info_subtitle") %></p>
37
47
  </div>
38
48
  </div>
39
49
  <div class="apm-panel-body">
40
50
  <dl class="apm-detail-list">
41
- <dt>URL</dt>
42
- <dd><%= @request.url %></dd>
43
- <dt>开始时间</dt>
51
+ <dt><%= t('simple_apm.show.request_id') %></dt>
52
+ <dd><span id="request-id" class="apm-mono"><%= @request.request_id %></span></dd>
53
+ <dt><%= t('simple_apm.show.format_method') %></dt>
54
+ <dd><%= @request.method.presence || t('simple_apm.common.unknown') %> / <%= @request.format %></dd>
55
+ <dt><%= t("simple_apm.common.url") %></dt>
56
+ <dd class="apm-mono"><%= @request.url %></dd>
57
+ <dt><%= t("simple_apm.show.started_at") %></dt>
44
58
  <dd><%= time_label @request.started, true %></dd>
45
- <dt>结束时内存</dt>
46
- <dd><%= @request.completed_memory.to_f.round(1) %>M (增幅:<%= @request.memory_during.to_f.round(1) %>M)</dd>
47
- <dt>server</dt>
59
+ <dt><%= t("simple_apm.show.completed_memory") %></dt>
60
+ <dd><%= @request.completed_memory.to_f.round(1) %> MB (<%= t("simple_apm.show.memory_increase") %>: <%= @request.memory_during.to_f.round(1) %> MB)</dd>
61
+ <dt><%= t("simple_apm.common.server") %></dt>
48
62
  <dd><%= @request.host %></dd>
49
- <dt>访问ip</dt>
63
+ <dt><%= t("simple_apm.show.ip") %></dt>
50
64
  <dd><%= @request.remote_addr %></dd>
51
65
  </dl>
52
66
  </div>
@@ -56,7 +70,7 @@
56
70
  <section class="apm-panel">
57
71
  <div class="apm-panel-header">
58
72
  <div>
59
- <h2 class="apm-panel-title">报错信息</h2>
73
+ <h2 class="apm-panel-title"><%= t("simple_apm.show.exception") %></h2>
60
74
  </div>
61
75
  </div>
62
76
  <div class="apm-panel-body">
@@ -65,55 +79,64 @@
65
79
  </section>
66
80
  <% end %>
67
81
 
68
- <% if @request.net_http_requests.present? %>
69
82
  <section class="apm-panel">
70
83
  <div class="apm-panel-header">
71
84
  <div>
72
- <h2 class="apm-panel-title">外部请求</h2>
73
- <p class="apm-panel-subtitle">请求过程中触发的 Net::HTTP 调用。</p>
85
+ <h2 class="apm-panel-title"><%= t("simple_apm.show.external_requests") %></h2>
86
+ <p class="apm-panel-subtitle"><%= t("simple_apm.show.external_requests_subtitle") %></p>
74
87
  </div>
75
88
  </div>
76
89
  <div class="apm-panel-body">
90
+ <% if @request.net_http_requests.empty? %>
91
+ <p class="apm-stat-hint"><%= t('simple_apm.show.no_http') %></p>
92
+ <% else %>
77
93
  <div class="apm-table-wrap">
78
94
  <table class="table table-bordered">
95
+ <thead>
79
96
  <tr>
80
- <th>开始时间</th>
81
- <th>耗时</th>
82
- <th>URL</th>
83
- <th>其他信息</th>
97
+ <th><%= t("simple_apm.show.started_at") %></th>
98
+ <th><%= t("simple_apm.show.duration") %></th>
99
+ <th><%= t("simple_apm.common.url") %></th>
100
+ <th><%= t("simple_apm.show.other_info") %></th>
84
101
  </tr>
102
+ </thead>
103
+ <tbody>
85
104
  <% @request.net_http_requests.each do |r| %>
86
105
  <tr>
87
106
  <td><%= time_label r.started %></td>
88
107
  <td><%= sec_str r.during %></td>
89
- <td><%= r.url %></td>
90
- <td><%= "#{r.filename}: #{r.line}" if r.filename.present? %></td>
108
+ <td class="apm-mono"><%= r.url %></td>
109
+ <td class="apm-mono"><%= "#{r.filename}: #{r.line}" if r.filename.present? %></td>
91
110
  </tr>
92
111
  <% end %>
112
+ </tbody>
93
113
  </table>
94
114
  </div>
115
+ <% end %>
95
116
  </div>
96
117
  </section>
97
- <% end %>
98
118
 
99
- <% if @request.sqls.present? %>
100
119
  <section class="apm-panel">
101
120
  <div class="apm-panel-header">
102
121
  <div>
103
- <h2 class="apm-panel-title">SQL 列表</h2>
104
- <p class="apm-panel-subtitle">点击 SQL 文本查看完整语句。</p>
122
+ <h2 class="apm-panel-title"><%= t("simple_apm.show.sql_list") %></h2>
123
+ <p class="apm-panel-subtitle"><%= t("simple_apm.show.sql_list_subtitle") %></p>
105
124
  </div>
106
125
  </div>
107
126
  <div class="apm-panel-body">
127
+ <% if @request.sqls.empty? %>
128
+ <p class="apm-stat-hint"><%= t('simple_apm.show.no_sql') %></p>
129
+ <% else %>
108
130
  <div class="apm-table-wrap">
109
131
  <table id="sql-table" class="table">
110
132
  <thead>
111
133
  <tr>
112
- <td>time</td>
113
- <td>name</td>
114
- <td>sql</td>
115
- <td>时间(ms)</td>
116
- <td>位置</td>
134
+ <th><%= t('simple_apm.show.started_at') %></th>
135
+ <th><%= t('simple_apm.show.sql_name') %></th>
136
+ <th>SQL</th>
137
+ <th><%= t('simple_apm.common.duration') %></th>
138
+ <th><%= t('simple_apm.show.sql_cached') %></th>
139
+ <th><%= t("simple_apm.show.location") %></th>
117
140
  </tr>
118
141
  </thead>
119
142
  <tbody>
@@ -124,24 +147,26 @@
124
147
  <%= sql.name %>
125
148
  </td>
126
149
  <td>
127
- <div class="sql"><%= sql.full_sql -%></div>
150
+ <button type="button" class="sql" aria-label="<%= t('simple_apm.show.sql_list_subtitle') %>"><%= sql.full_sql -%></button>
128
151
  </td>
129
- <td><%= sec_str sql.during %></td>
130
- <td><%= sql.filename %>:<%= sql.line %></td>
152
+ <td data-order="<%= sql.during.to_f %>"><%= sec_str sql.during %></td>
153
+ <td><%= sql.cached.nil? ? t('simple_apm.common.unknown') : t("simple_apm.show.#{sql.cached ? 'cache_hit' : 'cache_miss'}") %></td>
154
+ <td class="apm-mono"><%= "#{sql.filename}:#{sql.line}" if sql.filename.present? %></td>
131
155
  </tr>
132
156
  <% end %>
133
157
  </tbody>
134
158
  </table>
135
159
  </div>
160
+ <% end %>
136
161
  </div>
137
162
  </section>
163
+ <% if @request.sqls.present? %>
138
164
  <script type="text/javascript">
139
165
  $(document).ready(function () {
140
- $('#sql-table').DataTable({
141
- bPaginate: false,
142
- // 自定义的排序方法
143
- aoColumnDefs: [{sType: "sec", aTargets: [3]}]
144
- })
166
+ $('#sql-table').DataTable(window.SimpleApmUI.tableOptions({
167
+ paging: false,
168
+ order: [[3, 'desc']]
169
+ }))
145
170
 
146
171
  })
147
172
  </script>
@@ -0,0 +1,200 @@
1
+ en:
2
+ simple_apm:
3
+ actions:
4
+ action_count: "Actions"
5
+ total_hits: "Total Hits"
6
+ weighted_avg_response: "Avg Response Time"
7
+ summary_hint: "All actions for the selected date"
8
+ title: "Action Performance"
9
+ subtitle: "Aggregate hits, response time, and SQL behavior by Controller#Action."
10
+ list_title: "Action List"
11
+ list_subtitle: "Click an action name to inspect its slow request samples."
12
+ name: "Name"
13
+ click_count: "Hits"
14
+ avg_response_time: "Avg Response Time"
15
+ avg_db_time: "Avg DB Time"
16
+ avg_sql_count: "Avg SQL Count"
17
+ avg_http_time: "Avg HTTP Time"
18
+ fastest_response_time: "Fastest Response Time"
19
+ slowest_response_time: "Slowest Response Time"
20
+ action_info:
21
+ avg_http_time: "Avg HTTP Time"
22
+ cached_queries: "Avg cached SQL"
23
+ sample_status: "HTTP Status"
24
+ title: "Action Overview"
25
+ daily_hits: "Daily Hits"
26
+ avg_response_time: "Avg Response Time"
27
+ avg_db_time: "Avg DB Time"
28
+ avg_sql_count: "Avg SQL Count"
29
+ slowest_response_time: "Slowest Response Time"
30
+ fastest: "Fastest"
31
+ slow_samples_title: "Slow Request Samples"
32
+ slow_samples_subtitle: "Keeps the slowest requests for this action."
33
+ response_time: "Response Time"
34
+ access_time: "Access Time"
35
+ memory_delta: "Memory Delta"
36
+ request_id: "Request ID"
37
+ ip: "IP"
38
+ common:
39
+ copy: "Copy"
40
+ close: "Close"
41
+ apply: "Apply"
42
+ skip_content: "Skip to content"
43
+ missing_title: "Record unavailable"
44
+ missing_hint: "No record was retained for this date. Choose another date or return to the list."
45
+ back_actions: "Back to actions"
46
+ back_requests: "Back to slow requests"
47
+ status: "HTTP Status"
48
+ unknown: "Not recorded"
49
+ duration: "Duration"
50
+ no_samples: "No request samples retained for this date."
51
+ db: "DB"
52
+ http: "HTTP"
53
+ running: "Running"
54
+ paused: "Paused"
55
+ server: "Server"
56
+ sql: "SQL"
57
+ total: "Total"
58
+ url: "URL"
59
+ view: "View"
60
+ dashboard:
61
+ daily_avg_response: "Avg Response Time"
62
+ weighted_daily_average: "Weighted by request count"
63
+ no_data: "No requests for this date"
64
+ no_data_hint: "Select a date with collected data, or check collection status."
65
+ title: "Performance Overview"
66
+ subtitle: "Review response time and traffic trends in 10-minute intervals."
67
+ stat_points: "Data Points"
68
+ ten_minute_intervals: "10-minute intervals"
69
+ hits: "Hits"
70
+ current_day_total: "Current day total"
71
+ peak_avg_response: "Peak Avg Response"
72
+ interval_peak: "Interval peak"
73
+ current_collection: "Collection"
74
+ redis_status: "Redis status"
75
+ query_date: "Query Date"
76
+ switch_in_top_right: "Switchable in the top right"
77
+ response_time: "Response Time"
78
+ response_time_subtitle: "Average response time for each interval."
79
+ hit_count: "Hit Count"
80
+ hit_count_subtitle: "Request count for each interval."
81
+ data:
82
+ retained_days: "Retained Days"
83
+ retained_requests: "Retained Requests"
84
+ weighted_avg_response: "Avg Response Time"
85
+ summary_hint: "Across all retained dates"
86
+ view_dashboard: "View dashboard"
87
+ view_actions: "View actions"
88
+ view_slow_requests: "View slow requests"
89
+ no_data: "No historical data"
90
+ no_data_hint: "Historical data will appear after requests have been collected."
91
+ title: "Data Management"
92
+ subtitle: "Manage collection status and historical Redis data."
93
+ collection_status: "Collection Status"
94
+ collection_subtitle: "When paused, middleware stops recording new request performance data."
95
+ pause_collection: "Pause Collection"
96
+ resume_collection: "Resume Collection"
97
+ confirm_pause: "Pause collection?"
98
+ delete_data: "Delete Data"
99
+ delete_subtitle: "Clean historical data by retention period, or delete one day."
100
+ keep_one_week: "Keep One Week"
101
+ keep_one_month: "Keep One Month"
102
+ confirm_delete_week: "Delete all data older than one week?"
103
+ confirm_delete_month: "Delete all data older than one month?"
104
+ history_title: "Historical Data"
105
+ history_subtitle: "View collection volume and average response time by date."
106
+ date: "Date"
107
+ request_count: "Requests"
108
+ avg_response_time: "Avg Response Time"
109
+ operation: "Operation"
110
+ delete: "Delete"
111
+ confirm_delete: "Delete this data?"
112
+ flash:
113
+ deleted: "Deleted successfully."
114
+ deleted_count: "Deleted %{count} records successfully."
115
+ no_data_for_day: "No data for this day."
116
+ unknown_action: "Unknown action."
117
+ updated: "Updated successfully."
118
+ index:
119
+ sample_limit: "Sample limit"
120
+ refresh: "Refresh"
121
+ refresh_loading: "Loading…"
122
+ load_error: "Unable to load request samples. Refresh to try again."
123
+ title: "Slow Requests"
124
+ subtitle: "Sort by response duration to locate DB, SQL, View, and external request cost."
125
+ samples_title: "Request Samples"
126
+ samples_subtitle: "Shows the slowest retained requests for the selected date."
127
+ request_time: "Request Time"
128
+ action_name: "Action Name"
129
+ total_time: "Total Time"
130
+ memory_mb: "Memory Delta (MB)"
131
+ ip: "IP"
132
+ layout:
133
+ collected: "Collecting data"
134
+ date: "Date"
135
+ language: "Language"
136
+ nav_actions: "Actions"
137
+ nav_dashboard: "Dashboard"
138
+ nav_data: "Data"
139
+ nav_slow_requests: "Slow Requests"
140
+ redis_info:
141
+ current_memory: "Current Memory"
142
+ current_memory_rss: "Current Memory (RSS)"
143
+ db: "DB"
144
+ peak_memory: "Peak Memory"
145
+ redis_version: "Redis Version"
146
+ system_memory: "System Memory"
147
+ locales:
148
+ en: "English"
149
+ zh-CN: "中文"
150
+ show:
151
+ request_id: "Request ID"
152
+ format_method: "Method / Format"
153
+ sql_name: "Name"
154
+ sql_cached: "Cache"
155
+ cache_hit: "Hit"
156
+ cache_miss: "Miss"
157
+ timing_title: "Recorded Timing"
158
+ timing_hint: "Timings may overlap; DB, View and HTTP do not necessarily add up to the total."
159
+ no_sql: "No SQL statements retained. SQL below the configured threshold is not recorded."
160
+ no_http: "No external HTTP calls retained."
161
+ title: "Request Details"
162
+ cached: "Cached"
163
+ basic_info: "Basic Info"
164
+ basic_info_subtitle: "Request source, time, and memory changes."
165
+ started_at: "Started At"
166
+ completed_memory: "Completed Memory"
167
+ memory_increase: "Increase"
168
+ ip: "IP"
169
+ exception: "Exception"
170
+ external_requests: "External Requests"
171
+ external_requests_subtitle: "Net::HTTP calls triggered during this request."
172
+ duration: "Duration"
173
+ other_info: "Other Info"
174
+ sql_list: "SQL List"
175
+ sql_list_subtitle: "Click SQL text to view the complete statement."
176
+ time_ms: "Time (ms)"
177
+ location: "Location"
178
+ diagnostics:
179
+ title: "AI Diagnostic Context"
180
+ hint: "Copy metrics, retained samples, SQL, external calls and code locations as JSON. Common credential fields are filtered; expand to review the content."
181
+ copy: "Copy for AI"
182
+ preview: "Preview diagnostic context"
183
+ copied: "Copied to clipboard."
184
+ copy_failed: "Copy failed. Select the text and copy it manually."
185
+ table:
186
+ search: "Search:"
187
+ length_menu: "Show _MENU_ rows"
188
+ info: "_START_–_END_ of _TOTAL_ rows"
189
+ info_empty: "0 rows"
190
+ info_filtered: "(filtered from _MAX_ rows)"
191
+ zero_records: "No matching records. Try a different search."
192
+ empty: "No records for this date."
193
+ loading: "Loading…"
194
+ processing: "Processing…"
195
+ first: "First"
196
+ last: "Last"
197
+ next: "Next"
198
+ previous: "Previous"
199
+ sort_ascending: ": activate to sort ascending"
200
+ sort_descending: ": activate to sort descending"
@@ -0,0 +1,200 @@
1
+ zh-CN:
2
+ simple_apm:
3
+ actions:
4
+ action_count: "Action 数量"
5
+ total_hits: "请求总数"
6
+ weighted_avg_response: "平均响应时间"
7
+ summary_hint: "当前日期全部 Action"
8
+ title: "Action 性能"
9
+ subtitle: "按 Controller#Action 聚合访问次数、响应时间和 SQL 行为。"
10
+ list_title: "Action 列表"
11
+ list_subtitle: "点击 Action 名称查看该接口的慢请求样本。"
12
+ name: "Action 名称"
13
+ click_count: "请求次数"
14
+ avg_response_time: "平均响应时间"
15
+ avg_db_time: "平均 DB 时间"
16
+ avg_sql_count: "平均 SQL 次数"
17
+ avg_http_time: "平均 HTTP 访问时间"
18
+ fastest_response_time: "最快响应时间"
19
+ slowest_response_time: "最慢响应时间"
20
+ action_info:
21
+ avg_http_time: "平均 HTTP 耗时"
22
+ cached_queries: "平均缓存 SQL"
23
+ sample_status: "HTTP 状态"
24
+ title: "Action 概况"
25
+ daily_hits: "当日请求次数"
26
+ avg_response_time: "平均响应时间"
27
+ avg_db_time: "平均 DB 时间"
28
+ avg_sql_count: "平均 SQL 次数"
29
+ slowest_response_time: "最慢响应时间"
30
+ fastest: "最快"
31
+ slow_samples_title: "慢请求样本"
32
+ slow_samples_subtitle: "保留该 Action 下响应最慢的请求。"
33
+ response_time: "响应时间"
34
+ access_time: "访问时间"
35
+ memory_delta: "内存波动"
36
+ request_id: "请求 ID"
37
+ ip: "访问 IP"
38
+ common:
39
+ copy: "复制"
40
+ close: "关闭"
41
+ apply: "应用"
42
+ skip_content: "跳转到主要内容"
43
+ missing_title: "记录不可用"
44
+ missing_hint: "该日期没有保留此记录,请选择其他日期或返回列表。"
45
+ back_actions: "返回 Action 列表"
46
+ back_requests: "返回慢请求列表"
47
+ status: "HTTP 状态"
48
+ unknown: "未记录"
49
+ duration: "耗时"
50
+ no_samples: "该日期没有保留请求样本。"
51
+ db: "DB"
52
+ http: "HTTP"
53
+ running: "运行中"
54
+ paused: "已暂停"
55
+ server: "服务器"
56
+ sql: "SQL"
57
+ total: "总耗时"
58
+ url: "URL"
59
+ view: "视图"
60
+ dashboard:
61
+ daily_avg_response: "平均响应时间"
62
+ weighted_daily_average: "按请求次数加权统计"
63
+ no_data: "该日期没有请求数据"
64
+ no_data_hint: "请选择有采集数据的日期,或检查采集状态。"
65
+ title: "性能概览"
66
+ subtitle: "按 10 分钟粒度观察响应时间和访问量趋势。"
67
+ stat_points: "统计点"
68
+ ten_minute_intervals: "10 分钟区间"
69
+ hits: "访问次数"
70
+ current_day_total: "当前日期累计"
71
+ peak_avg_response: "最高平均响应"
72
+ interval_peak: "区间峰值"
73
+ current_collection: "当前采集"
74
+ redis_status: "Redis 状态"
75
+ query_date: "查询日期"
76
+ switch_in_top_right: "可在右上角切换"
77
+ response_time: "响应时间"
78
+ response_time_subtitle: "每个时间段的平均响应耗时。"
79
+ hit_count: "访问次数"
80
+ hit_count_subtitle: "每个时间段的请求数量。"
81
+ data:
82
+ retained_days: "保留天数"
83
+ retained_requests: "保留请求数"
84
+ weighted_avg_response: "平均响应时间"
85
+ summary_hint: "全部保留日期的统计"
86
+ view_dashboard: "查看概览"
87
+ view_actions: "查看 Action"
88
+ view_slow_requests: "查看慢请求"
89
+ no_data: "暂无历史数据"
90
+ no_data_hint: "采集到请求后,将在这里显示历史数据。"
91
+ title: "数据管理"
92
+ subtitle: "管理采集开关和历史 Redis 数据。"
93
+ collection_status: "采集状态"
94
+ collection_subtitle: "暂停后 middleware 不再记录新的请求性能数据。"
95
+ pause_collection: "暂停收集数据"
96
+ resume_collection: "继续收集数据"
97
+ confirm_pause: "确定暂停吗?"
98
+ delete_data: "删除数据"
99
+ delete_subtitle: "按保留周期清理历史数据,或删除单日数据。"
100
+ keep_one_week: "保留一周数据"
101
+ keep_one_month: "保留一个月数据"
102
+ confirm_delete_week: "确定删除所有一周以前的数据?"
103
+ confirm_delete_month: "确定删除所有一个月以前的数据?"
104
+ history_title: "历史数据"
105
+ history_subtitle: "以日期为单位查看采集量和平均响应时间。"
106
+ date: "日期"
107
+ request_count: "请求数量"
108
+ avg_response_time: "平均响应时间"
109
+ operation: "操作"
110
+ delete: "删除"
111
+ confirm_delete: "确定删除?"
112
+ flash:
113
+ deleted: "删除成功!"
114
+ deleted_count: "成功删除 %{count} 条数据"
115
+ no_data_for_day: "当日没有数据"
116
+ unknown_action: "未知操作!"
117
+ updated: "设置成功!"
118
+ index:
119
+ sample_limit: "样本数量上限"
120
+ refresh: "刷新"
121
+ refresh_loading: "加载中…"
122
+ load_error: "请求样本加载失败,请点击刷新重试。"
123
+ title: "慢事务列表"
124
+ subtitle: "按响应耗时排序,快速定位 DB、SQL、View 和外部请求占比。"
125
+ samples_title: "请求样本"
126
+ samples_subtitle: "展示当前日期保留的最慢请求,可排序和搜索。"
127
+ request_time: "请求时间"
128
+ action_name: "Action 名称"
129
+ total_time: "总耗时"
130
+ memory_mb: "内存变化 (MB)"
131
+ ip: "IP"
132
+ layout:
133
+ collected: "数据收集中"
134
+ date: "统计日期"
135
+ language: "语言"
136
+ nav_actions: "Action 列表"
137
+ nav_dashboard: "Dashboard"
138
+ nav_data: "数据管理"
139
+ nav_slow_requests: "慢事务列表"
140
+ redis_info:
141
+ current_memory: "当前内存占用"
142
+ current_memory_rss: "当前内存占用 (RSS)"
143
+ db: "DB"
144
+ peak_memory: "占用内存峰值"
145
+ redis_version: "Redis 版本"
146
+ system_memory: "系统内存"
147
+ locales:
148
+ en: "English"
149
+ zh-CN: "中文"
150
+ show:
151
+ request_id: "请求 ID"
152
+ format_method: "请求方法 / 格式"
153
+ sql_name: "名称"
154
+ sql_cached: "缓存"
155
+ cache_hit: "命中"
156
+ cache_miss: "未命中"
157
+ timing_title: "记录的耗时"
158
+ timing_hint: "各项耗时可能重叠,DB、View 和 HTTP 的合计不一定等于总耗时。"
159
+ no_sql: "没有保留 SQL 明细,低于配置阈值的 SQL 不会记录。"
160
+ no_http: "没有保留外部 HTTP 调用。"
161
+ title: "请求详情"
162
+ cached: "缓存"
163
+ basic_info: "基础信息"
164
+ basic_info_subtitle: "请求来源、时间和内存变化。"
165
+ started_at: "开始时间"
166
+ completed_memory: "结束时内存"
167
+ memory_increase: "增幅"
168
+ ip: "访问 IP"
169
+ exception: "报错信息"
170
+ external_requests: "外部请求"
171
+ external_requests_subtitle: "请求过程中触发的 Net::HTTP 调用。"
172
+ duration: "耗时"
173
+ other_info: "其他信息"
174
+ sql_list: "SQL 列表"
175
+ sql_list_subtitle: "点击 SQL 文本查看完整语句。"
176
+ time_ms: "时间 (ms)"
177
+ location: "位置"
178
+ diagnostics:
179
+ title: "AI 排查上下文"
180
+ hint: "以 JSON 复制指标、保留的请求样本、SQL、外部调用与代码位置。常见凭据字段已过滤,可展开预览内容。"
181
+ copy: "复制给 AI"
182
+ preview: "预览排查信息"
183
+ copied: "已复制到剪贴板。"
184
+ copy_failed: "复制失败,请选中文本后手动复制。"
185
+ table:
186
+ search: "搜索:"
187
+ length_menu: "每页 _MENU_ 条"
188
+ info: "第 _START_–_END_ 条,共 _TOTAL_ 条"
189
+ info_empty: "共 0 条"
190
+ info_filtered: "(从 _MAX_ 条记录筛选)"
191
+ zero_records: "没有匹配记录,请尝试其他关键词。"
192
+ empty: "该日期暂无记录。"
193
+ loading: "加载中…"
194
+ processing: "处理中…"
195
+ first: "首页"
196
+ last: "末页"
197
+ next: "下一页"
198
+ previous: "上一页"
199
+ sort_ascending: ":激活以升序排列"
200
+ sort_descending: ":激活以降序排列"
data/config/routes.rb CHANGED
@@ -5,7 +5,8 @@ SimpleApm::Engine.routes.draw do
5
5
  get 'action_info', to: 'apm#action_info'
6
6
  get 'actions', to: 'apm#actions'
7
7
  get 'data', to: 'apm#data'
8
- get 'data_delete', to: 'apm#data_delete'
8
+ post 'data_delete', to: 'apm#data_delete'
9
9
  get 'set_apm_date', to: 'apm#set_apm_date'
10
+ get 'set_locale', to: 'apm#set_locale'
10
11
  root 'apm#dashboard'
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleApm
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -51,13 +51,14 @@ module SimpleApm
51
51
  host: Socket.gethostname,
52
52
  remote_addr: remote_addr,
53
53
  method: payload[:method],
54
+ status: payload[:status],
54
55
  completed_memory: completed_memory,
55
56
  memory_during: memory_during,
56
57
  format: payload[:format],
57
58
  net_http_during: net_http_during,
58
59
  exception: payload[:exception].presence.to_json
59
60
  }.with_indifferent_access
60
- info[:status] = '500' if payload[:exception]
61
+ info[:status] ||= '500' if payload[:exception]
61
62
  # 存储
62
63
  in_slow = SimpleApm::SlowRequest.update_by_request info
63
64
  in_action_info = SimpleApm::Action.update_by_request info
@@ -92,6 +93,8 @@ module SimpleApm
92
93
  started: started,
93
94
  sql: payload[:sql],
94
95
  value: sql_value,
96
+ cached: payload[:cached] || false,
97
+ method: payload[:method],
95
98
  filename: payload[:filename],
96
99
  line: payload[:line]
97
100
  }.with_indifferent_access