67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/new_relic/agent/instrumentation/bunny/instrumentation.rb', line 67
def pop_with_tracing
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
begin
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
msg = yield
delivery_info, message_properties, _payload = msg
rescue StandardError => error
bunny_error = error
end
begin
exch_name, exch_type = if delivery_info
[exchange_name(delivery_info.exchange),
exchange_type(delivery_info, channel)]
else
[exchange_name(NewRelic::EMPTY_STR),
exchange_type({}, channel)]
end
segment = NewRelic::Agent::Messaging.start_amqp_consume_segment(
library: LIBRARY,
destination_name: exch_name,
delivery_info: (delivery_info || {}),
message_properties: (message_properties || {headers: {}}),
exchange_type: exch_type,
queue_name: name,
start_time: t0
)
rescue => e
NewRelic::Agent.logger.error('Error starting message broker segment in Bunny::Queue#pop', e)
else
if bunny_error
segment.notice_error(bunny_error)
raise bunny_error
end
ensure
::NewRelic::Agent::Transaction::Segment.finish(segment)
end
msg
end
|