newrelic_rpm 6.15.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -22
  3. data/README.md +2 -2
  4. data/lib/new_relic/agent.rb +0 -6
  5. data/lib/new_relic/agent/autostart.rb +1 -2
  6. data/lib/new_relic/agent/configuration/default_source.rb +270 -104
  7. data/lib/new_relic/agent/configuration/manager.rb +2 -2
  8. data/lib/new_relic/agent/datastores/redis.rb +0 -4
  9. data/lib/new_relic/agent/distributed_tracing.rb +0 -66
  10. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
  11. data/lib/new_relic/agent/instrumentation/bunny.rb +10 -152
  12. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
  13. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
  14. data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
  15. data/lib/new_relic/agent/instrumentation/curb.rb +9 -241
  16. data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
  17. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
  18. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
  19. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
  20. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
  21. data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
  22. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -50
  23. data/lib/new_relic/agent/instrumentation/excon.rb +2 -1
  24. data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
  25. data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
  26. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
  27. data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
  28. data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
  29. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
  30. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
  31. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
  32. data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
  33. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
  34. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
  35. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
  36. data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
  37. data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
  38. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
  39. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
  40. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
  41. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
  42. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -0
  43. data/lib/new_relic/agent/instrumentation/mongo.rb +7 -0
  44. data/lib/new_relic/agent/instrumentation/net_http.rb +39 -0
  45. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
  46. data/lib/new_relic/agent/instrumentation/{net_prepend.rb → net_http/instrumentation.rb} +3 -3
  47. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
  48. data/lib/new_relic/agent/instrumentation/padrino.rb +18 -53
  49. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
  50. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
  51. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
  52. data/lib/new_relic/agent/instrumentation/rack.rb +29 -139
  53. data/lib/new_relic/agent/instrumentation/rack/chain.rb +57 -0
  54. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
  55. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
  56. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +36 -0
  57. data/lib/new_relic/agent/instrumentation/rake.rb +13 -154
  58. data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
  59. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
  60. data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
  61. data/lib/new_relic/agent/instrumentation/redis.rb +10 -109
  62. data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
  63. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
  64. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
  65. data/lib/new_relic/agent/instrumentation/resque.rb +8 -28
  66. data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
  67. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +33 -0
  68. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
  69. data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -158
  70. data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
  71. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
  72. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +118 -0
  73. data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
  74. data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
  75. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
  76. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
  77. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
  78. data/lib/new_relic/agent/new_relic_service.rb +3 -12
  79. data/lib/new_relic/agent/sql_sampler.rb +1 -1
  80. data/lib/new_relic/agent/transaction.rb +1 -4
  81. data/lib/new_relic/control/frameworks/rails.rb +11 -9
  82. data/lib/new_relic/control/instance_methods.rb +1 -0
  83. data/lib/new_relic/dependency_detection.rb +116 -10
  84. data/lib/new_relic/noticed_error.rb +1 -5
  85. data/lib/new_relic/supportability_helper.rb +1 -2
  86. data/lib/new_relic/version.rb +2 -2
  87. data/newrelic_rpm.gemspec +1 -1
  88. metadata +53 -8
  89. data/cert/cacert.pem +0 -1177
  90. data/lib/new_relic/agent/instrumentation/http.rb +0 -49
  91. data/lib/new_relic/agent/instrumentation/net.rb +0 -70
@@ -23,7 +23,7 @@ module NewRelic
23
23
  end
24
24
 
25
25
  def has_key?(key)
26
- @cache.has_key?[key]
26
+ @cache.has_key? key
27
27
  end
28
28
 
29
29
  def keys
@@ -345,7 +345,7 @@ module NewRelic
345
345
  end
346
346
 
347
347
  def reset_cache
348
- @cache = Hash.new {|hash,key| hash[key] = self.fetch(key) }
348
+ @cache = Hash.new { |hash,key| hash[key] = self.fetch(key) }
349
349
  end
350
350
 
351
351
  def log_config(direction, source)
@@ -6,11 +6,7 @@ module NewRelic
6
6
  module Agent
7
7
  module Datastores
8
8
  module Redis
