statsman 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statsman/reporter_job.rb +40 -38
- data/lib/statsman/version.rb +1 -1
- data/lib/statsman.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d752188d03561e87022a85944cf218e4fa06b853
|
4
|
+
data.tar.gz: b28134db13fd3290a4a25f3ccc662d01e06c42e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a313c858001d4c7a00648bd76d59298dd0a34c381519b5880c8bcc865c34aec76dd387aec9a9523e79ca1eb4e9ef7200c560933166ea5462922e461ce060a0
|
7
|
+
data.tar.gz: 0f497b50cd46602827b9bb3e019ca0531bbae2603cc41200db829b57965d1d96c34b4a39c513f9c93d2a63e2bd06d7556ef59f634fb0063cd82deaee968d8664
|
@@ -3,43 +3,45 @@ require "sucker_punch"
|
|
3
3
|
require "openssl"
|
4
4
|
require "json"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
6
|
+
module Statsman
|
7
|
+
class ReporterJob
|
8
|
+
include SuckerPunch::Job
|
9
|
+
|
10
|
+
def perform(config, data_type, key, value, meta)
|
11
|
+
Statsman::Agent.log("ReporterJob sending data_type: #{data_type}, key: #{key}, value: #{value}, meta: #{meta}")
|
12
|
+
|
13
|
+
body = {
|
14
|
+
data_type: data_type,
|
15
|
+
key: key,
|
16
|
+
value: value,
|
17
|
+
meta: meta,
|
18
|
+
time: Time.now.to_i # Add timestamp to body to avoid replay attacks
|
19
|
+
}
|
20
|
+
|
21
|
+
url = "#{config.url}/stats"
|
22
|
+
|
23
|
+
resp = HTTParty.post(
|
24
|
+
"#{config.url}/stats",
|
25
|
+
headers: { "authorization" => request_auth_header(config, "/stats", body)},
|
26
|
+
body: body
|
27
|
+
)
|
28
|
+
Statsman::Agent.log("sent data_type: #{data_type}, key: #{key}, value: #{value}, meta: #{meta}, response: [#{resp.code}] #{resp.headers.inspect}")
|
29
|
+
|
30
|
+
rescue => e
|
31
|
+
Statsman::Agent.log("Exception sending data_type: #{data_type}, key: #{key}, value: #{value}, meta: #{meta}: #{e.message}\n#{e.backtrace.join("\n")}")
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def request_auth_header(config, path, body)
|
36
|
+
signature = request_signature(config, path, body)
|
37
|
+
"#{config.api_key}:#{signature}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def request_signature(config, path, body)
|
41
|
+
str = HTTParty::HashConversions.to_params(body)
|
42
|
+
to_sign = path + str
|
43
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), config.api_secret, to_sign)
|
44
|
+
end
|
45
|
+
|
37
46
|
end
|
38
|
-
|
39
|
-
def request_signature(config, path, body)
|
40
|
-
str = HTTParty::HashConversions.to_params(body)
|
41
|
-
to_sign = path + str
|
42
|
-
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), config.api_secret, to_sign)
|
43
|
-
end
|
44
|
-
|
45
47
|
end
|
data/lib/statsman/version.rb
CHANGED
data/lib/statsman.rb
CHANGED
@@ -61,7 +61,7 @@ module Statsman
|
|
61
61
|
|
62
62
|
def send_data(data_type, key, value, meta = {})
|
63
63
|
log("enqueueing data_type: #{data_type}, key: #{key}, value: #{value}, meta: #{meta.inspect}")
|
64
|
-
ReporterJob.new.async.perform(config, data_type, key, value, meta.to_json)
|
64
|
+
Statsman::ReporterJob.new.async.perform(config, data_type, key, value, meta.to_json)
|
65
65
|
end
|
66
66
|
|
67
67
|
end # Agent
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Emminger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sucker_punch
|