statsd 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,7 +10,7 @@ A network daemon for aggregating statistics (counters and timers), rolling them
10
10
 
11
11
  ### Configuration
12
12
 
13
- Create config.yml to your liking. There are 2 flush protocols: graphite and mongo. The former simple sends to carbon every flush interval. The latter flushes to MongoDB capped collections for 10s and 1min intervals.
13
+ Create config.yml to your liking. There are 2 flush protocols: graphite and mongo. The former simply sends to carbon every flush interval. The latter flushes to MongoDB capped collections for 10s and 1min intervals.
14
14
 
15
15
  Example config.yml
16
16
  ---
@@ -30,7 +30,7 @@ Example config.yml
30
30
 
31
31
  # If you change these, you need to delete the capped collections yourself!
32
32
  # Average mongo record size is 152 bytes
33
- # 10s or 1min data is transient so we'll use MongoDB's capped collections. These collections are fixed in size.
33
+ # 10s and 1min data is transient so we'll use MongoDB's capped collections. These collections are fixed in size.
34
34
  # 5min and 1d data is interesting to preserve long-term. These collections are not capped.
35
35
  retentions:
36
36
  - name: stats_per_10s
@@ -141,12 +141,18 @@ That translates to:
141
141
  This has been a good tradeoff so far between size-of-file (round robin databases are fixed size) and data we care about. Each "stats" database is about 3.2 megs with these retentions.
142
142
 
143
143
 
144
+ MongoDB
145
+ -------------
146
+
147
+ Statd::Mongo will flush and aggregate data to a MongoDB. The average record size is 152 bytes. We use capped collections for the transient data and regular collections for long-term storage.
148
+
144
149
  Inspiration
145
150
  -----------
151
+ [Etsy's][etsy] [blog post][blog post].
146
152
 
147
153
  StatsD was inspired (heavily) by the project (of the same name) at Flickr. Here's a post where Cal Henderson described it in depth:
148
154
  [Counting and timing](http://code.flickr.com/blog/2008/10/27/counting-timing/). Cal re-released the code recently: [Perl StatsD](https://github.com/iamcal/Flickr-StatsD)
149
- Inspired by [Etsy's][etsy] [blog post][blog post].
155
+
150
156
 
151
157
  [graphite]: http://graphite.wikidot.com
152
158
  [etsy]: http://www.etsy.com
data/lib/statsd/mongo.rb CHANGED
@@ -92,9 +92,11 @@ module Statsd
92
92
  retentions[1..-1].each_with_index do |retention,index|
93
93
  # fine_stats_collection = db.collection(retentions[index]['name'])
94
94
  coarse_stats_collection = db.collection(retention['name'])
95
+ puts "Aggregating #{retention['name']}"
95
96
  step = retention['seconds']
96
97
  current_coarse_bucket = current_bucket / step * step - step
97
98
  previous_coarse_bucket = current_coarse_bucket - step
99
+ puts "#{Time.at(previous_coarse_bucket)}..#{Time.at(current_coarse_bucket)}"
98
100
  # Look up previous bucket
99
101
  if coarse_stats_collection.find({:ts => previous_coarse_bucket}).count == 0
100
102
  # Aggregate
@@ -102,7 +104,7 @@ module Statsd
102
104
  stats_to_aggregate = fine_stats_collection.find(
103
105
  {:ts => {"$gte" => previous_coarse_bucket, "$lt" => current_coarse_bucket}})
104
106
  rows = stats_to_aggregate.to_a
105
- count = stats_to_aggregate.count
107
+ count = rows.count
106
108
  rows.group_by {|r| r["stat"] }.each_pair do |name,stats|
107
109
  case stats.first['type']
108
110
  when 'timer'
@@ -132,9 +134,9 @@ module Statsd
132
134
  else
133
135
  raise "unknown type #{stats.first['type']}"
134
136
  end
135
- docs.push(doc)
137
+ docs.push(doc)
136
138
  end
137
- coarse_stats_collection.insert(docs)
139
+ coarse_stats_collection.insert(docs) unless docs.empty?
138
140
  end
139
141
  end
140
142
 
data/lib/statsd/server.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'erb'
4
4
  module Statsd
5
5
  module Server #< EM::Connection
6
- Version = '0.5.0'
6
+ Version = '0.5.2'
7
7
 
8
8
  FLUSH_INTERVAL = 10
9
9
  COUNTERS = {}
data/lib/statsd.rb CHANGED
@@ -62,9 +62,10 @@ module Statsd
62
62
  data.each do |d|
63
63
  sock.send(d, 0, host, port)
64
64
  end
65
- rescue # silent but deadly
65
+ rescue Exception => e # silent but deadly
66
+ puts e.message
66
67
  ensure
67
- sock.close
68
+ sock.try(:close)
68
69
  end
69
70
  true
70
71
  end
data/statsd.gemspec CHANGED
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.required_rubygems_version = ">= 1.3.6"
16
16
 
17
- s.add_dependency "eventmachine", "~> 0.12.10"
18
- s.add_dependency "mongo", "~> 1.2.4"
19
- s.add_dependency "erubis", "~> 2.6.6"
17
+ s.add_dependency "eventmachine", ">= 0.12.10"
18
+ s.add_dependency "mongo", ">= 1.2.4"
19
+ s.add_dependency "erubis", ">= 2.6.6"
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: statsd
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.5.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Coldham
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-02-25 00:00:00 -08:00
14
+ date: 2011-05-15 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirement: &id001 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
- - - ~>
23
+ - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 0.12.10
26
26
  type: :runtime
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirement: &id002 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
- - - ~>
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.2.4
37
37
  type: :runtime
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirement: &id003 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.6.6
48
48
  type: :runtime
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements: []
94
94
 
95
95
  rubyforge_project:
96
- rubygems_version: 1.5.2
96
+ rubygems_version: 1.6.2
97
97
  signing_key:
98
98
  specification_version: 3
99
99
  summary: Ruby version of statsd.