telemetry 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/bin/telemetryd +9 -0
- data/lib/telemetry/api.rb +25 -6
- data/lib/telemetry/version.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: 45ea2abcafe731aecd8eae54d263934874d88bb8
|
4
|
+
data.tar.gz: 657e9dbfd677fdfae1d90cfeb31c9bccbd3b0c4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91502bed54b2ce5004539adb8377f68750b2c8843817589ef7e79187275f82d9163e786572597aabec44f643b5d1dd8733ad949a5d369c5c0ac1c5db54a46913
|
7
|
+
data.tar.gz: 09d06b7e9ea6dda84f1ab49a21ab219f072f786dbf1facb3406126fd1f9c035d436f5b4fab79b4928b0c717ed1bad49ad62d481b875dd68327eba51bc6128036
|
data/README.md
CHANGED
@@ -130,7 +130,23 @@ An example of code to do this would be:
|
|
130
130
|
flow = Telemetry::Value.new(tag: "test-flow-value", value: 3434)
|
131
131
|
Telemetry::Api.affiliate_send("affiliate-identifier", flow)
|
132
132
|
|
133
|
-
For more information see the [affiliate documentation](https://admin.telemetryapp.com/documentation/affiliates).
|
133
|
+
For more information see the [affiliate documentation](https://admin.telemetryapp.com/user/documentation/affiliates).
|
134
|
+
|
135
|
+
## Aggregations
|
136
|
+
|
137
|
+
This gem supports the aggregations API interface. Aggregations allow you to send data point by point and have Telemetry aggregate the data for you. The gem supports the following methods:
|
138
|
+
|
139
|
+
- Telemetry::Api.aggregate(bucket, value)
|
140
|
+
- Telemetry::Api.aggregate_set_interval(bucket, interval, values)
|
141
|
+
|
142
|
+
An example of code to do this would be:
|
143
|
+
|
144
|
+
require 'telemetry'
|
145
|
+
|
146
|
+
Telemetry.token = "test-api-token"
|
147
|
+
Telemetry::Api.aggregate("my-bucket", 23124)
|
148
|
+
|
149
|
+
For more infromation see the [aggregations documentation](https://admin.telemetryapp.com/user/documentation/aggregations)
|
134
150
|
|
135
151
|
## Daemon
|
136
152
|
|
data/bin/telemetryd
CHANGED
@@ -18,6 +18,9 @@ runner.with_options do |opts|
|
|
18
18
|
opts.on("-o", "--once", "Run once") do |o|
|
19
19
|
options[:once] = o
|
20
20
|
end
|
21
|
+
opts.on("-l", "--logfile PATH", "Log to a logfile") do |l|
|
22
|
+
options[:logfile] = l
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
runner.execute do |opts|
|
@@ -33,6 +36,9 @@ runner.execute do |opts|
|
|
33
36
|
exit
|
34
37
|
end
|
35
38
|
|
39
|
+
Telemetry::logfile = opts[:logfile] if opts[:logfile]
|
40
|
+
Telemetry::logger.info "Starting telemetryd"
|
41
|
+
|
36
42
|
# Loop Forever
|
37
43
|
loop do
|
38
44
|
start_timestamp = Time.now.to_f
|
@@ -50,12 +56,15 @@ runner.execute do |opts|
|
|
50
56
|
sleep 3600
|
51
57
|
|
52
58
|
rescue Telemetry::AuthenticationFailed => e
|
59
|
+
Telemetry::logger.error "Authentication Failed, Exiting"
|
53
60
|
raise e
|
54
61
|
|
55
62
|
rescue Telemetry::AuthorizationError => e
|
63
|
+
Telemetry::logger.error "Authorization Failed, Exiting"
|
56
64
|
raise e
|
57
65
|
|
58
66
|
rescue Telemetry::FormatError => e
|
67
|
+
Telemetry::logger.error "Format Error, Exiting"
|
59
68
|
raise e
|
60
69
|
|
61
70
|
rescue Exception => e
|
data/lib/telemetry/api.rb
CHANGED
@@ -31,6 +31,11 @@ module Telemetry
|
|
31
31
|
@api_host
|
32
32
|
end
|
33
33
|
|
34
|
+
def self.logfile=(logfile)
|
35
|
+
@logger = Logger.new(logfile)
|
36
|
+
@logger.level = Logger::INFO
|
37
|
+
end
|
38
|
+
|
34
39
|
def self.logger=(logger)
|
35
40
|
@logger = logger
|
36
41
|
end
|
@@ -41,9 +46,9 @@ module Telemetry
|
|
41
46
|
if ENV['RACK_ENV'] == 'development'
|
42
47
|
@logger.level = Logger::DEBUG
|
43
48
|
else
|
44
|
-
@logger.level = Logger::
|
49
|
+
@logger.level = Logger::INFO
|
45
50
|
end
|
46
|
-
end
|
51
|
+
end
|
47
52
|
@logger
|
48
53
|
end
|
49
54
|
|
@@ -85,6 +90,16 @@ module Telemetry
|
|
85
90
|
Telemetry::Api.send(:delete, "/flows/#{id}/data")
|
86
91
|
end
|
87
92
|
|
93
|
+
def self.aggregate(bucket, value)
|
94
|
+
raise Telemetry::AuthenticationFailed, "Please set your Telemetry.token" unless Telemetry.token
|
95
|
+
return Telemetry::Api.send(:post, "/aggregations/#{bucket}", {:value => value})
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.aggregate_set_interval(bucket, interval, values)
|
99
|
+
raise Telemetry::AuthenticationFailed, "Please set your Telemetry.token" unless Telemetry.token
|
100
|
+
return Telemetry::Api.send(:put, "/aggregations/#{bucket}/interval/#{interval}", {:value => value})
|
101
|
+
end
|
102
|
+
|
88
103
|
def self.channel_send_batch(channel_tag, flows)
|
89
104
|
raise Telemetry::AuthenticationFailed, "Please set your Telemetry.token" unless Telemetry.token
|
90
105
|
raise RuntimeError, "Must supply flows to send" unless flows
|
@@ -190,11 +205,15 @@ module Telemetry
|
|
190
205
|
|
191
206
|
case response.code
|
192
207
|
when "200"
|
193
|
-
|
194
|
-
|
208
|
+
rj = MultiJson.load(response.body)
|
209
|
+
Telemetry::logger.info "Updated: #{rj['updated'].join(', ')}" if rj && rj['updated'] && rj['updated'].count > 0
|
210
|
+
Telemetry::logger.info "Skipped: #{rj['skipped'].join(', ')}" if rj && rj['skipped'] && rj['skipped'].count > 0
|
211
|
+
return rj
|
195
212
|
when "201"
|
196
|
-
|
197
|
-
|
213
|
+
rj = MultiJson.load(response.body)
|
214
|
+
Telemetry::logger.info "Updated: #{rj['updated'].join(', ')}" if rj && rj['updated'] && rj['updated'].count > 0
|
215
|
+
Telemetry::logger.info "Skipped: #{rj['skipped'].join(', ')}" if rj && rj['skipped'] && rj['skipped'].count > 0
|
216
|
+
return rj
|
198
217
|
when "204"
|
199
218
|
return "No Body"
|
200
219
|
when "400"
|
data/lib/telemetry/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telemetry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- W. Gersham Meharg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|