-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix constant scoping when defining modules
- Loading branch information
Justin George
committed
Feb 10, 2010
1 parent
40b4ada
commit 6974677
Showing
21 changed files
with
155 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
26 changes: 17 additions & 9 deletions
26
lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
require 'new_relic/agent/instrumentation/controller_instrumentation' | ||
|
||
module NewRelic::Agent::Instrumentation::DelayedJobInstrumentation | ||
if defined?(Delayed::Job) | ||
module NewRelic | ||
module Agent | ||
module Instrumentation | ||
module DelayedJobInstrumentation | ||
|
||
Delayed::Job.class_eval do | ||
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
if self.instance_methods.include?('name') | ||
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}' | ||
else | ||
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob' | ||
Delayed::Job.class_eval do | ||
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
if self.instance_methods.include?('name') | ||
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}' | ||
else | ||
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob' | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
||
end if defined?(Delayed::Job) | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
module NewRelic::Agent::Instrumentation | ||
# NewRelic instrumentation for Sinatra applications. Sinatra actions will | ||
# appear in the UI similar to controller actions, and have breakdown charts | ||
# and transaction traces. | ||
# | ||
# The actions in the UI will correspond to the pattern expression used | ||
# to match them. HTTP operations are not distinguished. Multiple matches | ||
# will all be tracked as separate actions. | ||
module Sinatra | ||
|
||
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
|
||
def route_eval_with_newrelic(&block_arg) | ||
path = unescape(@request.path_info) | ||
name = path | ||
# Go through each route and look for a match | ||
if routes = self.class.routes[@request.request_method] | ||
routes.detect do |pattern, keys, conditions, block| | ||
if block_arg.equal? block | ||
name = pattern.source | ||
if defined?(Sinatra::Base) | ||
module NewRelic | ||
module Agent | ||
module Instrumentation | ||
# NewRelic instrumentation for Sinatra applications. Sinatra actions will | ||
# appear in the UI similar to controller actions, and have breakdown charts | ||
# and transaction traces. | ||
# | ||
# The actions in the UI will correspond to the pattern expression used | ||
# to match them. HTTP operations are not distinguished. Multiple matches | ||
# will all be tracked as separate actions. | ||
module Sinatra | ||
|
||
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
|
||
def route_eval_with_newrelic(&block_arg) | ||
path = unescape(@request.path_info) | ||
name = path | ||
# Go through each route and look for a match | ||
if routes = self.class.routes[@request.request_method] | ||
routes.detect do |pattern, keys, conditions, block| | ||
if block_arg.equal? block | ||
name = pattern.source | ||
end | ||
end | ||
end | ||
# strip of leading ^ and / chars and trailing $ and / | ||
name.gsub!(%r{^[/^]*(.*?)[/\$]*$}, '\1') | ||
name = 'root' if name.empty? | ||
perform_action_with_newrelic_trace(:category => :sinatra, :name => name) do | ||
route_eval_without_newrelic(&block_arg) | ||
end | ||
end | ||
end | ||
end | ||
# strip of leading ^ and / chars and trailing $ and / | ||
name.gsub!(%r{^[/^]*(.*?)[/\$]*$}, '\1') | ||
name = 'root' if name.empty? | ||
perform_action_with_newrelic_trace(:category => :sinatra, :name => name) do | ||
route_eval_without_newrelic(&block_arg) | ||
|
||
::Sinatra::Base.class_eval do | ||
include NewRelic::Agent::Instrumentation::Sinatra | ||
alias route_eval_without_newrelic route_eval | ||
alias route_eval route_eval_with_newrelic | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
::Sinatra::Base.class_eval do | ||
include NewRelic::Agent::Instrumentation::Sinatra | ||
alias route_eval_without_newrelic route_eval | ||
alias route_eval route_eval_with_newrelic | ||
end | ||
|
||
end if defined?(Sinatra::Base) | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
module NewRelic::Metrics | ||
CONTROLLER = "Controller" | ||
DISPATCHER = "HttpDispatcher" | ||
ACTIVE_RECORD = "ActiveRecord" | ||
USER_TIME = "CPU/User Time" | ||
MEMORY = "Memory/Physical" | ||
end | ||
module NewRelic | ||
module Metrics | ||
CONTROLLER = "Controller" | ||
DISPATCHER = "HttpDispatcher" | ||
ACTIVE_RECORD = "ActiveRecord" | ||
USER_TIME = "CPU/User Time" | ||
MEMORY = "Memory/Physical" | ||
end | ||
end |
This file contains 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
Oops, something went wrong.