Sha256: c4b83ab122f46bc6a1bc7dab56fdd3a4a06295cb2d8f14b67ca67cc2ed50b5e6
Contents?: true
Size: 1.15 KB
Versions: 10
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Mnemosyne module Probes module Restify module Base class Probe < ::Mnemosyne::Probe def setup ::Restify::Adapter::Base.prepend Instrumentation end module Instrumentation 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.meta[:status] = response.code trace << span.finish! end end else super end end end end end end register 'Restify::Adapter::Base', 'restify/adapter/base', Restify::Base::Probe.new end end
Version data entries
10 entries across 10 versions & 1 rubygems