Module: Protobuf::Opentracing::Extensions::Client

Included in:
Rpc::Client
Defined in:
lib/protobuf/rpc/extensions/client.rb

Instance Method Summary collapse

Instance Method Details

#operation_nameObject



17
18
19
# File 'lib/protobuf/rpc/extensions/client.rb', line 17

def operation_name
  @operation_name ||= "RPC #{options[:service]}##{options[:method]}"
end

#send_requestObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/protobuf/rpc/extensions/client.rb', line 5

def send_request
  scope, span = start_span
  options[:tracing_span] = span
  super
ensure
  if scope
    scope.close
  else
    span.finish
  end
end

#start_spanObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/protobuf/rpc/extensions/client.rb', line 21

def start_span
  tags = {
    "span.kind" => "client",
    "component" => "Protobuf",
  }
  if ::OpenTracing.active_span
    [nil, ::OpenTracing.start_span(operation_name, :tags => tags)]
  else
    scope = ::OpenTracing.start_active_span(operation_name, :tags => tags)
    [scope, scope.span]
  end
end