Sha256: ace9ce0db3cc1487ae571852289e80624b0193773165f1390a8e9cd9cc5dfbb4
Contents?: true
Size: 750 Bytes
Versions: 1
Compression:
Stored size: 750 Bytes
Contents
require 'statsd' module Rack class Graphite VERSION = '1.0.0' PREFIX = 'requests' def initialize(app, options={}) @app = app @prefix = options[:prefix] || PREFIX end def call(env) path = env['PATH_INFO'] || '/' method = env['REQUEST_METHOD'] || 'GET' metric = path_to_graphite(method, path) result = nil Statsd.instance.timing(metric) do result = @app.call(env) end return result end def path_to_graphite(method, path) method = method.downcase if (path.nil?) || (path == '/') || (path.empty?) "#{@prefix}.#{method}.root" else path = path.gsub('/', '.') "#{@prefix}.#{method}#{path}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-graphite-1.0.0 | lib/rack/graphite.rb |