soar_auditing_provider 1.1.4 → 1.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 263b7fc728885f0bc350e4c339cb70c365ab0181
|
4
|
+
data.tar.gz: 2ef1bee6ad5a0b42568ceb41bdb6a621c3b9df77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd74895116aaa81c4dc780f42a54a5a569a16d8a3040eb26affabffa64dc43d13cd9ad97ec48a34af55a91a8a4eadb2424806f5df5c79a4fb3b076cb9374ae4
|
7
|
+
data.tar.gz: 53d08d6854c16b74168a711d9f85a0a7774737d6149c2f2916d2ef2c59fa56e8e40cc8fbaba6f71810140c8e41498fec41fec24287deba3c4cd7fe757bebce2d
|
@@ -78,6 +78,13 @@ module SoarAuditingProvider
|
|
78
78
|
@worker.flush
|
79
79
|
end
|
80
80
|
|
81
|
+
def audit_exception(exception:, level: :error, flow_id: nil)
|
82
|
+
exception_message = "#{exception.class}: #{exception.message}"
|
83
|
+
exception_message = exception_message + ":\n\t" + exception.backtrace.join("\n\t") if ENV['RACK_ENV'] == 'development'
|
84
|
+
level = :error if not is_valid_audit_level?(level)
|
85
|
+
send(level,exception_message,flow_id)
|
86
|
+
end
|
87
|
+
|
81
88
|
private
|
82
89
|
|
83
90
|
def prepend_caller_information(data)
|
@@ -97,17 +104,11 @@ module SoarAuditingProvider
|
|
97
104
|
end
|
98
105
|
|
99
106
|
def exit_cleanup(exception = nil)
|
100
|
-
|
107
|
+
audit_exception(exception: exception, level: :fatal, flow_id: @startup_flow_id) if exception
|
101
108
|
info("Application exit",@startup_flow_id)
|
102
109
|
flush
|
103
110
|
end
|
104
111
|
|
105
|
-
def audit_exception_message(exception)
|
106
|
-
exception_message = "#{exception.class}: #{exception.message}"
|
107
|
-
exception_message = exception_message + ":\n\t" + exception.backtrace.join("\n\t") if ENV['RACK_ENV'] == 'development'
|
108
|
-
fatal(exception_message,@startup_flow_id)
|
109
|
-
end
|
110
|
-
|
111
112
|
def enqueue(level, data)
|
112
113
|
@worker.enqueue(level, data)
|
113
114
|
@enqueued_audit_events += 1
|
@@ -178,5 +179,9 @@ module SoarAuditingProvider
|
|
178
179
|
'startup_timestamp' => @startup_timestamp
|
179
180
|
}
|
180
181
|
end
|
182
|
+
|
183
|
+
def is_valid_audit_level?(level)
|
184
|
+
[:debug, :info, :warn, :error, :fatal].include?(level)
|
185
|
+
end
|
181
186
|
end
|
182
187
|
end
|
@@ -2,10 +2,17 @@ require 'soar_thread_worker/thread_worker'
|
|
2
2
|
|
3
3
|
module SoarAuditingProvider
|
4
4
|
class AuditingWorker < SoarThreadWorker::ThreadWorker
|
5
|
+
attr_reader :failed_audit_attempts
|
6
|
+
attr_reader :latest_failed_audit_timestamp
|
7
|
+
attr_reader :latest_failed_audit_error_message
|
8
|
+
attr_reader :successful_audits
|
9
|
+
attr_reader :dequeued_audits
|
10
|
+
attr_reader :latest_successful_audit_timespan
|
11
|
+
attr_reader :latest_successful_audit_timestamp
|
12
|
+
|
5
13
|
def initialize
|
6
14
|
@queue = Queue.new
|
7
15
|
@start_mutex = Mutex.new
|
8
|
-
@queue_mutex = Mutex.new
|
9
16
|
initialize_metrics
|
10
17
|
end
|
11
18
|
|
@@ -19,17 +26,20 @@ module SoarAuditingProvider
|
|
19
26
|
end
|
20
27
|
|
21
28
|
def enqueue(level, data)
|
22
|
-
@
|
23
|
-
raise AuditingOverflowError if @queue.size >= @maximum_queue_size
|
29
|
+
if @queue.size < @maximum_queue_size then
|
24
30
|
@queue.push({:level => level, :data => data})
|
25
|
-
|
26
|
-
|
31
|
+
else
|
32
|
+
raise AuditingOverflowError
|
33
|
+
end
|
34
|
+
ensure_worker_is_running
|
27
35
|
end
|
28
36
|
|
29
|
-
def start
|
37
|
+
def start(verbose: false)
|
30
38
|
@start_mutex.synchronize {
|
31
|
-
|
32
|
-
|
39
|
+
if not running? then
|
40
|
+
super()
|
41
|
+
$stderr.puts("Auditing worker was not running and respawned") if verbose
|
42
|
+
end
|
33
43
|
}
|
34
44
|
end
|
35
45
|
|
@@ -54,16 +64,11 @@ module SoarAuditingProvider
|
|
54
64
|
failed_before = true
|
55
65
|
retry
|
56
66
|
end
|
57
|
-
|
58
|
-
@queue_mutex.synchronize {
|
59
|
-
return false if not @queue.empty? #indicates to thread worker that we are not done executing since the queue is not empty
|
60
|
-
stop #explicitly stop the thread so that the stop occur automatically along with queue operations.
|
61
|
-
return true #indicates to thread worker that we are done executing since the queue is empty
|
62
|
-
}
|
67
|
+
return false #indicates to thread worder that we are not done executing
|
63
68
|
end
|
64
69
|
|
65
70
|
def flush(timeout = 1)
|
66
|
-
|
71
|
+
ensure_worker_is_running
|
67
72
|
wait_for_worker_to_clear_queue(timeout)
|
68
73
|
fallback_flush_to_stderr if @queue.size > 0
|
69
74
|
end
|
@@ -109,6 +114,10 @@ module SoarAuditingProvider
|
|
109
114
|
$stderr.puts "#{notification}: #{message}"
|
110
115
|
end
|
111
116
|
|
117
|
+
def ensure_worker_is_running
|
118
|
+
start(verbose: true)
|
119
|
+
end
|
120
|
+
|
112
121
|
def ensure_worker_is_stopped
|
113
122
|
attempt_graceful_stop
|
114
123
|
sleep_while_still_running(5)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soar_auditing_provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10-
|
12
|
+
date: 2016-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|