Created
March 21, 2012 00:43
-
-
Save mgreen/2143106 to your computer and use it in GitHub Desktop.
newrelic for em-http-request with em-synchrony
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
| if defined?(::EM::HTTPMethods) and defined?(::EM::Synchrony) | |
| module EM::HTTPMethods | |
| def request_with_newrelic_trace(type, *args, &block) | |
| uri = @uri.kind_of?(Addressable::URI) ? @uri : Addressable::URI::parse(@uri.to_s) | |
| metrics = ["External/#{uri.host}/EM::HTTPMethods/#{type.to_s.upcase}","External/#{uri.host}/a | |
| ll"] | |
| if NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? | |
| metrics << "External/allWeb" | |
| else | |
| metrics << "External/allOther" | |
| end | |
| self.class.trace_execution_scoped metrics do | |
| self.send("#{type}_without_newrelic_trace", *args, &block) | |
| end | |
| end | |
| end | |
| %w[get head post delete put].each do |type| | |
| EM::HTTPMethods.class_eval %[ | |
| def #{type}_with_newrelic_trace(*args, &block) | |
| request_with_newrelic_trace(:#{type}, *args, &block) | |
| end | |
| alias #{type}_without_newrelic_trace #{type} | |
| alias #{type} #{type}_with_newrelic_trace | |
| ] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment