forked from newrelic/rpm_contrib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bill Kayser
committed
Jan 21, 2010
1 parent
3d35021
commit 725bea7
Showing
8 changed files
with
153 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Version 1.0.0 | ||
- Initial Release |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if defined? Authlogic::Session::Base | ||
Authlogic::Session::Base.class_eval do | ||
# add_method_tracer :record, 'Authlogic/record' | ||
class << self | ||
add_method_tracer :find, 'Authlogic/find' | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module NewRelic::Agent::Instrumentation::DelayedJobInstrumentation | ||
extend self | ||
Delayed::Job.class_eval do | ||
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | ||
if self.instance_methods.include?('name') | ||
add_transaction_tracer "invoke_job", :category => :task, :name => '#{self.name}' | ||
else | ||
add_transaction_tracer "invoke_job", :category => :task | ||
end | ||
end | ||
|
||
Delayed::Worker.class_eval do | ||
def initialize_with_new_relic(*args) | ||
initialize_without_new_relic(*args) | ||
NewRelic::.delayed_worker = self | ||
end | ||
|
||
alias initialize_without_new_relic initialize | ||
alias initialize initialize_with_new_relic | ||
end | ||
|
||
def delayed_worker=(w) | ||
@delayed_worker = w | ||
env = NewRelic::Control.instance.local_env | ||
env.dispatcher = :delayed_job | ||
env.dispatcher_instance_id = case | ||
when @delayed_worker.respond_to?(:name) | ||
@delayed_worker.name | ||
when @delayed_worker.class.respond_to?(:default_name) | ||
@delayed_worker.class.default_name | ||
else | ||
"host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}" | ||
end | ||
|
||
env.append_environment_value 'Dispatcher', @dispatcher.to_s | ||
env.append_environment_value 'Dispatcher instance id', @dispatcher_instance_id | ||
|
||
@delayed_worker | ||
end | ||
|
||
def delayed_worker | ||
@delayed_worker | ||
end | ||
|
||
end if defined?(Delayed::Job) |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module NewRelic::Agent::Samplers | ||
class DelayedJobLockSampler < NewRelic::Agent::Sampler | ||
def initialize | ||
super :delayed_job_lock | ||
raise Unsupported, "No delayed job workers running" unless Instrumentation::DelayedJobInstrumentation.delayed_worker | ||
end | ||
|
||
def stats | ||
stats_engine.get_stats("DJ/Locked Jobs", false) | ||
end | ||
|
||
def local_env | ||
NewRelic::Control.instance.local_env | ||
end | ||
|
||
def worker_name | ||
local_env.dispatcher_instance_id | ||
end | ||
|
||
def locked_jobs | ||
Delayed::Job.count(:conditions => {:locked_by => worker_name}) | ||
end | ||
|
||
def poll | ||
stats.record_data_point locked_jobs | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'newrelic_rpm' | ||
module RPMContrib | ||
VERSION = File.read(File.dirname(__FILE__)+"/../CHANGELOG")[/Version ([\d\.]+)$/, 1] | ||
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{rpm_contrib} | ||
s.version = "1.0.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Bill Kayser"] | ||
s.date = %q{2010-01-20} | ||
s.description = %q{ Community contributed instrumentation for various frameworks based on | ||
the New Relic Ruby monitoring gem newrelic_rpm. | ||
} | ||
s.email = %q{support@newrelic.com} | ||
s.extra_rdoc_files = [ | ||
"LICENSE", | ||
"README.rdoc" | ||
] | ||
s.files = [ | ||
"LICENSE", | ||
"README.rdoc", | ||
"Rakefile", | ||
"lib/rpm_contrib.rb", | ||
"test/helper.rb", | ||
"test/test_rpm_contrib.rb" | ||
] | ||
s.homepage = %q{http://github.com/newrelic/rpm_contrib} | ||
s.rdoc_options = ["--charset=UTF-8"] | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.5} | ||
s.summary = %q{Contributed Instrumentation for New Relic RPM} | ||
s.test_files = [ | ||
"test/helper.rb", | ||
"test/test_rpm_contrib.rb" | ||
] | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
s.add_runtime_dependency(%q<newrelic_rpm>, [">= 2.10.2"]) | ||
else | ||
s.add_dependency(%q<newrelic_rpm>, [">= 2.10.2"]) | ||
end | ||
else | ||
s.add_dependency(%q<newrelic_rpm>, [">= 2.10.2"]) | ||
end | ||
end | ||
|