class Leafy::Rack::Metrics
Constants
- WRITER
Public Class Methods
new(app, registry, path = '/metrics')
click to toggle source
# File leafy-rack/lib/leafy/rack/metrics.rb, line 20 def initialize(app, registry, path = '/metrics') @app = app @path = path @registry = registry end
response( metrics, env )
click to toggle source
# File leafy-rack/lib/leafy/rack/metrics.rb, line 11 def self.response( metrics, env ) [ 200, { 'Content-Type' => 'application/json', 'Cache-Control' => 'must-revalidate,no-cache,no-store' }, [ WRITER.to_json( metrics, env[ 'QUERY_STRING' ] == 'pretty' ) ] ] end
Public Instance Methods
call(env)
click to toggle source
# File leafy-rack/lib/leafy/rack/metrics.rb, line 26 def call(env) if env['PATH_INFO'] == @path Metrics.response( @registry.metrics, env ) else @app.call( env ) end end