Class: Rack::Stats
- Inherits:
-
Object
- Object
- Rack::Stats
- Defined in:
- lib/rack/stats.rb,
lib/rack/stats/stat.rb,
lib/rack/stats/timer.rb,
lib/rack/stats/runtime.rb,
lib/rack/stats/version.rb
Defined Under Namespace
Modules: Stat Classes: Duration, Runtime, Timer
Constant Summary collapse
- DEFAULT_STATS =
[ { name: -> (*_args) { 'request_duration_global' }, value: -> (_req, d, _resp) { d.ms }, type: :timing }, { name: lambda do |req, _d, _resp| [ req.path.eql?('/') ? 'index' : \ req.path[1..-1].gsub(/\/\d+\//, '/id/') .gsub(/\/\d+$/, '/id') .gsub(/\//, '_'), req.request_method.downcase, 'request_duration' ] end, value: -> (_req, d, _resp) { d.ms }, type: :timing }, { name: -> (*_args) { 'request_number' }, type: :increment }, { name: lambda do |_req, _d, resp| ['request_number_status', "#{resp.status / 100}XX"] end, type: :increment } ]
- VERSION =
"0.0.5"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, args = {}) ⇒ Stats
constructor
A new instance of Stats.
Constructor Details
#initialize(app, args = {}) ⇒ Stats
Returns a new instance of Stats.
38 39 40 41 42 43 |
# File 'lib/rack/stats.rb', line 38 def initialize(app, args = {}) @app = app @namespace = args.fetch(:namespace, ENV['RACK_STATS_NAMESPACE']) @statsd = Statsd.new(*args.fetch(:statsd, '127.0.0.1:8125').split(':')) @stats = args.fetch(:stats, DEFAULT_STATS) end |