Sha256: da979f89cec342de0d94b06013e4862ddeca4991b9e1d7de77b92e590b558609

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module OpenTracing
  module Instrumentation
    module Thrift
      # Thrift processor trace operation name builder
      class TracedProcessorOperationNameBuilder
        DEFAULT_OPERATION_NAME_TEMPALTE = \
          'thrift_processor(%<name>s)'

        # @param operation_name_tempalte [String]
        def initialize(
          operation_name_template: DEFAULT_OPERATION_NAME_TEMPALTE
        )
          @operation_name_template = operation_name_template
        end

        # @param name [String] method name
        # @param type [Integer] type of message
        # @param seq_id [Integer] numberr of message
        # @return [String] operation name
        def build(name, type, seq_id)
          format_args = build_format_args(name, type, seq_id)
          format(operation_name_template, **format_args)
        end

        private

        attr_reader :operation_name_template

        def build_format_args(name, type, seq_id)
          {
            name: name,
            type: MESSAGE_TYPES[type],
            seq_id: seq_id,
          }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opentracing-instrumentation-0.2.1 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
opentracing-instrumentation-0.2.0 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
opentracing-instrumentation-0.1.18 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
opentracing-instrumentation-0.1.17 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
opentracing-instrumentation-0.1.16 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
opentracing-instrumentation-0.1.15 lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb