ocular 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ocular +1 -1
- data/lib/ocular/inputs/http_input.rb +1 -1
- data/lib/ocular/logging/kafka_logger.rb +29 -9
- data/lib/ocular/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b417bff05762b7e15a5dcc2dad418b5e31b224
|
4
|
+
data.tar.gz: fc7391ab1ac121832c29627712830a1447bca5e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b2d2092d6d8391456907c4323cd636bc73746840865c91fbbf5caff9ef6c12f04f1674993065d7fd0a1490e7f64d2a37812b6e71e230b352df4749c56881b78
|
7
|
+
data.tar.gz: 26d6329a5b56c07807e8125f6c3a9874c76721d71bd04d1bd64e5408a75262a87e75be2824c34ab06a76b39a904458b04538c57742fcc769e2cf8b14e88be84a
|
data/bin/ocular
CHANGED
@@ -590,7 +590,7 @@ class Ocular
|
|
590
590
|
|
591
591
|
@thread = Thread.new do
|
592
592
|
events_hander = @settings[:silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
|
593
|
-
server
|
593
|
+
server = ::Puma::Server.new(self, events_hander)
|
594
594
|
|
595
595
|
server.add_tcp_listener @settings[:host], @settings[:port]
|
596
596
|
server.min_threads = 0
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "kafka"
|
2
2
|
require "socket"
|
3
|
+
require "logger"
|
4
|
+
require "thread"
|
3
5
|
|
4
6
|
class Ocular
|
5
7
|
module Logging
|
@@ -14,16 +16,22 @@ class Ocular
|
|
14
16
|
if kafka != nil
|
15
17
|
@kafka = kafka
|
16
18
|
else
|
17
|
-
|
19
|
+
#logger = Logger.new(STDOUT)
|
20
|
+
#logger.level = Logger::DEBUG
|
21
|
+
#settings[:client][:logger] = logger
|
18
22
|
@kafka = Kafka.new(settings[:client])
|
19
23
|
end
|
20
24
|
@settings = settings
|
21
25
|
|
22
26
|
@producer = @kafka.producer
|
27
|
+
|
28
|
+
@semaphore = Mutex.new
|
23
29
|
end
|
24
30
|
|
25
31
|
def reconnect()
|
26
32
|
@kafka = Kafka.new(@settings[:client])
|
33
|
+
@producer = @kafka.producer
|
34
|
+
@semaphore = Mutex.new
|
27
35
|
end
|
28
36
|
|
29
37
|
def debug(message = nil, &block)
|
@@ -47,6 +55,10 @@ class Ocular
|
|
47
55
|
add(Severity::FATAL, message, @run_id, &block)
|
48
56
|
end
|
49
57
|
|
58
|
+
def deliver_messages
|
59
|
+
@producer.deliver_messages
|
60
|
+
end
|
61
|
+
|
50
62
|
def add(severity, message = nil, run_id = nil, &block)
|
51
63
|
severity ||= Severity::UNKNOWN
|
52
64
|
if severity < @level
|
@@ -62,8 +74,10 @@ class Ocular
|
|
62
74
|
end
|
63
75
|
|
64
76
|
begin
|
65
|
-
@
|
66
|
-
|
77
|
+
@semaphore.synchronize do
|
78
|
+
@producer.produce(@formatter.format_message(severity, Time.now, run_id, message), topic: @settings[:topic], partition_key: run_id)
|
79
|
+
deliver_messages()
|
80
|
+
end
|
67
81
|
rescue StandardError => e
|
68
82
|
STDERR.puts "Error on producing kafka message: #{e}"
|
69
83
|
STDERR.puts "Message was #{message}, stacktrace: #{e.backtrace.join("\n")}"
|
@@ -72,8 +86,10 @@ class Ocular
|
|
72
86
|
|
73
87
|
def log_event(property, value, run_id = nil)
|
74
88
|
begin
|
75
|
-
@
|
76
|
-
|
89
|
+
@semaphore.synchronize do
|
90
|
+
@producer.produce(@formatter.format_event(property, value, Time.now, run_id), topic: @settings[:topic], partition_key: run_id)
|
91
|
+
deliver_messages()
|
92
|
+
end
|
77
93
|
rescue StandardError => e
|
78
94
|
STDERR.puts "Error on producing kafka log_event: #{e}"
|
79
95
|
STDERR.puts "#{property} => #{value}, stacktrace: #{e.backtrace.join("\n")}"
|
@@ -82,8 +98,10 @@ class Ocular
|
|
82
98
|
|
83
99
|
def log_cause(type, environment, run_id = nil)
|
84
100
|
begin
|
85
|
-
@
|
86
|
-
|
101
|
+
@semaphore.synchronize do
|
102
|
+
@producer.produce(@formatter.format_cause(type, environment, Time.now, run_id), topic: @settings[:topic], partition_key: run_id)
|
103
|
+
deliver_messages()
|
104
|
+
end
|
87
105
|
rescue StandardError => e
|
88
106
|
STDERR.puts "Error on producing kafka log_cause: #{e}"
|
89
107
|
STDERR.puts "type: #{type}, stacktrace: #{e.backtrace.join("\n")}"
|
@@ -93,8 +111,10 @@ class Ocular
|
|
93
111
|
|
94
112
|
def log_timing(key, value, run_id = nil)
|
95
113
|
begin
|
96
|
-
@
|
97
|
-
|
114
|
+
@semaphore.synchronize do
|
115
|
+
@producer.produce(@formatter.format_event("timing:" + key, value, Time.now, run_id), topic: @settings[:topic], partition_key: run_id)
|
116
|
+
deliver_messages()
|
117
|
+
end
|
98
118
|
rescue StandardError => e
|
99
119
|
STDERR.puts "Error on producing kafka log_timing: #{e}"
|
100
120
|
STDERR.puts "Timing: #{key} => #{value}, stacktrace: #{e.backtrace.join("\n")}"
|
data/lib/ocular/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocular
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juho Mäkinen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rye
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.3.
|
131
|
+
version: 0.3.15
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.3.
|
138
|
+
version: 0.3.15
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: mysql2
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|