Class: OpenTracing::Instrumentation::Bunny::ConsumeTracer
- Inherits:
-
Object
- Object
- OpenTracing::Instrumentation::Bunny::ConsumeTracer
- Extended by:
- Forwardable
- Defined in:
- lib/opentracing/instrumentation/bunny/consume_tracer.rb
Overview
ConsumeTracer extract parent span from message headers and create span around passed block
Usage:
consumer_tracer = \
OpenTracing::Instrumentation::Bunny::ConsumeTracer.new
consumer_tracer = \
OpenTracing::Instrumentation::Bunny::ConsumeTracer.new do |config|
config.tracer = custom_tracer
end
queue.subscribe(block: true) do |delivery_info, properties, payload|
consume_tracer.consume(delivery_info, properties) do
end
end
Instance Method Summary collapse
-
#consume(delivery_info, properties) {|scope| ... } ⇒ OpenTracing::Scope?
Extract tracing parent from headers.
-
#initialize(config: ConsumeTracerConfig.new) {|config| ... } ⇒ ConsumeTracer
constructor
A new instance of ConsumeTracer.
Constructor Details
#initialize(config: ConsumeTracerConfig.new) {|config| ... } ⇒ ConsumeTracer
Returns a new instance of ConsumeTracer.
26 27 28 29 |
# File 'lib/opentracing/instrumentation/bunny/consume_tracer.rb', line 26 def initialize(config: ConsumeTracerConfig.new) yield config if block_given? @config = config end |
Instance Method Details
#consume(delivery_info, properties) {|scope| ... } ⇒ OpenTracing::Scope?
Extract tracing parent from headers. Create span with tags. If block passed, then span closed after block exit, otherwise return active scope.
without block, otherwise return block result
41 42 43 44 45 46 47 48 |
# File 'lib/opentracing/instrumentation/bunny/consume_tracer.rb', line 41 def consume(delivery_info, properties) span_scope = safe_start_active_span(delivery_info, properties) return span_scope unless block_given? handle_error(span_scope) do yield span_scope end end |