class Curl::Multi
Public Instance Methods
add_with_mmtrix(curl)
click to toggle source
Add CAT with callbacks if the request is serial
# File lib/mmtrix/agent/instrumentation/curb.rb, line 95 def add_with_mmtrix(curl) #THREAD_LOCAL_ACCESS if curl.respond_to?(:_nr_serial) && curl._nr_serial hook_pending_request(curl) if Mmtrix::Agent.tl_is_execution_traced? end return add_without_mmtrix( curl ) end
Also aliased as: add
hook_pending_request(request)
click to toggle source
Instrument the specified request
(a Curl::Easy
object) and set up cross-application tracing if it’s enabled.
# File lib/mmtrix/agent/instrumentation/curb.rb, line 125 def hook_pending_request(request) #THREAD_LOCAL_ACCESS wrapped_request, wrapped_response = wrap_request(request) state = Mmtrix::Agent::TransactionState.tl_get t0 = Time.now node = Mmtrix::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request) unless request._nr_instrumented install_header_callback(request, wrapped_response) install_completion_callback(request, t0, node, wrapped_request, wrapped_response) request._nr_instrumented = true end rescue => err Mmtrix::Agent.logger.error("Untrapped exception", err) end
install_completion_callback(request, t0, node, wrapped_request, wrapped_response)
click to toggle source
Install a callback that will finish the trace.
# File lib/mmtrix/agent/instrumentation/curb.rb, line 166 def install_completion_callback(request, t0, node, wrapped_request, wrapped_response) #THREAD_LOCAL_ACCESS original_callback = request.on_complete request._nr_original_on_complete = original_callback request.on_complete do |finished_request| begin state = Mmtrix::Agent::TransactionState.tl_get Mmtrix::Agent::CrossAppTracing.finish_trace(state, t0, node, wrapped_request, wrapped_response) ensure # Make sure the existing completion callback is run, and restore the # on_complete callback to how it was before. original_callback.call(finished_request) if original_callback remove_instrumentation_callbacks(request) end end end
install_header_callback( request, wrapped_response )
click to toggle source
Install a callback that will record the response headers to enable CAT linking
# File lib/mmtrix/agent/instrumentation/curb.rb, line 150 def install_header_callback( request, wrapped_response ) original_callback = request.on_header request._nr_original_on_header = original_callback request._nr_header_str = '' request.on_header do |header_data| wrapped_response.append_header_data( header_data ) if original_callback original_callback.call( header_data ) else header_data.length end end end
perform_with_mmtrix(&blk)
click to toggle source
Trace as an External/Multiple call if the first request isn’t serial.
# File lib/mmtrix/agent/instrumentation/curb.rb, line 108 def perform_with_mmtrix(&blk) return perform_without_mmtrix if self.requests.first && self.requests.first.respond_to?(:_nr_serial) && self.requests.first._nr_serial trace_execution_scoped("External/Multiple/Curb::Multi/perform") do perform_without_mmtrix(&blk) end end
Also aliased as: perform
remove_instrumentation_callbacks(request)
click to toggle source
# File lib/mmtrix/agent/instrumentation/curb.rb, line 182 def remove_instrumentation_callbacks(request) request.on_complete(&request._nr_original_on_complete) request.on_header(&request._nr_original_on_header) request._nr_instrumented = false end
wrap_request(request)
click to toggle source
Create request and response adapter objects for the specified request
# File lib/mmtrix/agent/instrumentation/curb.rb, line 142 def wrap_request(request) return Mmtrix::Agent::HTTPClients::CurbRequest.new(request), Mmtrix::Agent::HTTPClients::CurbResponse.new(request) end