Module: OpenTelemetry::Instrumentation::Bunny::Patches::Channel

Defined in:
lib/opentelemetry/instrumentation/bunny/patches/channel.rb

Overview

The Channel module contains the instrumentation patch the Channel#basic_get, Channel#basic_publish and Channel#handle_frameset methods

Instance Method Summary collapse

Instance Method Details

#basic_get(queue, opts = { manual_ack: false }) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/opentelemetry/instrumentation/bunny/patches/channel.rb', line 13

def basic_get(queue, opts = { manual_ack: false })
  attributes = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.basic_attributes(self, connection, '', nil)

  tracer.in_span("#{queue} receive", attributes: attributes, kind: :consumer) do |span, _ctx|
    delivery_info, properties, payload = super

    return [delivery_info, properties, payload] unless delivery_info

    OpenTelemetry::Instrumentation::Bunny::PatchHelpers.trace_enrich_receive_span(span, self, delivery_info, properties)

    [delivery_info, properties, payload]
  end
end

#basic_publish(payload, exchange, routing_key, opts = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/opentelemetry/instrumentation/bunny/patches/channel.rb', line 27

def basic_publish(payload, exchange, routing_key, opts = {})
  OpenTelemetry::Instrumentation::Bunny::PatchHelpers.with_send_span(self, tracer, exchange, routing_key) do
    OpenTelemetry::Instrumentation::Bunny::PatchHelpers.inject_context_into_property(opts, :headers)

    super(payload, exchange, routing_key, opts)
  end
end

#handle_frameset(basic_deliver, properties, content) ⇒ Object

This method is called when rabbitmq pushes messages to subscribed consumers



36
37
38
39
40
# File 'lib/opentelemetry/instrumentation/bunny/patches/channel.rb', line 36

def handle_frameset(basic_deliver, properties, content)
  OpenTelemetry::Instrumentation::Bunny::PatchHelpers.trace_enrich_receive_span(OpenTelemetry::Trace.current_span, self, basic_deliver, properties) if basic_deliver

  super
end