mysql-statsd 4.0 → 4.1

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: f0aee233c5b0179676b4567014475779ab2fb544
4
- data.tar.gz: ea901f14ddbea761ca8976bc1f9b2ffc90810334
3
+ metadata.gz: 69e5a9b210509c0c97ea0936f69dd03254a98969
4
+ data.tar.gz: 978c04604ac3d370393e6e3927c7a21e0b35361d
5
5
  SHA512:
6
- metadata.gz: 564e60ee1ea70ef7935fea84a833b30812e000db8e6642e1a41a2c674eb753c3c2e772d5c26156178da2805e4acb1585893e9c92c0940d3f25fd22ae46349d90
7
- data.tar.gz: df2059889cf0a611801bacbcae932483765507b079b5f61f98f5c33bd5fd06b74396904942ea4d0055bf7b12c8b2848ba9c9902b7d3c77b8fea5b04a924c9f78
6
+ metadata.gz: 7a03863d9973e918f4ba057959056860d15145155a950db83388b9d61adf81ae72ed73ecb55605cd270ccf764630fda7753476e88b455c3fb9933106a093f167
7
+ data.tar.gz: 1270c45a07b93787b10059c7f17593863327898caebbabe08328b582f8c0612d94abb3d7a63409b7d3bb3fa77999f648fbf51a4fadea3983e18b1bfab43c9da5
data/README.md CHANGED
@@ -4,6 +4,18 @@ Sends data to StatsD from this queries:
4
4
 
5
5
  * SHOW GLOBAL STATUS
6
6
  * SHOW PROCESSLIST
7
+ * Custom
8
+
9
+ ## Custom Queries
10
+
11
+ Define them in the config file under mysql.queries . For example:
12
+
13
+ mysql:
14
+ ...
15
+ database: app_production
16
+ queries:
17
+ - SELECT count(1) as 'users.count' from users
18
+ - SELECT count(1) as 'premium_users.count' from users where premium = 1
7
19
 
8
20
  ## Installation
9
21
 
@@ -39,7 +39,7 @@ module Mysql
39
39
  end
40
40
 
41
41
  def instrument_queries
42
- config['mysql']['queries'].map { |query| mysql.query(query).first }.compact.each do |entry|
42
+ (config['mysql']['queries'] || []).map { |query| mysql.query(query).first }.compact.each do |entry|
43
43
  statsd.gauge *entry.to_a.flatten
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  module Mysql
2
2
  module Statsd
3
- VERSION = "4.0"
3
+ VERSION = "4.1"
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ mysql:
2
+ host: 'mysqlhost'
3
+ username: 'user'
4
+
5
+ statsd:
6
+ host: 'statsdhost'
7
+ namespace: 'ns'
@@ -1,7 +1,8 @@
1
1
  require 'mysql-statsd'
2
2
 
3
3
  describe Mysql::Statsd::Runner do
4
- subject { Mysql::Statsd::Runner.new "spec/config.yml" }
4
+ let(:config_path) { "spec/config.yml" }
5
+ subject { Mysql::Statsd::Runner.new config_path }
5
6
 
6
7
  before :each do
7
8
  Mysql2::Client.any_instance.stub :connect
@@ -46,5 +47,13 @@ describe Mysql::Statsd::Runner do
46
47
  subject.statsd.should_receive(:gauge).with('users.count', 15)
47
48
  subject.run!
48
49
  end
50
+
51
+ context "with a config file without queries" do
52
+ let(:config_path) { "spec/config_without_queries.yml" }
53
+
54
+ it "should not break" do
55
+ lambda { subject.run! }.should_not raise_exception
56
+ end
57
+ end
49
58
  end
50
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: '4.0'
4
+ version: '4.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Carrion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -71,6 +71,7 @@ files:
71
71
  - lib/mysql-statsd/version.rb
72
72
  - mysql-statsd.gemspec
73
73
  - spec/config.yml
74
+ - spec/config_without_queries.yml
74
75
  - spec/runner_spec.rb
75
76
  homepage: ''
76
77
  licenses: []
@@ -97,4 +98,5 @@ specification_version: 4
97
98
  summary: Picks data from MySQL and sends it to StatsD
98
99
  test_files:
99
100
  - spec/config.yml
101
+ - spec/config_without_queries.yml
100
102
  - spec/runner_spec.rb