Class: Mnemosyne::Middleware::Acfs

Inherits:
Object
  • Object
show all
Defined in:
lib/mnemosyne/middleware/acfs.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Acfs

Returns a new instance of Acfs.



6
7
8
# File 'lib/mnemosyne/middleware/acfs.rb', line 6

def initialize(app, *)
  @app = app
end

Instance Method Details

#call(request) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mnemosyne/middleware/acfs.rb', line 10

def call(request)
  trace = ::Mnemosyne::Instrumenter.current_trace

  if trace
    span = ::Mnemosyne::Span.new('external.http.acfs',
      meta: extract_meta(request))

    span.start!

    request.headers['X-Mnemosyne-Transaction'] = trace.transaction
    request.headers['X-Mnemosyne-Origin'] = span.uuid

    request.on_complete do |response, nxt|
      span.finish!
      trace << span

      nxt.call(response)
    end
  end

  @app.call(request)
end