9
- MULTI_OPERATION = 'multi'
10
- PIPELINE_OPERATION = 'pipeline'
11
9
  BINARY_DATA_PLACEHOLDER = "<binary data>"
12
- PRODUCT_NAME = 'Redis'
13
- CONNECT = 'connect'
14
10
 
15
11
  MAXIMUM_COMMAND_LENGTH = 1000
16
12
  MAXIMUM_ARGUMENT_LENGTH = 64
@@ -24,72 +24,6 @@ module NewRelic
24
24
  extend NewRelic::SupportabilityHelper
25
25
  extend self
26
26
 
27
- # Create a payload object containing the current transaction's
28
- # tracing properties (e.g., duration, priority). You can use
29
- # this object to generate headers to inject into a network
30
- # request, so that the downstream service can participate in a
31
- # distributed trace.
32
- #
33
- # @return [DistributedTracePayload] Payload for the current
34
- # transaction, or +nil+ if we
35
- # could not create the payload
36
- #
37
- # @api public
38
- #
39
- # @deprecated See {#create_distributed_trace_headers} instead.
40
- #
41
- def create_distributed_trace_payload
42
- Deprecator.deprecate :create_distributed_trace_payload, :create_distributed_trace_headers
43
-
44
- unless Agent.config[:'distributed_tracing.enabled']
45
- NewRelic::Agent.logger.warn "Not configured to create New Relic distributed trace payload"
46
- return nil
47
- end
48
-
49
- return unless transaction = Transaction.tl_current
50
- transaction.distributed_tracer.create_distributed_trace_payload
51
- rescue => e
52
- NewRelic::Agent.logger.error 'error during create_distributed_trace_payload', e
53
- nil
54
- end
55
-
56
- # Decode a JSON string containing distributed trace properties
57
- # (e.g., calling application, priority) and apply them to the
58
- # current transaction. You can use it to receive distributed
59
- # tracing information protocols the agent does not already
60
- # support.
61
- #
62
- # This method will fail if you call it after calling
63
- # {#create_distributed_trace_payload}.
64
- #
65
- # @param payload [String] Incoming distributed trace payload,
66
- # either as a JSON string or as a
67
- # header-friendly string returned from
68
- # {DistributedTracePayload#http_safe}
69
- #
70
- # @return nil
71
- #
72
- # @api public
73
- #
74
- # @deprecated See {#accept_distributed_trace_headers} instead
75
- #
76
- def accept_distributed_trace_payload payload
77
- Deprecator.deprecate :accept_distributed_trace_payload, :accept_distributed_trace_headers
78
-
79
- unless Agent.config[:'distributed_tracing.enabled']
80
- NewRelic::Agent.logger.warn "Not configured to accept New Relic distributed trace payload"
81
- return nil
82
- end
83
-
84
- return unless transaction = Transaction.tl_current
85
- transaction.distributed_tracer.accept_distributed_trace_payload(payload)
86
- nil
87
- rescue => e
88
- NewRelic::Agent.logger.error 'error during accept_distributed_trace_payload', e
89
- nil
90
- end
91
-
92
-
93
27
  # Adds the Distributed Trace headers so that the downstream service can participate in a
94
28
  # distributed trace. This method should be called every time an outbound call is made
95
29
  # since the header payload contains a timestamp.
@@ -92,22 +92,6 @@ DependencyDetection.defer do
92
92
  !NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
93
93
  end
94
94
 
95
-
96
- depends_on do
97
- # If the deprecated :disable_active_record_4 setting is true, and
98
- # the active record version is four, disable!
99
- NewRelic::Agent.config[:disable_active_record_4] == false \
100
- || ::ActiveRecord::VERSION::MAJOR.to_i != 4
101
- end
102
-
103
- depends_on do
104
- # If the deprecated :disable_active_record_5 setting is true, and
105
- # the active record version is five, disable!
106
- NewRelic::Agent.config[:disable_active_record_5] == false \
107
- || ::ActiveRecord::VERSION::MAJOR.to_i != 5
108
- end
109
-
110
-
111
95
  executes do
112
96
  ::NewRelic::Agent.logger.info 'Installing notifications based Active Record instrumentation'
