logjam_agent 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/logjam_agent.rb
CHANGED
@@ -87,4 +87,25 @@ module LogjamAgent
|
|
87
87
|
EOS
|
88
88
|
end
|
89
89
|
|
90
|
+
def self.event(label, extra_fields = {})
|
91
|
+
logjam_fields = {
|
92
|
+
:label => label,
|
93
|
+
:started_at => Time.now.iso8601,
|
94
|
+
:host => hostname
|
95
|
+
}
|
96
|
+
logjam_fields.merge!(extra_fields)
|
97
|
+
|
98
|
+
json_message = Oj.dump(logjam_fields, :format => :compat)
|
99
|
+
forwarder.forward(json_message, :routing_key => events_routing_key)
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def self.events_routing_key
|
105
|
+
"events.#{application_name}.#{environment_name}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.forwarder
|
109
|
+
@forwarder ||= Forwarders.get(application_name, environment_name)
|
110
|
+
end
|
90
111
|
end
|
@@ -23,12 +23,14 @@ module LogjamAgent
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# TODO: mutex!
|
26
|
-
def forward(msg,
|
26
|
+
def forward(msg, options = {})
|
27
27
|
return if paused? || LogjamAgent.disabled
|
28
28
|
begin
|
29
29
|
# $stderr.puts msg
|
30
|
-
key = @config[:routing_key]
|
31
|
-
|
30
|
+
key = options[:routing_key] || @config[:routing_key]
|
31
|
+
if engine = options[:engine]
|
32
|
+
key += ".#{engine}"
|
33
|
+
end
|
32
34
|
exchange.publish(msg, :key => key, :persistent => false)
|
33
35
|
rescue Exception => exception
|
34
36
|
reraise_expectation_errors!
|
data/lib/logjam_agent/request.rb
CHANGED
@@ -41,7 +41,7 @@ module LogjamAgent
|
|
41
41
|
|
42
42
|
def forward
|
43
43
|
engine = @fields.delete(:engine)
|
44
|
-
@forwarder.forward(encode_payload, engine)
|
44
|
+
@forwarder.forward(encode_payload, :engine => engine)
|
45
45
|
rescue Exception => e
|
46
46
|
handle_forwarding_error(e)
|
47
47
|
end
|
@@ -52,7 +52,7 @@ module LogjamAgent
|
|
52
52
|
def encode_payload
|
53
53
|
Oj.dump(@fields, :mode => :compat)
|
54
54
|
rescue
|
55
|
-
@fields.
|
55
|
+
@fields.to_json
|
56
56
|
end
|
57
57
|
else
|
58
58
|
def encode_payload
|
data/lib/logjam_agent/version.rb
CHANGED
@@ -56,11 +56,13 @@ module LogjamAgent
|
|
56
56
|
@socket = nil
|
57
57
|
end
|
58
58
|
|
59
|
-
def forward(msg,
|
59
|
+
def forward(msg, options={})
|
60
60
|
return if LogjamAgent.disabled
|
61
61
|
begin
|
62
|
-
key = @config[:routing_key]
|
63
|
-
|
62
|
+
key = options[:routing_key] || @config[:routing_key]
|
63
|
+
if engine = options[:engine]
|
64
|
+
key += ".#{engine}"
|
65
|
+
end
|
64
66
|
publish(key, msg)
|
65
67
|
rescue Exception => exception
|
66
68
|
reraise_expectation_errors!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stefan Kaes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-03-20 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|