Sha256: 639a4988dfc4f09e50f7e58d3f8967e4857d1eaf616960f54ba631c2a1cefda8

Contents?: true

Size: 700 Bytes

Versions: 1

Compression:

Stored size: 700 Bytes

Contents

module ILove
  module Tracing
    module IncomingRequests
      class TraceRackMiddleware
        def initialize(app)
          @app = app
        end

        def call(env)
          extracted_ctx = OpenTracing.global_tracer.extract(OpenTracing::FORMAT_RACK, env)
          span = OpenTracing.start_span('incoming http request', child_of: extracted_ctx)
          scope = OpenTracing.scope_manager.activate span

          @app.call(env)
        ensure
          scope.close
        end
      end


      def self.setup(cfg)
        raise 'incoming requests tracing requires rails' unless defined?(Rails)

        Rails.application.middleware.unshift TraceRackMiddleware
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ilove-tracing-0.2.0 lib/ilove/tracing/incoming_requests.rb