113
97
  end
@@ -3,6 +3,10 @@
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
  # frozen_string_literal: true
5
5
 
6
+ require_relative 'bunny/instrumentation'
7
+ require_relative 'bunny/chain'
8
+ require_relative 'bunny/prepend'
9
+
6
10
  DependencyDetection.defer do
7
11
  named :bunny
8
12
 
@@ -18,158 +22,12 @@ DependencyDetection.defer do
18
22
  end
19
23
 
20
24
  executes do
21
- module Bunny
22
- class Exchange
23
- alias_method :publish_without_new_relic, :publish
24
-
25
- def publish payload, opts = {}
26
- begin
27
- destination = NewRelic::Agent::Instrumentation::Bunny.exchange_name(name)
28
-
29
- tracing_enabled =
30
- NewRelic::Agent::CrossAppTracing.cross_app_enabled? ||
31
- NewRelic::Agent.config[:'distributed_tracing.enabled']
32
- opts[:headers] ||= {} if tracing_enabled
33
-
34
- segment = NewRelic::Agent::Messaging.start_amqp_publish_segment(
35
- library: NewRelic::Agent::Instrumentation::Bunny::LIBRARY,
36
- destination_name: destination,
37
- headers: opts[:headers],
38
- routing_key: opts[:routing_key] || opts[:key],
39
- reply_to: opts[:reply_to],
40
- correlation_id: opts[:correlation_id],
41
- exchange_type: type
42
- )
43
- rescue => e
44
- NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Exchange#publish", e
45
- publish_without_new_relic payload, opts
46
- else
47
- NewRelic::Agent::Tracer.capture_segment_error segment do
48
- publish_without_new_relic payload, opts
49
- end
50
- ensure
51
- segment.finish if segment
52
- end
53
- end
54
- end
55
-
56
- class Queue
57
- alias_method :pop_without_new_relic, :pop
58
-
59
- def pop(opts = {:manual_ack => false}, &block)
60
- bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
61
- begin
62
- t0 = Time.now
63
- msg = pop_without_new_relic opts, &block
64
- delivery_info, message_properties, _payload = msg
65
- rescue StandardError => error
66
- bunny_error = error
67
- end
68
-
69
- begin
70
- exchange_name, exchange_type = if delivery_info
71
- [ NewRelic::Agent::Instrumentation::Bunny.exchange_name(delivery_info.exchange),
72
- NewRelic::Agent::Instrumentation::Bunny.exchange_type(delivery_info, channel) ]
73
- else
74
- [ NewRelic::Agent::Instrumentation::Bunny.exchange_name(NewRelic::EMPTY_STR),
75
- NewRelic::Agent::Instrumentation::Bunny.exchange_type({}, channel) ]
76
- end
77
-
78
- segment = NewRelic::Agent::Messaging.start_amqp_consume_segment(
79
- library: NewRelic::Agent::Instrumentation::Bunny::LIBRARY,
80
- destination_name: exchange_name,
81
- delivery_info: (delivery_info || {}),
82
- message_properties: (message_properties || {headers: {}}),
83
- exchange_type: exchange_type,
84
- queue_name: name,
85
- start_time: t0
86
- )
87
- rescue => e
88
- NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Queue#pop", e
89
- else
90
- if bunny_error
91
- segment.notice_error bunny_error
92
- raise bunny_error
93
- end
94
- ensure
95
- segment.finish if segment
96
- end
97
-
98
- msg
99
- end
100
-
101
- alias_method :purge_without_new_relic, :purge
102
-
103
- def purge *args
104
- begin
105
- type = server_named? ? :temporary_queue : :queue
106
- segment = NewRelic::Agent::Tracer.start_message_broker_segment(
107
- action: :purge,
108
- library: NewRelic::Agent::Instrumentation::Bunny::LIBRARY,
109
- destination_type: type,
110
- destination_name: name
111
- )
112
- rescue => e
113
- NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Queue#purge", e
114
- purge_without_new_relic(*args)
115
- else
116
- NewRelic::Agent::Tracer.capture_segment_error segment do
117
- purge_without_new_relic(*args)
118
- end
119
- ensure
120
- segment.finish if segment
121
- end
122
- end
123
-
124
- end
125
-
126
- class Consumer
127
- alias_method :call_without_new_relic, :call
128
-
129
- def call *args
130
- delivery_info, message_properties, _ = args
131
- queue_name = queue.respond_to?(:name) ? queue.name : queue
132
-
133
- NewRelic::Agent::Messaging.wrap_amqp_consume_transaction(
134
- library: NewRelic::Agent::Instrumentation::Bunny::LIBRARY,
135
- destination_name: NewRelic::Agent::Instrumentation::Bunny.exchange_name(delivery_info.exchange),
136
- delivery_info: delivery_info,
137
- message_properties: message_properties,
138
- exchange_type: NewRelic::Agent::Instrumentation::Bunny.exchange_type(delivery_info, channel),
139
- queue_name: queue_name) do
140
-
141
- call_without_new_relic(*args)
142
- end
143
- end
144
-
145
- end
146
- end
147
- end
148
- end
149
-
150
- module NewRelic
151
- module Agent
152
- module Instrumentation
153
- module Bunny
154
- LIBRARY = 'RabbitMQ'
155
- DEFAULT_NAME = 'Default'
156
- DEFAULT_TYPE = :direct
157
-
158
- SLASH = '/'
159
-
160
- class << self
161
- def exchange_name name
162
- name.empty? ? DEFAULT_NAME : name
163
- end
164
-
165
- def exchange_type delivery_info, channel
166
- if di_exchange = delivery_info[:exchange]
167
- return DEFAULT_TYPE if di_exchange.empty?
168
- return channel.exchanges[delivery_info[:exchange]].type if channel.exchanges[di_exchange]
169
- end
170
- end
171
- end
172
- end
25
+ if use_prepend?
26
+ prepend_instrument ::Bunny::Exchange, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
27
+ prepend_instrument ::Bunny::Queue, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
28
+ prepend_instrument ::Bunny::Consumer, ::NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
29
+ else
30
+ chain_instrument NewRelic::Agent::Instrumentation::Bunny
173
31
  end
