lib/mnemosyne/middleware/restify.rb in mnemosyne-ruby-1.0.1 vs lib/mnemosyne/middleware/restify.rb in mnemosyne-ruby-1.1.0.rc1

- old
+ new

@@ -1,25 +1,24 @@ # frozen_string_literal: true module Mnemosyne module Middleware module Restify - # rubocop:disable Metrics/MethodLength def call(request) if (trace = ::Mnemosyne::Instrumenter.current_trace) - meta = {url: request.uri, method: request.method} + meta = {url: request.uri.to_s, method: request.method} span = ::Mnemosyne::Span.new('external.http.restify', meta: meta) span.start! request.headers['X-Mnemosyne-Transaction'] = trace.transaction request.headers['X-Mnemosyne-Origin'] = span.uuid - super.then do |response| - span.finish! - trace << span - - response + super.tap do |x| + x.add_observer do |_, _response, _err| + span.finish! + trace << span + end end else super end end