Module: Thrift::Metrics
- Defined in:
- lib/thrift/metrics.rb
Defined Under Namespace
Modules: Middleware
Constant Summary collapse
- MIDDLEWARES =
[Middleware::Timing, Middleware::Exception]
Class Method Summary collapse
Class Method Details
.client ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/thrift/metrics.rb', line 60 def client @client ||= begin if ENV['STATSD_URL'] ip, port = ENV['STATSD_URL'].split(':') Statsd.new ip, port.to_i else NullStatsd.new end end end |
.instrument(name, &block) ⇒ Object
54 55 56 57 58 |
# File 'lib/thrift/metrics.rb', line 54 def instrument(name, &block) MIDDLEWARES.reduce(block) do |acc, cur| Proc.new { cur.instrument(name) { acc.call } } end.call end |