174
32
  end
175
33
  end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module Bunny
7
+ def self.instrument!
8
+ ::Bunny::Exchange.class_eval do
9
+ include NewRelic::Agent::Instrumentation::Bunny::Exchange
10
+
11
+ alias_method :publish_without_new_relic, :publish
12
+
13
+ def publish payload, opts = {}
14
+ publish_with_tracing(payload, opts) { publish_without_new_relic payload, opts }
15
+ end
16
+ end
17
+
18
+ ::Bunny::Queue.class_eval do
19
+ include NewRelic::Agent::Instrumentation::Bunny::Queue
20
+
21
+ alias_method :pop_without_new_relic, :pop
22
+
23
+ def pop(opts = {:manual_ack => false}, &block)
24
+ pop_with_tracing { pop_without_new_relic opts, &block }
25
+ end
26
+
27
+ alias_method :purge_without_new_relic, :purge
28
+
29
+ def purge *args
30
+ purge_with_tracing { purge_without_new_relic(*args) }
31
+ end
32
+ end
33
+
34
+ ::Bunny::Consumer.class_eval do
35
+ include NewRelic::Agent::Instrumentation::Bunny::Consumer
36
+
37
+ alias_method :call_without_new_relic, :call
38
+
39
+ def call *args
40
+ call_with_tracing(*args) { call_without_new_relic(*args) }
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,152 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
+ # frozen_string_literal: true
5
+
6
+ module NewRelic
7
+ module Agent
8
+ module Instrumentation
9
+ module Bunny
10
+ module_function
11
+
12
+ LIBRARY = 'RabbitMQ'
13
+ DEFAULT_NAME = 'Default'
14
+ DEFAULT_TYPE = :direct
15
+ SLASH = '/'
16
+
17
+ def exchange_name name
18
+ name.empty? ? DEFAULT_NAME : name
19
+ end
20
+
21
+ def exchange_type delivery_info, channel
22
+ if di_exchange = delivery_info[:exchange]
23
+ return DEFAULT_TYPE if di_exchange.empty?
24
+ return channel.exchanges[delivery_info[:exchange]].type if channel.exchanges[di_exchange]
25
+ end
26
+ end
27
+
28
+ module Exchange
29
+ include Bunny
30
+
31
+ def publish_with_tracing payload, opts = {}
32
+ begin
33
+ destination = exchange_name(name)
34
+
35
+ tracing_enabled =
36
+ NewRelic::Agent::CrossAppTracing.cross_app_enabled? ||
37
+ NewRelic::Agent.config[:'distributed_tracing.enabled']
38
+ opts[:headers] ||= {} if tracing_enabled
39
+
40
+ segment = NewRelic::Agent::Messaging.start_amqp_publish_segment(
41
+ library: LIBRARY,
42
+ destination_name: destination,
43
+ headers: opts[:headers],
44
+ routing_key: opts[:routing_key] || opts[:key],
45
+ reply_to: opts[:reply_to],
46
+ correlation_id: opts[:correlation_id],
47
+ exchange_type: type
48
+ )
49
+ rescue => e
50
+ NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Exchange#publish", e
51
+ yield
52
+ else
53
+ NewRelic::Agent::Tracer.capture_segment_error segment do
54
+ yield
55
+ end
56
+ ensure
57
+ segment.finish if segment
58
+ end
59
+ end
60
+ end
61
+
62
+ module Queue
63
+ include Bunny
64
+
65
+ def pop_with_tracing
66
+ bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
67
+ begin
68
+ t0 = Time.now
69
+ msg = yield
70
+ delivery_info, message_properties, _payload = msg
71
+ rescue StandardError => error
72
+ bunny_error = error
73
+ end
74
+
75
+ begin
76
+ exch_name, exch_type = if delivery_info
77
+ [ exchange_name(delivery_info.exchange),
78
+ exchange_type(delivery_info, channel) ]
79
+ else
80
+ [ exchange_name(NewRelic::EMPTY_STR),
81
+ exchange_type({}, channel) ]
82
+ end
83
+
84
+ segment = NewRelic::Agent::Messaging.start_amqp_consume_segment(
85
+ library: LIBRARY,
86
+ destination_name: exch_name,
87
+ delivery_info: (delivery_info || {}),
88
+ message_properties: (message_properties || {headers: {}}),
89
+ exchange_type: exch_type,
90
+ queue_name: name,
91
+ start_time: t0
92
+ )
93
+ rescue => e
94
+ NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Queue#pop", e
95
+ else
96
+ if bunny_error
97
+ segment.notice_error bunny_error
98
+ raise bunny_error
99
+ end
100
+ ensure
101
+ segment.finish if segment
102
+ end
103
+
104
+ msg
105
+ end
106
+
107
+ def purge_with_tracing
108
+ begin
109
+ type = server_named? ? :temporary_queue : :queue
110
+ segment = NewRelic::Agent::Tracer.start_message_broker_segment(
111
+ action: :purge,
112
+ library: LIBRARY,
113
+ destination_type: type,
114
+ destination_name: name
115
+ )
116
+ rescue => e
117
+ NewRelic::Agent.logger.error "Error starting message broker segment in Bunny::Queue#purge", e
118
+ yield
119
+ else
120
+ NewRelic::Agent::Tracer.capture_segment_error segment do
121
+ yield
122
+ end
123
+ ensure
124
+ segment.finish if segment
125
+ end
126
+ end
127
+ end
128
+
129
+ module Consumer
130
+ include Bunny
131
+
132
+ def call_with_tracing *args
133
+ delivery_info, message_properties, _ = args
134
+ queue_name = queue.respond_to?(:name) ? queue.name : queue
135
+
136
+ NewRelic::Agent::Messaging.wrap_amqp_consume_transaction(
137
+ library: LIBRARY,
138
+ destination_name: exchange_name(delivery_info.exchange),
139
+ delivery_info: delivery_info,
140
+ message_properties: message_properties,
141
+ exchange_type: exchange_type(delivery_info, channel),
142
+ queue_name: queue_name) do
143
+
144
+ yield
145
+ end
146
+ end
147
+
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end