Class: Aws::Xray::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/xray/rack.rb

Constant Summary collapse

TRACE_ENV =
'HTTP_X_AMZN_TRACE_ID'.freeze
ORIGINAL_TRACE_ENV =
'HTTP_X_AMZN_TRACE_ID_ORIGINAL'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, client_options: {}, excluded_paths: []) ⇒ Rack

Returns a new instance of Rack.

Parameters:

  • client_options (Hash) (defaults to: {})

    For xray-agent client.

    • host: e.g. ‘127.0.0.1’

    • port: e.g. 2000

    • sock: test purpose.

  • excluded_paths (Array<String,Regexp>) (defaults to: [])

    for health-check endpoints etc…



16
17
18
19
20
21
# File 'lib/aws/xray/rack.rb', line 16

def initialize(app, client_options: {}, excluded_paths: [])
  @app = app
  @name = Aws::Xray.config.name || raise(MissingNameError)
  @client = Client.new(Aws::Xray.config.client_options.merge(client_options))
  @excluded_paths = excluded_paths + Aws::Xray.config.excluded_paths
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/aws/xray/rack.rb', line 23

def call(env)
  if excluded_path?(env['PATH_INFO'])
    @app.call(env)
  else
    call_with_tracing(env)
  end
end