wd_sinatra 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,12 @@
1
1
  # Weasel Diesel Sinatra Changelog
2
2
 
3
+ ## 0.2.6
4
+
5
+ * Added a few basic disabled settings for newrelic and airbrake.
6
+
3
7
  ## 0.2.5
4
8
 
5
- * added suport for `ENV['DONT_LOAD_MODELS']` to avoid loading models.
9
+ * added support for `ENV['DONT_LOAD_MODELS']` to avoid loading models.
6
10
 
7
11
  ## 0.2.4
8
12
 
data/README.md CHANGED
@@ -49,6 +49,16 @@ like the most.
49
49
  The console mode is like the server mode but without the server only
50
50
  concerns such as the sinatra routes config and Rack middleware.
51
51
 
52
+ If your users also want `script/console`, add the file, chmod +x it and
53
+ use the following code:
54
+
55
+ ```bash
56
+ #!/bin/bash
57
+ # Run bin/console for those who like the old Rails way.
58
+ abspath=$(cd ${0%/*} && echo $PWD/${0##*/})
59
+ $abspath/../../bin/console
60
+ ```
61
+
52
62
  ### Documentation generation
53
63
 
54
64
  $ rake doc:services
@@ -205,7 +215,6 @@ app by trying to generate a new app named the same as your old app.
205
215
  The generator will detect conflicts and let you pick an action (diff,
206
216
  overwrite, ignore...)
207
217
 
208
-
209
218
  ## Contributing
210
219
 
211
220
  1. Fork it
@@ -1,5 +1,5 @@
1
1
  module WD
2
2
  module Sinatra
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ gem "sinatra", "1.3.2"
5
5
  # service DSL
6
6
  gem "weasel_diesel"
7
7
  gem "wd_sinatra"
8
-
8
+ # gem 'wd_newrelic_rpm', :require => 'newrelic_rpm'
9
9
 
10
10
  if RUBY_VERSION =~ /1.8/
11
11
  gem 'backports', '2.3.0'
@@ -0,0 +1,16 @@
1
+ common: &default_settings
2
+ api_key: 'replace me'
3
+ params_filters:
4
+ - password
5
+ host: 'api.airbrake.io'
6
+ enabled: false
7
+
8
+ development:
9
+ <<: *default_settings
10
+
11
+ test:
12
+ <<: *default_settings
13
+
14
+ production:
15
+ <<: *default_settings
16
+ enabled: true
@@ -0,0 +1,16 @@
1
+ if defined?(NewRelic)
2
+ if RACK_ENV == 'development'
3
+ require 'new_relic/rack/developer_mode'
4
+ use NewRelic::Rack::DeveloperMode
5
+ end
6
+ if NewRelic::Control.instance.agent_enabled?
7
+ LOGGER.info "New Relic monitoring enabled App name: '#{NewRelic::Control.instance['app_name']}', Mode: '#{NewRelic::Control.instance.app}'"
8
+ end
9
+ end
10
+
11
+ # Use this middleware with AR to avoid threading issues.
12
+ # require 'active_record'
13
+ # use ActiveRecord::ConnectionAdapters::ConnectionManagement
14
+
15
+ use Airbrake::Rack if defined?(Airbrake)
16
+ use Rack::ContentLength
@@ -3,3 +3,22 @@
3
3
  #
4
4
  # Here you want to load your dependencies and maybe set your
5
5
  # datastore.
6
+
7
+
8
+ ############### AIRBRAKE ###############
9
+ airbrake_config_file = File.join(WDSinatra::AppLoader.root_path, 'config', 'airbrake.yml')
10
+ if File.exist?(airbrake_config_file)
11
+ airbrake_config = YAML.load_file(airbrake_config_file)[RACK_ENV]
12
+ if airbrake_config && airbrake_config['enabled']
13
+ require 'airbrake'
14
+ Airbrake.configure do |config|
15
+ config.api_key = airbrake_config['api_key']
16
+ (airbrake_config['params_filters'] - config.params_filters).each do |param|
17
+ config.params_filters << param
18
+ end
19
+ config.environment_name = RACK_ENV
20
+ config.host = airbrake_config['host'] if airbrake_config['host']
21
+ config.logger = LOGGER
22
+ end
23
+ end
24
+ end
@@ -85,3 +85,7 @@ end
85
85
 
86
86
  Sinatra::Helpers.send(:include, WDSinatraHooks)
87
87
  WeaselDiesel::RequestHandler.send(:include, WDSinatraHooks)
