Class: OpenTracing::Instrumentation::Thrift::TracedProtocolOperationNameBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/opentracing/instrumentation/thrift/traced_protocol_operation_name_builder.rb

Overview

Build operation name for TracedProtocol

Constant Summary collapse

DEFAULT_OPERATION_NAME_PATTERN =
'thrift(direction=%<direction>s, name=%<name>s, type=%<type>s)'

Instance Method Summary collapse

Constructor Details

#initialize(operation_name_pattern: DEFAULT_OPERATION_NAME_PATTERN) ⇒ TracedProtocolOperationNameBuilder

Returns a new instance of TracedProtocolOperationNameBuilder.

Parameters:

  • operation_name_pattern (String) (defaults to: DEFAULT_OPERATION_NAME_PATTERN)


14
15
16
17
18
# File 'lib/opentracing/instrumentation/thrift/traced_protocol_operation_name_builder.rb', line 14

def initialize(
  operation_name_pattern: DEFAULT_OPERATION_NAME_PATTERN
)
  @operation_name_pattern = operation_name_pattern
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
# File 'lib/opentracing/instrumentation/thrift/traced_protocol_operation_name_builder.rb', line 29

def ==(other)
  operation_name_pattern == other.operation_name_pattern
end

#build_operation_name(direction, name, type) ⇒ String

Returns formated operation name.

Parameters:

  • direction (String)

    should be ‘write’ or ‘read’

  • name (String)

    method name. Example: ‘Service:method’

  • type (Integer)

    message type, See ::Thrift::MessageTypes

Returns:

  • (String)

    formated operation name



24
25
26
27
# File 'lib/opentracing/instrumentation/thrift/traced_protocol_operation_name_builder.rb', line 24

def build_operation_name(direction, name, type)
  format_args = build_format_args(direction, name, type)
  format(operation_name_pattern, **format_args)
end