Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
added typhoeus instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sdawara authored and jaggederest committed May 12, 2011
1 parent 6a8f71d commit 9daf548
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions lib/rpm_contrib/instrumentation/typhoeus.rb
@@ -1,17 +1,21 @@
if defined? Typhoeus
Typhoeus.class_eval do
def get_with_newrelic_trace(*args, &block)
metrics = ["External/#{@address}/Typhoeus/#{args[0].method}","External/#{@address}/all"]
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
metrics << "External/allWeb"
else
metrics << "External/allOther"
end
self.class.trace_execution_scoped metrics do
request_without_newrelic_trace(*args, &block)
require 'uri'
module Typhoeus
Request.instance_eval do
def get_with_newrelic_trace(*args, &block)
uri = URI.parse(args.first)
metrics = ["External/#{uri.host}/Typhoeus/GET","External/#{uri.host}/all"]
if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction?
metrics << "External/allWeb"
else
metrics << "External/allOther"
end
self.class.trace_execution_scoped metrics do
get_without_newrelic_trace(*args, &block)
end
end
alias get_without_newrelic_trace get
alias get get_with_newrelic_trace
end
alias get_without_newrelic_trace request
alias get get_with_newrelic_trace
end
end
end
4 changes: 2 additions & 2 deletions rpm_contrib.gemspec
Expand Up @@ -37,6 +37,7 @@ the New Relic Ruby monitoring gem newrelic_rpm.
"lib/rpm_contrib/instrumentation/paperclip.rb",
"lib/rpm_contrib/instrumentation/redis.rb",
"lib/rpm_contrib/instrumentation/resque.rb",
"lib/rpm_contrib/instrumentation/typhoeus.rb",
"test/helper.rb",
"test/schema.rb",
"test/test_mongoid.rb",
Expand Down Expand Up @@ -67,5 +68,4 @@ the New Relic Ruby monitoring gem newrelic_rpm.
else
s.add_dependency(%q<newrelic_rpm>, [">= 2.13.1"])
end
end

end

0 comments on commit 9daf548

Please sign in to comment.