Sha256: 961d5d2545e7780dbcb31f46754bff410ed901a4b5c988fde008e8a42af27523

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

# Provides:
# * configurable agent
# * endpoint for accessing metrics JSON
# 
module Metrics
  module Integration
    module Rack
      class Endpoint
        
        attr_accessor :app, :options, :agent,
                      # integration metrics
                      :requests, :uncaught_exceptions,
                      :status_codes
        
        def initialize(options = {})
          @options  = options
          @agent    = @options.delete(:agent) || Agent.new
        end
        
        def call(_)
          body = @agent.to_json
          
          [ 200,
            { 'Content-Type'    => 'application/json',
              'Content-Length'  => body.size.to_s },
            [body]
          ]
        end
        
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-metrics-0.9.4 lib/ruby-metrics/integration/rack_endpoint.rb