Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
bumped the version with newrelic and airbrake setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattetti committed Jun 13, 2012
1 parent 72d42d9 commit 53e5954
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,8 +1,12 @@
# Weasel Diesel Sinatra Changelog

## 0.2.6

* Added a few basic disabled settings for newrelic and airbrake.

## 0.2.5

* added suport for `ENV['DONT_LOAD_MODELS']` to avoid loading models.
* added support for `ENV['DONT_LOAD_MODELS']` to avoid loading models.

## 0.2.4

Expand Down
2 changes: 1 addition & 1 deletion lib/wd_sinatra/version.rb
@@ -1,5 +1,5 @@
module WD
module Sinatra
VERSION = "0.2.5"
VERSION = "0.2.6"
end
end
16 changes: 16 additions & 0 deletions templates/config/airbrake.yml
@@ -0,0 +1,16 @@
common: &default_settings
api_key: 'replace me'
params_filters:
- password
host: 'api.airbrake.io'
enabled: false

development:
<<: *default_settings

test:
<<: *default_settings

production:
<<: *default_settings
enabled: true
66 changes: 66 additions & 0 deletions templates/lib/newrelic_instrumentation.rb
@@ -0,0 +1,66 @@
require 'new_relic/agent/instrumentation/controller_instrumentation'

DependencyDetection.defer do
depends_on do
defined?(WeaselDiesel) && defined?(WeaselDiesel::RequestHandler) &&
WeaselDiesel::RequestHandler.method_defined?(:dispatch)
end

executes do
NewRelic::Agent.logger.debug 'Installing WeaselDiesel instrumentation'
end

executes do
::WeaselDiesel::RequestHandler.class_eval do
include NewRelic::Agent::Instrumentation::WeaselDiesel
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
alias dispatch_without_newrelic dispatch
alias dispatch dispatch_with_newrelic

add_method_tracer :params_preprocessor_hook if self.method_defined?(:params_preprocessor_hook)
add_method_tracer :params_postprocessor_hook if self.method_defined?(:params_postprocessor_hook)
add_method_tracer :pre_dispatch_hook if self.method_defined?(:pre_dispatch_hook)
end
# Monitor the actual dispatch of each service
WSList.all.each do |service|
service.handler.class_eval do
add_method_tracer :service_dispatch, 'Service/Dispatch'
end
end
end
end


module NewRelic
module Agent
module Instrumentation
module WeaselDiesel
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

def dispatch_with_newrelic(app)
perform_action_with_newrelic_trace(:category => :controller,
:class_name => service.class.name,
:controller => service.class.name,
:path => "#{service.verb.upcase} #{service.url}",
:name => "#{service.verb.upcase} #{service.url}",
:params => filter_newrelic_params(app.params),
:request => app.request) do
dispatch_without_newrelic(app)
end
end

# filter params based the newrelic.yml entry if it exists.
def filter_newrelic_params(params)
@filters ||= NewRelic::Control.instance['filter_parameters']
return params if @filters.nil? || @filters.empty?
duped_params = params.dup
duped_params.each{|k,v| duped_params[k] = 'FILTERED' if @filters.include?(k) }
duped_params
end

end
end
end
end

DependencyDetection.detect!

0 comments on commit 53e5954

Please sign in to comment.