class OpenTracing::Instrumentation::Thrift::TracedProtocolTagsBuilder

TagsBuilder for TracedProtocol

Constants

METHOD_PART
NAME_PATTER
SERVICE_NAME_PART

Public Instance Methods

==(other) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 28
def ==(other)
  self.class == other.class
end
build_message_tags(name, type) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 10
def build_message_tags(name, type)
  service_name, method = parse_message_name(name)
  {
    'thrift.method' => method,
    'thrift.service_name' => service_name,
    'thrift.multiplexed' => !service_name.nil?,
    'thrift.type' => MESSAGE_TYPES[type],
  }.merge(error_tags(type))
end
build_protocol_tags(protocol) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 20
def build_protocol_tags(protocol)
  transport = protocol.trans
  {
    'thrift.protocol' => build_protocol_name(protocol),
    'thrift.transport' => build_transport_name(transport),
  }
end

Private Instance Methods

build_protocol_name(protocol) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 45
def build_protocol_name(protocol)
  protocol.class.to_s
end
build_transport_name(transport) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 49
def build_transport_name(transport)
  inner_transport = transport.instance_variable_get(:@transport)

  if inner_transport
    inner_transport_name = build_transport_name(inner_transport)
    "#{transport.class}(#{inner_transport_name})"
  else
    transport.class.to_s
  end
end
error_tags(type) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 60
def error_tags(type)
  return {} if type != ::Thrift::MessageTypes::EXCEPTION

  {
    'error' => true,
  }
end
parse_message_name(name) click to toggle source
# File lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb, line 38
def parse_message_name(name)
  name_matches = NAME_PATTER.match(name)
  method = name_matches[METHOD_PART]
  service_name = name_matches[SERVICE_NAME_PART]
  [service_name, method]
end