logworm_amqp 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/lib/base/db.rb +42 -10
- data/logworm_amqp.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/base/db.rb
CHANGED
@@ -28,10 +28,11 @@ module Logworm
|
|
28
28
|
@consumer_key, @consumer_secret, @host, @token, @token_secret = match[1..5]
|
29
29
|
@connection = OAuth::AccessToken.new(OAuth::Consumer.new(@consumer_key, @consumer_secret), @token, @token_secret)
|
30
30
|
Minion.amqp_url = "amqp://logworm-producer:4tX.z.rC@pomelo-1.dotcloud.com/"
|
31
|
-
|
32
|
-
|
33
|
-
@
|
34
|
-
|
31
|
+
@current_day = Time.now.yday
|
32
|
+
@total_time = 0
|
33
|
+
@tock = 0
|
34
|
+
@amqp_min = 500
|
35
|
+
@amqp_max = 0
|
35
36
|
end
|
36
37
|
|
37
38
|
def self.with_tokens(token, token_secret)
|
@@ -111,26 +112,57 @@ module Logworm
|
|
111
112
|
|
112
113
|
def set_minion_url()
|
113
114
|
#updates amqp_url potentially once a day.
|
114
|
-
|
115
|
-
day_now = current_time.yday
|
115
|
+
day_now = Time.now.yday
|
116
116
|
if day_now != @current_day
|
117
|
-
|
117
|
+
url = nil
|
118
|
+
begin
|
119
|
+
res = db_call(:get, "#{host_with_protocol}/amqp_url")
|
120
|
+
url = res["url"] if res and res["url"]
|
121
|
+
rescue Exception
|
122
|
+
end
|
123
|
+
Minion.amqp_url = url if !url.nil?
|
118
124
|
@current_day = day_now
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
128
|
+
def amqp_avg_set(value)
|
129
|
+
#min and max can be the same target value if method is only used once.
|
130
|
+
if value > @amqp_max
|
131
|
+
@amqp_max = value
|
132
|
+
end
|
133
|
+
if value < @amqp_min
|
134
|
+
@amqp_min = value
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def push_stats()
|
139
|
+
if (rand(300) == 1) #and @tock > 0 --> don't need to worry about this since tock is always incremented at least once before ever using as a divsor
|
140
|
+
average = @total_time / @tock
|
141
|
+
tstamp = Time.now
|
142
|
+
Minion.enqueue("lw.stats", {:avg => average, :stamp => tstamp,
|
143
|
+
:max => @amqp_max, :min => @amqp_min, :max => @amqp_max, :total => @total_time })
|
144
|
+
@total_time = 0
|
145
|
+
@tock = 0
|
146
|
+
@amqp_max = 0
|
147
|
+
@amqp_min = 500
|
148
|
+
end
|
149
|
+
end
|
122
150
|
|
123
151
|
def batch_log(entries)
|
124
152
|
#db_call(:post, "#{host_with_protocol}/log", {:entries => $lr_queue.to_json})
|
125
153
|
content = $lr_queue.to_json
|
126
154
|
sig= signature(content, @token_secret )
|
127
155
|
set_minion_url()
|
128
|
-
|
156
|
+
s = Time.now
|
157
|
+
Minion.enqueue("lw.logging", {:entries => content, :consumer_key => @token, :signature => sig })
|
158
|
+
elapse = (Time.now - s)
|
159
|
+
@total_time += elapse
|
160
|
+
@tock += 1
|
161
|
+
amqp_avg_set(elapse)
|
162
|
+
push_stats()
|
129
163
|
end
|
130
164
|
|
131
165
|
|
132
|
-
|
133
|
-
|
134
166
|
private
|
135
167
|
def db_call(method, uri, params = {})
|
136
168
|
begin
|
data/logworm_amqp.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{logworm_amqp}
|
5
|
-
s.version = "0.8.
|
5
|
+
s.version = "0.8.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pomelo, LLC"]
|
9
|
-
s.date = %q{2010-08-
|
9
|
+
s.date = %q{2010-08-04}
|
10
10
|
s.description = %q{logworm logging tool}
|
11
11
|
s.email = %q{schapira@pomelollc.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "README.md", "lib/base/config.rb", "lib/base/db.rb", "lib/base/query_builder.rb", "lib/logworm_amqp.rb"]
|
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: 53
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 5
|
10
|
+
version: 0.8.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pomelo, LLC
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-04 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|