Class: Metrics::Integration::Rack::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-metrics/integration/rack_endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Endpoint

Returns a new instance of Endpoint.



15
16
17
18
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 15

def initialize(options ={})
  @options  = options
  @agent    = @options.delete(:agent) || Agent.new
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def agent
  @agent
end

#appObject

Returns the value of attribute app.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def app
  @app
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def options
  @options
end

#requestsObject

Returns the value of attribute requests.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def requests
  @requests
end

#status_codesObject

Returns the value of attribute status_codes.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def status_codes
  @status_codes
end

#uncaught_exceptionsObject

Returns the value of attribute uncaught_exceptions.



10
11
12
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 10

def uncaught_exceptions
  @uncaught_exceptions
end

Instance Method Details

#call(_) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/ruby-metrics/integration/rack_endpoint.rb', line 20

def call(_)
  body = @agent.to_json
  
  [ 200,
    { 'Content-Type'    => 'application/json',
      'Content-Length'  => body.size.to_s },
    [body]
  ]
end