statsd-default_instrumentation 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,13 +17,17 @@ Instrumentation
17
17
 
18
18
  **ActionController**
19
19
 
20
- * Count of controller actions grouped by response code. Example: controller.action.403
20
+ * Count of controller actions grouped by response code. Example: controllers.admin/users.create.200
21
21
 
22
22
  **MemCache**
23
23
 
24
+ Supported clients: memcache-client, memcached
25
+
24
26
  * Count of each operation. Example: memcache.set
25
- * Count of hits/misses for get operations as memcache.get.hit and memcache.get.miss
27
+ * Count of hits/misses for get operations as memcache.hit and memcache.miss
26
28
 
27
29
  **Redis**
28
30
 
29
- * Count and timing of each operation. Example: redis.get
31
+ Supported clients: redis-rb
32
+
33
+ * Count and timing of each operation. Example: redis.get.count, redis.get.time
@@ -1,9 +1,11 @@
1
- ActionController::Base.around_filter do |controller, action|
1
+ ApplicationController.around_filter do |controller, action|
2
2
  action.call
3
3
 
4
4
  # Record requests per response code
5
5
  StatsD.increment(
6
- [StatsD::DefaultInstrumentation.prefix,
6
+ [StatsD::DefaultInstrumentation.prefix,
7
+ 'controllers',
8
+ controller.params[:controller],
7
9
  controller.params[:action],
8
10
  controller.response.status.to_i].join('.'))
9
11
  end
@@ -1,14 +1,14 @@
1
1
  MemCache.class_eval do
2
2
  extend StatsD::Instrument
3
3
 
4
- [:decr, :incr, :cas, :add, :set].each do |method|
4
+ [:decr, :incr, :cas, :add, :set, :get, :replace, :append, :prepend, :delete].each do |method|
5
5
  statsd_count method, [StatsD::DefaultInstrumentation.prefix, "memcache", method].join('.')
6
6
  end
7
7
 
8
8
  def get_with_statsd(*args)
9
+ stat = [StatsD::DefaultInstrumentation.prefix, "memcache"].join('.')
10
+
9
11
  get_without_statsd(*args).tap do |result|
10
- stat = [StatsD::DefaultInstrumentation.prefix, "memcache", "get"].join('.')
11
- StatsD.increment stat
12
12
  StatsD.increment [stat, result.nil? ? 'miss' : 'hit'].join('.')
13
13
  end
14
14
  end
@@ -0,0 +1,20 @@
1
+ Memcached.class_eval do
2
+ extend StatsD::Instrument
3
+
4
+ [:decrement, :increment, :replace, :append, :prepend, :delete, :add, :set, :get].each do |method|
5
+ statsd_measure method, [StatsD::DefaultInstrumentation.prefix, "memcache", method].join('.')
6
+ end
7
+
8
+ def get_with_statsd(*args)
9
+ stat = [StatsD::DefaultInstrumentation.prefix, "memcache"].join('.')
10
+ get_without_statsd(*args).tap do |result|
11
+ StatsD.increment "#{stat}.hit"
12
+ end
13
+ rescue Memcached::NotFound
14
+ StatsD.increment "#{stat}.miss"
15
+ raise
16
+ end
17
+
18
+ alias_method :get_without_statsd, :get
19
+ alias_method :get, :get_with_statsd
20
+ end
@@ -10,7 +10,6 @@ Redis.class_eval do
10
10
  srem subscribe sunion sunionstore ttl type unsubscribe zadd zcard zcount zincrby zinterstore
11
11
  zrange zrangebyscore zrank zrem zremrangebyrank zremrangebyscore zrevrange zrevrangebyscore
12
12
  zrevrank zscore zunionstore).each do |method|
13
- statsd_count method.to_sym, [StatsD::DefaultInstrumentation.prefix, 'redis', method].join('.')
14
13
  statsd_measure method.to_sym, [StatsD::DefaultInstrumentation.prefix, 'redis', method].join('.')
15
14
  end
16
15
  end
@@ -2,7 +2,7 @@ module StatsD
2
2
  module DefaultInstrumentation
3
3
  module VERSION
4
4
  MAJOR = 0
5
- MINOR = 2
5
+ MINOR = 3
6
6
  PATCH = 0
7
7
 
8
8
  def self.to_s
@@ -7,8 +7,9 @@ module StatsD
7
7
  self.prefix = "default_instrumentation"
8
8
 
9
9
  def self.detect!
10
- require 'statsd/default_instrumentation/action_controller' if defined?(ActionController)
10
+ require 'statsd/default_instrumentation/action_controller' if defined?(ApplicationController)
11
11
  require 'statsd/default_instrumentation/memcache-client' if defined?(MemCache)
12
+ require 'statsd/default_instrumentation/memcached' if defined?(Memcached)
12
13
  require 'statsd/default_instrumentation/redis' if defined?(Redis)
13
14
  end
14
15
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsd-default_instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Griffin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-08 00:00:00 -05:00
18
+ date: 2011-11-09 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,7 @@ files:
47
47
  - lib/statsd/default_instrumentation.rb
48
48
  - lib/statsd/default_instrumentation/action_controller.rb
49
49
  - lib/statsd/default_instrumentation/memcache-client.rb
50
+ - lib/statsd/default_instrumentation/memcached.rb
50
51
  - lib/statsd/default_instrumentation/redis.rb
51
52
  - lib/statsd/default_instrumentation/version.rb
52
53
  has_rdoc: true