Class: Rack::Instrumentation::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/instrumentation/tracer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, tracer: OpenTracing.global_tracer) ⇒ Tracer

Create a new Rack Tracer middleware.

Parameters:

  • app

    The Rack application/middlewares stack.

  • tracer (OpenTracing::Tracer) (defaults to: OpenTracing.global_tracer)

    A tracer to be used when start_span, and extract is called.



14
15
16
17
# File 'lib/rack/instrumentation/tracer.rb', line 14

def initialize(app, tracer: OpenTracing.global_tracer)
  @app = app
  @tracer = tracer
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/rack/instrumentation/tracer.rb', line 7

def app
  @app
end

#tracerObject (readonly)

Returns the value of attribute tracer.



7
8
9
# File 'lib/rack/instrumentation/tracer.rb', line 7

def tracer
  @tracer
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
# File 'lib/rack/instrumentation/tracer.rb', line 19

def call(env)
  tracer.start_active_span(*span_args(env)) do |scope|
    trace_request(env, scope)
  end
end