Class: OpenTracing::Instrumentation::Thrift::TracedProtocol
- Inherits:
-
Thrift::BaseProtocol
- Object
- Thrift::BaseProtocol
- OpenTracing::Instrumentation::Thrift::TracedProtocol
- Extended by:
- Forwardable
- Includes:
- Thrift::ProtocolDecorator
- Defined in:
- lib/opentracing/instrumentation/thrift/traced_protocol.rb
Overview
TracedProtocol wrap any raw Thrift protocol instance. Not thread safe!
Usage (without multiplexed):
buffered_transport = ::Thrift::BufferedTransport.new(transport)
protocol = ::Thrift::BinaryProtocol.new(buffered_transport)
traced_protocol = \
OpenTracing::Instrumentation::Thrift::TracedProtocol.new(protocol)
Usage (multiplexed):
buffered_transport = ::Thrift::BufferedTransport.new(transport)
protocol = ::Thrift::BinaryProtocol.new(buffered_transport)
traced_protocol =
OpenTracing::Instrumentation::Thrift::TracedProtocol
.new(protocol)
multiplexed_protocol =
::Thrift::MultiplexedProtocol
.new(traced_protocol, 'OrderService')
Constant Summary collapse
- WRITE_DIRECTION =
'write'- READ_DIRECTION =
'read'
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(protocol, config: TracedProtocolConfig.new) {|@config| ... } ⇒ TracedProtocol
constructor
A new instance of TracedProtocol.
- #read_message_begin ⇒ Object
- #read_message_end ⇒ Object
- #write_message_begin(name, type, seqid) ⇒ Object
- #write_message_end ⇒ Object
Constructor Details
#initialize(protocol, config: TracedProtocolConfig.new) {|@config| ... } ⇒ TracedProtocol
Returns a new instance of TracedProtocol.
32 33 34 35 36 37 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 32 def initialize(protocol, config: TracedProtocolConfig.new) super(protocol) @config = config.dup yield @config if block_given? @protocol_tags = config..(protocol) end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 39 def ==(other) protocol == other.protocol && config == other.config && == other. end |
#read_message_begin ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 64 def start_time = Time.now.utc name, type, rseqid = super self.read_span = \ safe_start_span(READ_DIRECTION, name, type, start_time: start_time) [name, type, rseqid] end |
#read_message_end ⇒ Object
76 77 78 79 80 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 76 def super ensure safe_close_span(read_span) end |
#write_message_begin(name, type, seqid) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 45 def (name, type, seqid) self.write_span = \ safe_start_span(WRITE_DIRECTION, name, type) # Call protocol instaed super, beacaus ProtocolDecorator do not # pass arguments to protocol.write_message_begin protocol.(name, type, seqid) rescue StandardError => e write_error(write_span, e) safe_close_span(write_span) raise e end |
#write_message_end ⇒ Object
58 59 60 61 62 |
# File 'lib/opentracing/instrumentation/thrift/traced_protocol.rb', line 58 def super ensure safe_close_span(write_span) end |