Created
November 8, 2012 06:15
-
-
Save kputnam/4037164 to your computer and use it in GitHub Desktop.
NewRelic Instrumentation for HTTPI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 with_adapter_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 | |
with_adapter_without_newrelic_trace(method, request, adapter, &block) | |
end | |
end | |
alias with_adapter_without_newrelic_trace with_adapter | |
alias with_adapter with_adapter_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