logworm_amqp 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -1
- data/Rakefile +1 -1
- data/lib/base/db.rb +9 -5
- data/logworm_amqp.gemspec +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/base/db.rb
CHANGED
@@ -112,7 +112,10 @@ module Logworm
|
|
112
112
|
def get_amqp_url()
|
113
113
|
if @amqp_url.nil? and (@last_attempt.nil? or (Time.now - @last_attempt) > RETRY_FREQUENCY)
|
114
114
|
begin
|
115
|
-
|
115
|
+
resp = db_call(:get, "#{host_with_protocol}/amqp_url")
|
116
|
+
@amqp_url = resp["url"]
|
117
|
+
@stats_freq = resp["stats_freq"]
|
118
|
+
puts "Found: #{@amqp_url}, #{@stats_freq}"
|
116
119
|
Minion.amqp_url = @amqp_url
|
117
120
|
rescue
|
118
121
|
@last_attempt = Time.now
|
@@ -123,7 +126,8 @@ module Logworm
|
|
123
126
|
|
124
127
|
def to_amqp(queue, payload)
|
125
128
|
if get_amqp_url
|
126
|
-
|
129
|
+
content = payload.to_json
|
130
|
+
sig= signature(content, @token_secret )
|
127
131
|
Minion.enqueue(queue, {:payload => content, :consumer_key => @token, :signature => sig,
|
128
132
|
:env => ENV['RACK_ENV'] || "?", :timestamp => Time.now})
|
129
133
|
end
|
@@ -133,7 +137,7 @@ module Logworm
|
|
133
137
|
s = Time.now
|
134
138
|
yield if block_given?
|
135
139
|
record_stats((Time.now - s))
|
136
|
-
push_stats() if (rand(
|
140
|
+
push_stats() if (rand(@stats_freq || 0) == 1)
|
137
141
|
end
|
138
142
|
|
139
143
|
def record_stats(value)
|
@@ -144,7 +148,7 @@ module Logworm
|
|
144
148
|
end
|
145
149
|
|
146
150
|
def push_stats()
|
147
|
-
to_amqp("lw.stats", {:avg => (@total_time / @tock), :max => @amqp_max, :min => @amqp_min
|
151
|
+
to_amqp("lw.stats", {:avg => (@total_time / @tock), :max => @amqp_max, :min => @amqp_min})
|
148
152
|
reset_stats
|
149
153
|
end
|
150
154
|
|
@@ -155,7 +159,7 @@ module Logworm
|
|
155
159
|
|
156
160
|
def batch_log(entries)
|
157
161
|
recording_stats do
|
158
|
-
to_amqp("lw.logging", {:entries => entries
|
162
|
+
to_amqp("lw.logging", {:entries => entries})
|
159
163
|
end
|
160
164
|
end
|
161
165
|
|
data/logworm_amqp.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logworm_amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 7
|
10
|
+
version: 0.8.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pomelo, LLC
|