mysql-statsd 3.1 → 4.0

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: 33315d1d0830c9231d1e5a1caa378c571721035e
4
- data.tar.gz: fc0648c6053c4b5e767f12926624b52cc0bf04d7
3
+ metadata.gz: f0aee233c5b0179676b4567014475779ab2fb544
4
+ data.tar.gz: ea901f14ddbea761ca8976bc1f9b2ffc90810334
5
5
  SHA512:
6
- metadata.gz: 9e8adf89846ef5a0736a3abf97499d023bb219bb14d0767c72b3e84360c7f55130b31706061a1f677ec398a8254d6a0ee3f4e0eae5cfc4b3baa2b65a7e4f48cb
7
- data.tar.gz: f723ab5dc4d0cecad9bd11238a5a4b9b24852bc8caf59c82fc09a7ae76102f67bb69a3ca0a93e21051dc2db7a161c52e75aa373a1e5b9335972f196b4d0c4866
6
+ metadata.gz: 564e60ee1ea70ef7935fea84a833b30812e000db8e6642e1a41a2c674eb753c3c2e772d5c26156178da2805e4acb1585893e9c92c0940d3f25fd22ae46349d90
7
+ data.tar.gz: df2059889cf0a611801bacbcae932483765507b079b5f61f98f5c33bd5fd06b74396904942ea4d0055bf7b12c8b2848ba9c9902b7d3c77b8fea5b04a924c9f78
data/README.md CHANGED
@@ -15,6 +15,14 @@ Then copy config.yml.sample to a desired path and customize.
15
15
 
16
16
  mysql-statsd /path/to/config.yml
17
17
 
18
+ ## Tips
19
+
20
+ * You may want to configure StatsD to send the gauges as zero when not received:
21
+
22
+ deleteGauges: true
23
+
24
+ * If using Graphite, the derivate function is useful in gauges that only increment over time, for example threads_running
25
+
18
26
  ## Testing
19
27
 
20
28
  rspec spec
@@ -15,6 +15,7 @@ module Mysql
15
15
  def run!
16
16
  instrument_statuses
17
17
  instrument_process_list
18
+ instrument_queries
18
19
  end
19
20
 
20
21
  def statsd
@@ -37,6 +38,12 @@ module Mysql
37
38
  show("GLOBAL STATUS").each { |entry| statsd.gauge entry["Variable_name"].downcase, entry["Value"] }
38
39
  end
39
40
 
41
+ def instrument_queries
42
+ config['mysql']['queries'].map { |query| mysql.query(query).first }.compact.each do |entry|
43
+ statsd.gauge *entry.to_a.flatten
44
+ end
45
+ end
46
+
40
47
  def show(term)
41
48
  mysql.query "SHOW #{term}"
42
49
  end
@@ -1,5 +1,5 @@
1
1
  module Mysql
2
2
  module Statsd
3
- VERSION = "3.1"
3
+ VERSION = "4.0"
4
4
  end
5
5
  end
@@ -40,5 +40,11 @@ describe Mysql::Statsd::Runner do
40
40
  subject.statsd.should_receive(:gauge).with('command.jump', 2)
41
41
  subject.run!
42
42
  end
43
+
44
+ it "should query configured queries" do
45
+ subject.mysql.stub(:query).with("SELECT count(1) as 'users.count' from users").and_return [{'users.count' => 15}]
46
+ subject.statsd.should_receive(:gauge).with('users.count', 15)
47
+ subject.run!
48
+ end
43
49
  end
44
50
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.1'
4
+ version: '4.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Carrion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: statsd-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Picks data from MySQL and sends it to StatsD
@@ -60,7 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - .gitignore
63
+ - ".gitignore"
64
64
  - Gemfile
65
65
  - LICENSE.txt
66
66
  - README.md
@@ -70,6 +70,7 @@ files:
70
70
  - lib/mysql-statsd.rb
71
71
  - lib/mysql-statsd/version.rb
72
72
  - mysql-statsd.gemspec
73
+ - spec/config.yml
73
74
  - spec/runner_spec.rb
74
75
  homepage: ''
75
76
  licenses: []
@@ -80,19 +81,20 @@ require_paths:
80
81
  - lib
81
82
  required_ruby_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
- - - '>='
84
+ - - ">="
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
- - - '>='
89
+ - - ">="
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 2.0.3
94
+ rubygems_version: 2.2.2
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: Picks data from MySQL and sends it to StatsD
97
98
  test_files:
99
+ - spec/config.yml
98
100
  - spec/runner_spec.rb