snowagent 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/snowagent.rb +13 -1
- data/lib/snowagent/configuration.rb +3 -3
- data/lib/snowagent/railtie.rb +0 -11
- data/lib/snowagent/service.rb +5 -1
- data/lib/snowagent/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42aacb27b1de008f048ef737649388ede58a7060
|
4
|
+
data.tar.gz: 8ed7ac6e359b29e47b59b37778cc7cb373c59106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 378d78170e3bc1a75691520bbe71969235295e2754362214643b0fad438667fa64ba2b1b23fd85ac3a839da6a90222b0bbefcabe128dcb924a2ddaaf3cda3714
|
7
|
+
data.tar.gz: a4045d4bddf3ac31e1b53f988979c0a69114eb6d494d8b5cfc2f43ca11bbf1fb0e2abdc78010acaf80af3bbc9be45124ea9ede55e75a75063f0ad7621623bccd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ TODO: Write usage instructions here
|
|
24
24
|
|
25
25
|
## Contributing
|
26
26
|
|
27
|
-
1. Fork it ( https://github.com/
|
27
|
+
1. Fork it ( https://github.com/snowman-io/snowagent/fork )
|
28
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/snowagent.rb
CHANGED
@@ -42,9 +42,21 @@ module SnowAgent
|
|
42
42
|
nil
|
43
43
|
end
|
44
44
|
|
45
|
+
def time(key)
|
46
|
+
start = Time.now
|
47
|
+
result = yield
|
48
|
+
metric(key, ((Time.now - start) * 1000).round, "time")
|
49
|
+
result
|
50
|
+
end
|
51
|
+
|
52
|
+
def increment(key, value = 1)
|
53
|
+
metric(key, value, "counter")
|
54
|
+
end
|
55
|
+
|
45
56
|
def configure
|
46
57
|
yield(configuration)
|
47
|
-
|
58
|
+
# do not trigger initialization if not configured
|
59
|
+
self.agent if configuration.configured?
|
48
60
|
end
|
49
61
|
end
|
50
62
|
end
|
@@ -23,10 +23,10 @@ module SnowAgent
|
|
23
23
|
self.secret_token = ENV['SNOWMANIO_SECRET_TOKEN']
|
24
24
|
self.send_interval = 15
|
25
25
|
|
26
|
-
self.read_timeout =
|
27
|
-
self.open_timeout =
|
26
|
+
self.read_timeout = 30
|
27
|
+
self.open_timeout = 30
|
28
28
|
|
29
|
-
self.async =
|
29
|
+
self.async = false
|
30
30
|
end
|
31
31
|
|
32
32
|
# Determines if the agent confiured to send metrics.
|
data/lib/snowagent/railtie.rb
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
# This module loading only for Rails apps
|
2
2
|
module SnowAgent
|
3
3
|
class Railtie < Rails::Railtie
|
4
|
-
initializer "snowagent.subscribe_notifications" do
|
5
|
-
ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
|
6
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
7
|
-
|
8
|
-
# Count only `html` GET requets
|
9
|
-
if event.payload[:method] == "GET" && event.payload[:format] == :html
|
10
|
-
duration = event.duration/1000.0
|
11
|
-
SnowAgent.metric("request", duration, :request)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
4
|
end
|
16
5
|
end
|
data/lib/snowagent/service.rb
CHANGED
@@ -10,7 +10,7 @@ module SnowAgent
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def post_data(payload)
|
13
|
-
req = Net::HTTP::Post.new("#{@uri.path}?#{@uri.query}")
|
13
|
+
req = Net::HTTP::Post.new("#{@uri.path}?#{@uri.query}", headers)
|
14
14
|
req.body = JSON.dump(payload.merge(token: @token))
|
15
15
|
size = req.body.length
|
16
16
|
|
@@ -29,5 +29,9 @@ module SnowAgent
|
|
29
29
|
|
30
30
|
http
|
31
31
|
end
|
32
|
+
|
33
|
+
def headers
|
34
|
+
{'Content-Type' =>'application/json'}
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/snowagent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snowagent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Vakhov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -98,4 +98,3 @@ signing_key:
|
|
98
98
|
specification_version: 4
|
99
99
|
summary: Send metrics to snowman
|
100
100
|
test_files: []
|
101
|
-
has_rdoc:
|