evidence 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c1b6dbf6bb3b0a59bb56b902ef62834f315e804
4
- data.tar.gz: 983e1414221dae85d29c7eafadff2c7fa3d2c1d0
3
+ metadata.gz: 4b8963748cdd5830802554d79fd26f64037fd13b
4
+ data.tar.gz: d800a7d498f1a4e2856bdfc5405313b8be4ddb83
5
5
  SHA512:
6
- metadata.gz: b75c8fdc0a63017250c3412d8e579f64c26f8b603ed4b374b7c7143fdb4d4ceb1d161d7574d7afc238c6ee1af441cb574e48940ca7b670ff8a187ef6655cae27
7
- data.tar.gz: c5700202e8e74b13bacb9e8a5ecd0007775e6d8c2c9a8e7355c9dc91d53aa2845c38c2f7fdb91ca54888d5fa5efb396d8854f35e4979231fcc11111b29f0b6a8
6
+ metadata.gz: 0e070f30317b31e03bd71d73b13a9115c9a12829ff48901c420971eebe682d237014cf6fa790fdd376e2092f060f7edb12001198223432f5c92c6fc8d22674ee
7
+ data.tar.gz: 8e7a2f25a780c22501a09c8e6fcc05d5a60fcd4d1b387906f487e2403b9d5cc8e5ebc6ed8d0df19dd65fee720efe62af0882b27135d57a882bae3190e10c2d3f
@@ -10,14 +10,24 @@ module Evidence
10
10
  def to_proc
11
11
  lambda do |log|
12
12
  pid = @pid[log]
13
+ msg = @message[log]
13
14
  if @processes.has_key?(pid)
14
- @processes[pid] << log
15
- if end_action?(@message[log])
16
- parse_action_logs(@processes.delete(pid))
15
+ if start_action?(msg)
16
+ warn "[WARN] Found start action following another start action: #{msg}"
17
+ warn "[WARN] Ignore logs: #{@processes.delete(pid).inspect}"
18
+ @processes[pid] = [log]
19
+ nil
20
+ else
21
+ @processes[pid] << log
22
+ if end_action?(msg)
23
+ parse_action_logs(@processes.delete(pid))
24
+ end
17
25
  end
18
26
  else
19
- if start_action?(@message[log])
27
+ if start_action?(msg)
20
28
  @processes[pid] = [log]
29
+ else
30
+ warn "[WARN] Ignore a log that is not start action and also not after a start action: #{log.inspect}"
21
31
  end
22
32
  nil
23
33
  end
@@ -5,6 +5,7 @@ module Evidence
5
5
  (\#012\#012)? # ignore encoded newlines
6
6
  Processing\s+
7
7
  (?<controller>\w+)\#(?<action>\w+)\s+
8
+ (to\s+(?<format>\w+)\s+)?
8
9
  \(for\s+
9
10
  (?<remote_addr>[^\s]+)\s+
10
11
  at\s+
@@ -14,13 +15,16 @@ module Evidence
14
15
  end: /^
15
16
  Completed\sin\s
16
17
  (?<completed_time>\d+)ms\s+
17
- \((View\:\s(?<view_time>\d+))?
18
- \s*,?\s*
19
- (\s*DB\:\s(?<db_time>\d+))?
20
- \)?\s+\|\s+
18
+ (
19
+ \(
20
+ (View\:\s(?<view_time>\d+))?
21
+ \s*,?\s*
22
+ (DB\:\s(?<db_time>\d+))?
23
+ \)?
24
+ )?\s*\|\s*
21
25
  (?<code>\d+)\s+
22
- (?<status>\w+)\s+
23
- \[(?<url>.+)\]
26
+ (?<status>[ \w-]+)\s+
27
+ (?<url>.+)
24
28
  $/x
25
29
  }
26
30
  end
data/lib/evidence.rb CHANGED
@@ -13,7 +13,9 @@ module Evidence
13
13
  def parse_log(pattern)
14
14
  lambda do |log|
15
15
  if m = pattern.match(log)
16
- Hash[m.names.map(&:to_sym).zip(m.captures)]
16
+ Hash[m.names.map(&:to_sym).zip(m.captures)].tap do |h|
17
+ h[:origin] = log unless h.has_key?(:origin)
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -39,7 +41,7 @@ module Evidence
39
41
  end
40
42
  end
41
43
 
42
- # actions.chunk(&time_window(60))
44
+ # actions.chunk(&by_time_window(60))
43
45
  def by_time_window(time_window, start=nil)
44
46
  range = nil
45
47
  lambda do |ele|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evidence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiao Li
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-22 00:00:00.000000000 Z
12
+ date: 2013-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -37,7 +37,6 @@ files:
37
37
  - lib/evidence/action_parser.rb
38
38
  - lib/evidence/lazy.rb
39
39
  - lib/evidence/rails.rb
40
- - lib/evidence/rails_action_parser.rb
41
40
  - lib/evidence.rb
42
41
  - examples/mingle_logs_analysis.rb
43
42
  homepage: https://github.com/ThoughtWorksStudios/evidence
@@ -1,55 +0,0 @@
1
- module Evidence
2
- class ActionParser
3
-
4
- def initialize(pid, message, action_patterns)
5
- @pid, @message = pid, message
6
- @processes = Hash.new
7
- @start_action_pattern, @end_action_pattern = action_patterns[:start], action_patterns[:end]
8
- end
9
-
10
- def to_proc
11
- lambda do |log|
12
- pid = @pid[log]
13
- if @processes.has_key?(pid)
14
- @processes[pid] << log
15
- if end_action?(@message[log])
16
- parse_action_logs(@processes.delete(pid))
17
- end
18
- else
19
- if start_action?(@message[log])
20
- @processes[pid] = [log]
21
- end
22
- nil
23
- end
24
- end
25
- end
26
-
27
- def parse_action_logs(logs)
28
- {
29
- request: request(@message[logs[0]]),
30
- response: response(@message[logs[-1]]),
31
- logs: logs
32
- }
33
- end
34
-
35
- def end_action?(msg)
36
- msg =~ @end_action_pattern
37
- end
38
-
39
- def start_action?(msg)
40
- msg =~ @start_action_pattern
41
- end
42
-
43
- def request(msg)
44
- to_hash(@start_action_pattern.match(msg))
45
- end
46
-
47
- def response(msg)
48
- to_hash(@end_action_pattern.match(msg))
49
- end
50
-
51
- def to_hash(m)
52
- Hash[m.names.map(&:to_sym).zip(m.captures)]
53
- end
54
- end
55
- end