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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7206a30bbf4d5e2c582cafb7e797654dcc88b64c
4
- data.tar.gz: 8dcccf75dabddc8a4951daa19a6a2392e9091cf1
3
+ metadata.gz: 42aacb27b1de008f048ef737649388ede58a7060
4
+ data.tar.gz: 8ed7ac6e359b29e47b59b37778cc7cb373c59106
5
5
  SHA512:
6
- metadata.gz: 3ac6485b4f6e46160e413df8011ff76562ec27fa44bc0ce6527b65e440ca620a8f6ee2131481f2854408b8392d93b66f6ca3599110205fa5c066453845cd2312
7
- data.tar.gz: 1563aa9481647d760cb59b226e7e86cf938c245450cf5f0ee931689e33add43b8b777a0fcb4a84f3f1fda6137a64211e22b72c0590d27d810aa4241c857c1f95
6
+ metadata.gz: 378d78170e3bc1a75691520bbe71969235295e2754362214643b0fad438667fa64ba2b1b23fd85ac3a839da6a90222b0bbefcabe128dcb924a2ddaaf3cda3714
7
+ data.tar.gz: a4045d4bddf3ac31e1b53f988979c0a69114eb6d494d8b5cfc2f43ca11bbf1fb0e2abdc78010acaf80af3bbc9be45124ea9ede55e75a75063f0ad7621623bccd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # SnowAgent
2
2
 
3
+ Version 0.0.3 - 2015.06.08
4
+ - Add `time` and `increment` metrics
5
+ - `async = true` by default
6
+
3
7
  Version 0.0.2 - 2015.02.22
4
8
  - Count only GET-requests
5
9
 
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/[my-github-username]/snowagent/fork )
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
- self.agent
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 = 1
27
- self.open_timeout = 1
26
+ self.read_timeout = 30
27
+ self.open_timeout = 30
28
28
 
29
- self.async = true
29
+ self.async = false
30
30
  end
31
31
 
32
32
  # Determines if the agent confiured to send metrics.
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SnowAgent
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-02-22 00:00:00.000000000 Z
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: