Module: Protobuf::Opentracing::Extensions::Base

Included in:
Rpc::Connectors::Base
Defined in:
lib/protobuf/rpc/extensions/base.rb

Instance Method Summary collapse

Instance Method Details

#request_fieldsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/protobuf/rpc/extensions/base.rb', line 5

def request_fields
  return super if options[:tracing_span].nil?

  trace_carrier = {}
  ::OpenTracing.inject(options[:tracing_span].context,
                       ::OpenTracing::FORMAT_TEXT_MAP,
                       trace_carrier)

  trace_headers = trace_carrier.map do |header|
    ::Protobuf::Socketrpc::Header.new(:key => header[0],
                                      :value => header[1])
  end

  fields = super
  headers = fields[:headers] || []
  fields[:headers] = headers + trace_headers
  fields
end