mysql-statsd 3.0 → 3.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: 60c44d6868a4e8bb040d294554b41de7dd8587f2
4
- data.tar.gz: 49adbedfb43619aaefe16dfe3c0709a31ab32ee8
3
+ metadata.gz: 33315d1d0830c9231d1e5a1caa378c571721035e
4
+ data.tar.gz: fc0648c6053c4b5e767f12926624b52cc0bf04d7
5
5
  SHA512:
6
- metadata.gz: 6554affeb5a2beb1ad891a96e2b937b56b0bd6f348ce843b1350f6152261a8b8bddcfc860efaff0272cdbe12c651330b21c9d7eb7fef84b6603b6c4188fa5896
7
- data.tar.gz: f6af0c38cf068ae98dab1cbcd74a61b24d9502d655acb609ec41082dd8068d1d508c739d1c868039f795536ecedb53a18a337543ff34437e97e9fb0e7a97b622
6
+ metadata.gz: 9e8adf89846ef5a0736a3abf97499d023bb219bb14d0767c72b3e84360c7f55130b31706061a1f677ec398a8254d6a0ee3f4e0eae5cfc4b3baa2b65a7e4f48cb
7
+ data.tar.gz: f723ab5dc4d0cecad9bd11238a5a4b9b24852bc8caf59c82fc09a7ae76102f67bb69a3ca0a93e21051dc2db7a161c52e75aa373a1e5b9335972f196b4d0c4866
@@ -28,10 +28,9 @@ module Mysql
28
28
  private
29
29
 
30
30
  def instrument_process_list
31
- show("PROCESSLIST").each do |entry|
32
- statsd.increment metric("Command", entry)
33
- statsd.increment metric("State", entry)
34
- end
31
+ @process_list = show "PROCESSLIST"
32
+ instrument_processes "State"
33
+ instrument_processes "Command"
35
34
  end
36
35
 
37
36
  def instrument_statuses
@@ -42,8 +41,8 @@ module Mysql
42
41
  mysql.query "SHOW #{term}"
43
42
  end
44
43
 
45
- def metric(name, entry)
46
- "#{name}.#{entry[name].gsub(" ", "_")}".downcase
44
+ def instrument_processes(metric_name)
45
+ @process_list.map { |row| row[metric_name] }.group_by(&:to_s).each { |metric, values| statsd.gauge "#{metric_name}.#{metric.gsub(" ", "_")}".downcase, values.count }
47
46
  end
48
47
  end
49
48
  end
@@ -1,5 +1,5 @@
1
1
  module Mysql
2
2
  module Statsd
3
- VERSION = "3.0"
3
+ VERSION = "3.1"
4
4
  end
5
5
  end
@@ -34,9 +34,10 @@ describe Mysql::Statsd::Runner do
34
34
  end
35
35
 
36
36
  it "should instrument the process list" do
37
- subject.mysql.stub(:query).with("SHOW PROCESSLIST").and_return [{'Command' => 'Jump', 'State' => 'Long Lived'}]
38
- subject.statsd.should_receive(:increment).with('command.jump')
39
- subject.statsd.should_receive(:increment).with('state.long_lived')
37
+ subject.mysql.stub(:query).with("SHOW PROCESSLIST").and_return [{'Command' => 'Jump', 'State' => 'Long Lived'}, {'Command' => 'Jump', 'State' => 'Long Dead'}]
38
+ subject.statsd.should_receive(:gauge).with('state.long_lived', 1)
39
+ subject.statsd.should_receive(:gauge).with('state.long_dead', 1)
40
+ subject.statsd.should_receive(:gauge).with('command.jump', 2)
40
41
  subject.run!
41
42
  end
42
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.0'
4
+ version: '3.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Carrion