Skip to content

Instantly share code, notes, and snippets.

@lsylvester
Forked from kputnam/newrelic_httpi.rb
Created March 12, 2013 05:38
Show Gist options
  • Save lsylvester/5140591 to your computer and use it in GitHub Desktop.
Save lsylvester/5140591 to your computer and use it in GitHub Desktop.
DependencyDetection.defer do
@name = :net
depends_on do
defined?(HTTPI)
end
executes do
NewRelic::Agent.logger.debug "Installing HTTPI instrumentation"
end
executes do
HTTPI.instance_eval do
def request_with_newrelic_trace(method, request, adapter, &block)
host = request.url.host
metrics = ["External/#{host}/HTTPI/#{method}", "External/#{host}/all", "External/all"]
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
metrics << "External/allWeb"
else
metrics << "External/allOther"
end
trace_execution_scoped(metrics) do
request_without_newrelic_trace(method, request, adapter, &block)
end
end
alias request_without_newrelic_trace request
alias request request_with_newrelic_trace
end
end
end if defined? DependencyDetection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment