Sha256: a3f7accc72ddbaa81e2ae47b8267dcb3073c97adf484e16a1103808c1b9d7d12

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

module Mnemosyne
  module Middleware
    module Restify
      def call(request)
        if (trace = ::Mnemosyne::Instrumenter.current_trace)
          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.tap do |x|
            x.add_observer do |_, _response, _err|
              span.finish!
              trace << span
            end
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mnemosyne-ruby-1.1.0 lib/mnemosyne/middleware/restify.rb
mnemosyne-ruby-1.1.0.rc1 lib/mnemosyne/middleware/restify.rb