88
+
89
+ # NEW RELIC HOOKS
90
+ # uncomment if you want to use newrelic (you also need the wd_newrelic_rpm gem)
91
+ # require 'newrelic_instrumentation'
@@ -0,0 +1,66 @@
1
+ require 'new_relic/agent/instrumentation/controller_instrumentation'
2
+
3
+ DependencyDetection.defer do
4
+ depends_on do
5
+ defined?(WeaselDiesel) && defined?(WeaselDiesel::RequestHandler) &&
6
+ WeaselDiesel::RequestHandler.method_defined?(:dispatch)
7
+ end
8
+
9
+ executes do
10
+ NewRelic::Agent.logger.debug 'Installing WeaselDiesel instrumentation'
11
+ end
12
+
13
+ executes do
14
+ ::WeaselDiesel::RequestHandler.class_eval do
15
+ include NewRelic::Agent::Instrumentation::WeaselDiesel
16
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
17
+ alias dispatch_without_newrelic dispatch
18
+ alias dispatch dispatch_with_newrelic
19
+
20
+ add_method_tracer :params_preprocessor_hook if self.method_defined?(:params_preprocessor_hook)
21
+ add_method_tracer :params_postprocessor_hook if self.method_defined?(:params_postprocessor_hook)
22
+ add_method_tracer :pre_dispatch_hook if self.method_defined?(:pre_dispatch_hook)
23
+ end
24
+ # Monitor the actual dispatch of each service
25
+ WSList.all.each do |service|
26
+ service.handler.class_eval do
27
+ add_method_tracer :service_dispatch, 'Service/Dispatch'
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+
34
+ module NewRelic
35
+ module Agent
36
+ module Instrumentation
37
+ module WeaselDiesel
38
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
39
+
40
+ def dispatch_with_newrelic(app)
41
+ perform_action_with_newrelic_trace(:category => :controller,
42
+ :class_name => service.class.name,
43
+ :controller => service.class.name,
44
+ :path => "#{service.verb.upcase} #{service.url}",
45
+ :name => "#{service.verb.upcase} #{service.url}",
46
+ :params => filter_newrelic_params(app.params),
47
+ :request => app.request) do
48
+ dispatch_without_newrelic(app)
49
+ end
50
+ end
51
+
52
+ # filter params based the newrelic.yml entry if it exists.
53
+ def filter_newrelic_params(params)
54
+ @filters ||= NewRelic::Control.instance['filter_parameters']
55
+ return params if @filters.nil? || @filters.empty?
56
+ duped_params = params.dup
57
+ duped_params.each{|k,v| duped_params[k] = 'FILTERED' if @filters.include?(k) }
58
+ duped_params
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ DependencyDetection.detect!
metadata CHANGED
@@ -1,61 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wd_sinatra
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 5
10
- version: 0.2.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matt Aimonetti
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-01 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: weasel_diesel
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70297591787320 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: thor
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70297591787320
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &70297591786900 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
47
33
  type: :runtime
48
- version_requirements: *id002
49
- description: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps using the Weasel Diesel DSL
50
- email:
34
+ prerelease: false
35
+ version_requirements: *70297591786900
36
+ description: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra
37
+ apps using the Weasel Diesel DSL
38
+ email:
51
39
  - mattaimonetti@gmail.com
52
- executables:
40
+ executables:
53
41
  - wd_sinatra
54
42
  extensions: []
55
-
56
43
  extra_rdoc_files: []
57
-
58
- files:
44
+ files:
59
45
  - .gitignore
60
46
  - CHANGELOG.md
61
47
  - Gemfile
@@ -75,6 +61,7 @@ files:
75
61
  - templates/api/hello_world.rb
76
62
  - templates/bin/console
77
63
  - templates/config.ru
64
+ - templates/config/airbrake.yml
78
65
  - templates/config/environments/default.rb
79
66
  - templates/config/environments/production.rb
80
67
  - templates/config/environments/test.rb
@@ -83,6 +70,7 @@ files:
83
70
  - templates/lib/app.rb
84
71
  - templates/lib/body_parser.rb
85
72
  - templates/lib/hooks.rb
73
+ - templates/lib/newrelic_instrumentation.rb
86
74
  - templates/lib/tasks/doc.rake
87
75
  - templates/lib/tasks/doc_generator/bootstrap/.gitignore
88
76
  - templates/lib/tasks/doc_generator/bootstrap/LICENSE
@@ -143,39 +131,29 @@ files:
143
131
  - templates/test/integration/hello_world_test.rb
144
132
  - templates/test/test_helpers.rb
145
133
  - wd-sinatra.gemspec
146
- has_rdoc: true
147
134
  homepage: https://github.com/mattetti/wd_sinatra
148
135
  licenses: []
149
-
150
136
  post_install_message:
151
137
  rdoc_options: []
152
-
153
- require_paths:
138
+ require_paths:
154
139
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
140
+ required_ruby_version: !ruby/object:Gem::Requirement
156
141
  none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- hash: 3
161
- segments:
162
- - 0
163
- version: "0"
164
- required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
147
  none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
173
152
  requirements: []
174
-
175
153
  rubyforge_project:
176
- rubygems_version: 1.5.3
154
+ rubygems_version: 1.8.16
177
155
  signing_key:
178
156
  specification_version: 3
179
- summary: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps using the Weasel Diesel DSL
157
+ summary: Weasel-Diesel Sinatra app gem, allowing you to generate/update sinatra apps
158
+ using the Weasel Diesel DSL
180
159
  test_files: []
181
-