class Protobuf::Opentracing::RequestDecoder
Attributes
app[R]
env[R]
Public Class Methods
new(app)
click to toggle source
# File lib/protobuf/opentracing/request_decoder.rb, line 6 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/protobuf/opentracing/request_decoder.rb, line 10 def call(env) operation = "RPC #{env.service_name}##{env.method_name}" headers = request_headers(env) parent = ::OpenTracing.extract(::OpenTracing::FORMAT_TEXT_MAP, headers) options = {} options[:child_of] = parent unless parent.nil? options[:tags] = { "span.kind" => "server", "component" => "Protobuf", } result = nil ::OpenTracing.start_active_span(operation, options) do result = app.call(env) end result end
request_headers(env)
click to toggle source
# File lib/protobuf/opentracing/request_decoder.rb, line 29 def request_headers(env) return nil if env.request_wrapper.nil? env.request_wrapper.headers.reduce({}) do |ctx, header| ctx[header.key] = header.value ctx end end