log_sense 2.4.0 → 2.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/CHANGELOG.org +4 -0
- data/lib/log_sense/rails/log_parser.rb +42 -46
- data/lib/log_sense/rails_aggregator.rb +22 -6
- data/lib/log_sense/rails_report_shaper.rb +2 -0
- data/lib/log_sense/report_shaper.rb +23 -0
- data/lib/log_sense/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: 85b0ebee3c5879005dce7f3e32675a5f0319411eb74f138b2dfd7a4c21d26d43
|
4
|
+
data.tar.gz: 1aec3ca221196cfaf9061495e6767f5136a23a1f9d6f510fb43a28c056c1ca8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27389b84f365fdaa02ece44dd70eabb130051ca81d26d17cd573325f8101d21c0dc83fd5c81915babfcd1e8d1f363ef777811f9676b2439e8f6b868013515700
|
7
|
+
data.tar.gz: e52b3e05fb838362c3938aaf20d1f6347a3a4c8025d40963c98eeae4fe4b6c01d9acf225353ce2c872c213b2f113af089de418bc0e424e4b151884f4fd37c03c
|
data/CHANGELOG.org
CHANGED
@@ -16,53 +16,43 @@ module LogSense
|
|
16
16
|
def parse(streams, options = {})
|
17
17
|
db = SQLite3::Database.new ":memory:"
|
18
18
|
|
19
|
+
event_table = {
|
20
|
+
exit_status: "TEXT",
|
21
|
+
started_at: "TEXT",
|
22
|
+
ended_at: "TEXT",
|
23
|
+
log_id: "TEXT",
|
24
|
+
ip: "TEXT",
|
25
|
+
unique_visitor: "TEXT",
|
26
|
+
url: "TEXT",
|
27
|
+
controller: "TEXT",
|
28
|
+
html_verb: "TEXT",
|
29
|
+
status: "INTEGER",
|
30
|
+
duration_total_ms: "FLOAT",
|
31
|
+
duration_views_ms: "FLOAT",
|
32
|
+
duration_ar_ms: "FLOAT",
|
33
|
+
allocations: "INTEGER",
|
34
|
+
queries: "INTEGER",
|
35
|
+
cached_queries: "INTEGER",
|
36
|
+
gc_duration: "FLOAT",
|
37
|
+
comment: "TEXT",
|
38
|
+
source_file: "TEXT",
|
39
|
+
line_number: "INTEGER"
|
40
|
+
}
|
41
|
+
|
42
|
+
table_declaration = event_table.map { |k, v| "#{k} #{v}" }.join(",")
|
19
43
|
db.execute <<-EOS
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ended_at TEXT,
|
25
|
-
log_id TEXT,
|
26
|
-
ip TEXT,
|
27
|
-
unique_visitor TEXT,
|
28
|
-
url TEXT,
|
29
|
-
controller TEXT,
|
30
|
-
html_verb TEXT,
|
31
|
-
status INTEGER,
|
32
|
-
duration_total_ms FLOAT,
|
33
|
-
duration_views_ms FLOAT,
|
34
|
-
duration_ar_ms FLOAT,
|
35
|
-
allocations INTEGER,
|
36
|
-
queries INTEGER,
|
37
|
-
cached_queries INTEGER,
|
38
|
-
gc_duration INTEGER,
|
39
|
-
comment TEXT,
|
40
|
-
source_file TEXT,
|
41
|
-
line_number INTEGER
|
42
|
-
)
|
44
|
+
CREATE TABLE IF NOT EXISTS Event(
|
45
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
46
|
+
#{table_declaration}
|
47
|
+
)
|
43
48
|
EOS
|
44
49
|
|
50
|
+
tds = event_table.keys.size
|
45
51
|
ins = db.prepare <<-EOS
|
46
|
-
|
47
|
-
|
48
|
-
started_at,
|
49
|
-
ended_at,
|
50
|
-
log_id,
|
51
|
-
ip,
|
52
|
-
unique_visitor,
|
53
|
-
url,
|
54
|
-
controller,
|
55
|
-
html_verb,
|
56
|
-
status,
|
57
|
-
duration_total_ms,
|
58
|
-
duration_views_ms,
|
59
|
-
duration_ar_ms,
|
60
|
-
allocations,
|
61
|
-
comment,
|
62
|
-
source_file,
|
63
|
-
line_number
|
52
|
+
insert into Event(
|
53
|
+
#{event_table.keys.join(", ")}
|
64
54
|
)
|
65
|
-
values (#{Array.new(
|
55
|
+
values (#{Array.new(tds, "?").join(", ")})
|
66
56
|
EOS
|
67
57
|
|
68
58
|
db.execute <<-EOS
|
@@ -254,6 +244,9 @@ module LogSense
|
|
254
244
|
event[:duration_views_ms],
|
255
245
|
event[:duration_ar_ms],
|
256
246
|
event[:allocations],
|
247
|
+
event[:queries],
|
248
|
+
event[:cached_queries],
|
249
|
+
event[:gc_duration],
|
257
250
|
event[:comment],
|
258
251
|
filename,
|
259
252
|
line_number
|
@@ -290,6 +283,9 @@ module LogSense
|
|
290
283
|
event[:duration_views_ms],
|
291
284
|
event[:duration_ar_ms],
|
292
285
|
event[:allocations],
|
286
|
+
event[:queries],
|
287
|
+
event[:cached_queries],
|
288
|
+
event[:gc_duration],
|
293
289
|
event[:comment],
|
294
290
|
filename,
|
295
291
|
line_number
|
@@ -494,10 +490,10 @@ module LogSense
|
|
494
490
|
duration_total_ms: matchdata[:total],
|
495
491
|
duration_views_ms: matchdata[:views],
|
496
492
|
duration_ar_ms: matchdata[:arec],
|
497
|
-
allocations:
|
498
|
-
queries:
|
499
|
-
cached_queries:
|
500
|
-
gc_duration:
|
493
|
+
allocations: matchdata[:alloc],
|
494
|
+
queries: matchdata[:queries],
|
495
|
+
cached_queries: matchdata[:cached_queries],
|
496
|
+
gc_duration: matchdata[:gc_duration],
|
501
497
|
comment: ""
|
502
498
|
}
|
503
499
|
end
|
@@ -81,6 +81,22 @@ module LogSense
|
|
81
81
|
}
|
82
82
|
end
|
83
83
|
|
84
|
+
@queries = @db.execute %Q(
|
85
|
+
SELECT SUM(queries), SUM(cached_queries),
|
86
|
+
ROUND(SUM(queries) / SUM(cached_queries), 2)
|
87
|
+
FROM Event
|
88
|
+
)
|
89
|
+
|
90
|
+
@queries_by_controller = @db.execute %Q(
|
91
|
+
SELECT controller,
|
92
|
+
MIN(queries), MAX(queries), ROUND(AVG(queries), 2),
|
93
|
+
SUM(queries), SUM(cached_queries),
|
94
|
+
ROUND(SUM(cached_queries) / SUM(queries), 2),
|
95
|
+
SUM(gc_duration)
|
96
|
+
FROM Event
|
97
|
+
GROUP BY Event.controller
|
98
|
+
)
|
99
|
+
|
84
100
|
@controller_and_methods_by_device = @db.execute %Q(
|
85
101
|
SELECT controller as Controller,
|
86
102
|
method as Method,
|
@@ -125,7 +141,7 @@ module LogSense
|
|
125
141
|
ON event.log_id == error.log_id
|
126
142
|
WHERE #{filter} and exit_status == 'S:FAILED'
|
127
143
|
GROUP BY strftime("%Y-%m-%d", started_at)
|
128
|
-
)
|
144
|
+
) || [[]]
|
129
145
|
|
130
146
|
@fatal = @db.execute %(
|
131
147
|
SELECT strftime("%Y-%m-%d %H:%M", started_at),
|
@@ -137,7 +153,7 @@ module LogSense
|
|
137
153
|
FROM Event JOIN Error
|
138
154
|
ON event.log_id == error.log_id
|
139
155
|
WHERE #{filter} and exit_status == 'S:FAILED'
|
140
|
-
)
|
156
|
+
) || [[]]
|
141
157
|
|
142
158
|
@fatal_grouped = @db.execute %(
|
143
159
|
SELECT filename,
|
@@ -147,7 +163,7 @@ module LogSense
|
|
147
163
|
count(distinct(error.id))
|
148
164
|
FROM Error
|
149
165
|
GROUP BY description
|
150
|
-
)
|
166
|
+
) || [[]]
|
151
167
|
|
152
168
|
@job_plot = @db.execute %(
|
153
169
|
SELECT strftime("%Y-%m-%d", ended_at) as Day,
|
@@ -156,7 +172,7 @@ module LogSense
|
|
156
172
|
FROM Job
|
157
173
|
WHERE #{filter}
|
158
174
|
GROUP BY strftime("%Y-%m-%d", ended_at)
|
159
|
-
)
|
175
|
+
) || [[]]
|
160
176
|
|
161
177
|
# worker,
|
162
178
|
# host,
|
@@ -173,7 +189,7 @@ module LogSense
|
|
173
189
|
attempt
|
174
190
|
FROM Job
|
175
191
|
WHERE #{filter}
|
176
|
-
)
|
192
|
+
) || [[]]
|
177
193
|
|
178
194
|
@job_error_grouped = @db.execute %(
|
179
195
|
SELECT worker,
|
@@ -188,7 +204,7 @@ module LogSense
|
|
188
204
|
FROM Job
|
189
205
|
WHERE #{filter} and (exit_status == 'S:ERROR' or exit_status == 'S:FAILED')
|
190
206
|
GROUP BY object_id
|
191
|
-
)
|
207
|
+
) || [[]]
|
192
208
|
|
193
209
|
instance_vars_to_hash
|
194
210
|
end
|
@@ -136,6 +136,29 @@ module LogSense
|
|
136
136
|
}
|
137
137
|
end
|
138
138
|
|
139
|
+
def queries(data, colors: [], col: "small-12 cell")
|
140
|
+
{
|
141
|
+
title: "Number of queries",
|
142
|
+
header: %w[Queries Cached Perc_Cached],
|
143
|
+
column_alignment: %i[right right right],
|
144
|
+
rows: data[:queries],
|
145
|
+
col: col,
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def queries_by_controller(data, colors: [], col: "small-12 cell")
|
150
|
+
{
|
151
|
+
title: "Queries by Controller",
|
152
|
+
header: ["Controller",
|
153
|
+
"Min queries", "Max queries", "Avg Queries",
|
154
|
+
"Total queries", "Cached queries", "Perc",
|
155
|
+
"Total GC"],
|
156
|
+
column_alignment: %i[left right right right right right right right],
|
157
|
+
rows: data[:queries_by_controller],
|
158
|
+
col: col,
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
139
162
|
#
|
140
163
|
# Reports shared between rails and apache/nginx
|
141
164
|
#
|
data/lib/log_sense/version.rb
CHANGED