newrelic_rpm 3.4.1 → 3.4.2.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of newrelic_rpm might be problematic. Click here for more details.

Files changed (81) hide show
  1. data/CHANGELOG +7 -0
  2. data/ReleaseNotes.md +638 -0
  3. data/lib/new_relic/agent/agent.rb +44 -56
  4. data/lib/new_relic/agent/beacon_configuration.rb +1 -1
  5. data/lib/new_relic/agent/browser_monitoring.rb +80 -42
  6. data/lib/new_relic/agent/configuration/defaults.rb +75 -0
  7. data/lib/new_relic/agent/configuration/environment_source.rb +42 -0
  8. data/lib/new_relic/agent/configuration/manager.rb +100 -0
  9. data/lib/new_relic/agent/configuration/server_source.rb +24 -0
  10. data/lib/new_relic/agent/configuration/yaml_source.rb +61 -0
  11. data/lib/new_relic/agent/configuration.rb +48 -0
  12. data/lib/new_relic/agent/error_collector.rb +10 -14
  13. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -5
  14. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +20 -4
  15. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
  16. data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
  17. data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -1
  18. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +3 -3
  19. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
  20. data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
  21. data/lib/new_relic/agent/method_tracer.rb +1 -1
  22. data/lib/new_relic/agent/new_relic_service.rb +18 -9
  23. data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
  24. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -5
  25. data/lib/new_relic/agent/sql_sampler.rb +11 -35
  26. data/lib/new_relic/agent/stats_engine/transactions.rb +2 -2
  27. data/lib/new_relic/agent/transaction_info.rb +24 -4
  28. data/lib/new_relic/agent/transaction_sample_builder.rb +2 -3
  29. data/lib/new_relic/agent/transaction_sampler.rb +9 -16
  30. data/lib/new_relic/agent.rb +4 -1
  31. data/lib/new_relic/collection_helper.rb +1 -1
  32. data/lib/new_relic/commands/deployments.rb +5 -3
  33. data/lib/new_relic/control/class_methods.rb +2 -3
  34. data/lib/new_relic/control/frameworks/rails.rb +8 -8
  35. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  36. data/lib/new_relic/control/instance_methods.rb +26 -32
  37. data/lib/new_relic/control/logging_methods.rb +5 -23
  38. data/lib/new_relic/control/server_methods.rb +11 -18
  39. data/lib/new_relic/control.rb +0 -1
  40. data/lib/new_relic/delayed_job_injection.rb +1 -1
  41. data/lib/new_relic/language_support.rb +8 -0
  42. data/lib/new_relic/noticed_error.rb +1 -1
  43. data/lib/new_relic/rack/browser_monitoring.rb +18 -6
  44. data/lib/new_relic/version.rb +2 -2
  45. data/newrelic.yml +0 -4
  46. data/newrelic_rpm.gemspec +16 -6
  47. data/test/config/newrelic.yml +3 -2
  48. data/test/new_relic/agent/agent/connect_test.rb +88 -83
  49. data/test/new_relic/agent/agent/start_test.rb +75 -80
  50. data/test/new_relic/agent/agent/start_worker_thread_test.rb +18 -18
  51. data/test/new_relic/agent/beacon_configuration_test.rb +13 -11
  52. data/test/new_relic/agent/browser_monitoring_test.rb +69 -14
  53. data/test/new_relic/agent/configuration/environment_source_test.rb +58 -0
  54. data/test/new_relic/agent/configuration/manager_test.rb +120 -0
  55. data/test/new_relic/agent/configuration/server_source_test.rb +28 -0
  56. data/test/new_relic/agent/configuration/yaml_source_test.rb +56 -0
  57. data/test/new_relic/agent/error_collector/notice_error_test.rb +63 -50
  58. data/test/new_relic/agent/error_collector_test.rb +10 -12
  59. data/test/new_relic/agent/new_relic_service_test.rb +11 -3
  60. data/test/new_relic/agent/pipe_channel_manager_test.rb +19 -16
  61. data/test/new_relic/agent/rpm_agent_test.rb +21 -19
  62. data/test/new_relic/agent/sql_sampler_test.rb +55 -56
  63. data/test/new_relic/agent/transaction_info_test.rb +45 -4
  64. data/test/new_relic/agent/transaction_sampler_test.rb +48 -44
  65. data/test/new_relic/agent_test.rb +68 -41
  66. data/test/new_relic/collection_helper_test.rb +7 -8
  67. data/test/new_relic/command/deployments_test.rb +12 -1
  68. data/test/new_relic/control/frameworks/rails_test.rb +26 -0
  69. data/test/new_relic/control/logging_methods_test.rb +77 -52
  70. data/test/new_relic/control_test.rb +103 -126
  71. data/test/new_relic/local_environment_test.rb +4 -6
  72. data/test/new_relic/rack/browser_monitoring_test.rb +4 -4
  73. data/test/new_relic/rack/developer_mode_test.rb +13 -7
  74. data/test/new_relic/transaction_sample_test.rb +8 -2
  75. data/test/script/build_test_gem.sh +9 -3
  76. data/test/script/ci.sh +13 -3
  77. data/test/test_helper.rb +9 -2
  78. data/ui/helpers/developer_mode_helper.rb +2 -7
  79. metadata +26 -11
  80. data/lib/new_relic/control/configuration.rb +0 -206
  81. data/test/new_relic/control/configuration_test.rb +0 -77
@@ -36,14 +36,12 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
36
36
  assert_equal :passenger, e.environment
37
37
  assert_nil e.dispatcher_instance_id, "dispatcher instance id should be nil: #{e.dispatcher_instance_id}"
38
38
 
39
- NewRelic::Control.instance.instance_eval do
40
- @settings['app_name'] = 'myapp'
39
+ with_config(:app_name => 'myapp') do
40
+ e = NewRelic::LocalEnvironment.new
41
+ assert_equal :passenger, e.environment
42
+ assert_nil e.dispatcher_instance_id
41
43
  end
42
44
 
43
- e = NewRelic::LocalEnvironment.new
44
- assert_equal :passenger, e.environment
45
- assert_nil e.dispatcher_instance_id
46
-
47
45
  ::Passenger.class_eval { remove_const :AbstractServer }
48
46
  end
49
47
 
@@ -132,11 +132,11 @@ EOL
132
132
  def test_guid_is_set_in_footer_when_token_is_set
133
133
  guid = 'abcdefgfedcba'
134
134
  NewRelic::TransactionSample.any_instance.stubs(:generate_guid).returns(guid)
135
- NewRelic::Control.instance.stubs(:apdex_t).returns(0.0001)
136
135
  set_cookie "NRAGENT=tk=token"
137
- get '/'
138
-
139
- assert(last_response.body.include?(guid), last_response.body)
136
+ with_config(:apdex_t => 0.0001) do
137
+ get '/'
138
+ assert(last_response.body.include?(guid), last_response.body)
139
+ end
140
140
  end
141
141
  end
142
142
  else
@@ -14,32 +14,38 @@ class DeveloperModeTest < Test::Unit::TestCase
14
14
  mock_app = lambda { |env| [500, {}, "Don't touch me!"] }
15
15
  NewRelic::Rack::DeveloperMode.new(mock_app)
16
16
  end
17
-
17
+
18
18
  def setup
19
+ @test_config = { 'developer_mode' => true }
20
+ NewRelic::Agent.config.apply_config(@test_config)
19
21
  @sampler = NewRelic::Agent::TransactionSampler.new
20
22
  run_sample_trace_on(@sampler, '/here')
21
23
  run_sample_trace_on(@sampler, '/there')
22
24
  run_sample_trace_on(@sampler, '/somewhere')
23
25
  NewRelic::Agent.instance.stubs(:transaction_sampler).returns(@sampler)
24
26
  end
25
-
27
+
28
+ def teardown
29
+ NewRelic::Agent.config.remove_config(@test_config)
30
+ end
31
+
26
32
  def test_index_displays_all_samples
27
33
  get '/newrelic'
28
-
34
+
29
35
  assert last_response.ok?
30
36
  assert last_response.body.include?('/here')
31
37
  assert last_response.body.include?('/there')
32
- assert last_response.body.include?('/somewhere')
38
+ assert last_response.body.include?('/somewhere')
33
39
  end
34
40
 
35
41
  def test_show_sample_summary_displays_sample_details
36
42
  get "/newrelic/show_sample_summary?id=#{@sampler.samples[0].sample_id}"
37
-
43
+
38
44
  assert last_response.ok?
39
45
  assert last_response.body.include?('/here')
40
46
  assert last_response.body.include?('SandwichesController')
41
- assert last_response.body.include?('index')
42
- end
47
+ assert last_response.body.include?('index')
48
+ end
43
49
 
44
50
  def test_explain_sql_displays_query_plan
45
51
  sample = @sampler.samples[0]
@@ -5,6 +5,8 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
5
5
  ::SQL_STATEMENT = "SELECT * from sandwiches"
6
6
 
7
7
  def setup
8
+ @test_config = { 'developer_mode' => true }
9
+ NewRelic::Agent.config.apply_config(@test_config)
8
10
  @connection_stub = Mocha::Mockery.instance.named_mock('connection')
9
11
  @connection_stub.stubs(:execute).returns([['QUERY RESULT']])
10
12
 
@@ -12,6 +14,10 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
12
14
  @t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
13
15
  end
14
16
 
17
+ def teardown
18
+ NewRelic::Agent.config.remove_config(@test_config)
19
+ end
20
+
15
21
  def test_be_recorded
16
22
  assert_not_nil @t
17
23
  end
@@ -78,7 +84,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
78
84
 
79
85
  def test_have_explains
80
86
  s = @t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
81
-
87
+
82
88
  s.each_segment do |segment|
83
89
  if segment.params[:explain_plan]
84
90
  explanation = segment.params[:explain_plan]
@@ -138,7 +144,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
138
144
  s.to_s
139
145
  end
140
146
  end
141
-
147
+
142
148
  def test_to_s_includes_keys
143
149
  s = @t.prepare_to_send(:explain_sql => 0.1)
144
150
  s.params[:fake_key] = 'a fake param'
@@ -1,10 +1,15 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # print commands in this script as they're invoked
4
- set -x
4
+ #set -x
5
5
  # fail if any command fails
6
6
  set -e
7
7
 
8
+ . "$HOME/.rvm/scripts/rvm"
9
+
10
+ #rvm 1.9.3
11
+
12
+
8
13
  if [ "x$BUILD_NUMBER" == "x" ]; then
9
14
  echo '$BUILD_NUMBER is undefined'
10
15
  echo 'setting $BUILD_NUMBER to alpha'
@@ -12,7 +17,7 @@ if [ "x$BUILD_NUMBER" == "x" ]; then
12
17
  fi
13
18
 
14
19
  SHA1=`git log --pretty=format:'%h' -n 1`
15
- echo "building gem for commit $SHA"
20
+ echo "building gem for commit $SHA1"
16
21
 
17
22
  if [[ `gem list jeweler | grep [j]eweler | wc -l` -eq 1 ]]; then
18
23
  echo "detected jeweler. skipping install"
@@ -28,7 +33,8 @@ mkdir gems
28
33
 
29
34
  # FIXME: don't include the $SHA1 since some of our builds systems are confused
30
35
  # by this.
31
- BUILD_ID=$BUILD_NUMBER #.$SHA1
36
+ #BUILD_ID="$SHA1.$BUILD_NUMBER" #.$SHA1
37
+ BUILD_ID="$BUILD_NUMBER" #.$SHA1
32
38
 
33
39
  # rewrite the version file, setting the patch identifier to include the
34
40
  # BUILD_ID
data/test/script/ci.sh CHANGED
@@ -29,12 +29,22 @@ set -e
29
29
  if [ "x$RUBY" == "x" ]; then
30
30
  echo '$RUBY is undefined'
31
31
  echo 'defaulting to 1.9.3'
32
- RUBY=1.9.3
32
+ export RUBY=1.9.3
33
33
  fi
34
34
  if [ "x$BRANCH" == "x" ]; then
35
35
  echo '$BRANCH is undefined'
36
36
  echo 'defaulting to rails31'
37
- BRANCH=rails31
37
+ export BRANCH=rails31
38
+ fi
39
+
40
+ if [ "x$JOB_NAME" == "x" ]; then
41
+ echo '$JOB_NAME is undefined'
42
+ echo 'defaulting to clrun'
43
+ export PROJECT_NAME=clrun
44
+ else
45
+ CLEANSED_NAME=`echo $JOB_NAME | sed "s/label//" | sed "s/Portland//" | sed "s/BRANCH//" | sed "s/RUBY//" | sed "s/[=\/,\._]//g" | sed "s/ReleaseCandidate/RC/"`
46
+ echo "setting PROJECT_NAME to $CLEANSED_NAME"
47
+ export PROJECT_NAME="$CLEANSED_NAME"
38
48
  fi
39
49
 
40
50
  . "$HOME/.rvm/scripts/rvm"
@@ -73,7 +83,7 @@ mysql: &mysql
73
83
  socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
74
84
  username: root
75
85
  host: localhost
76
- database: <%= [ 'rails_blog', ENV['BRANCH'], ENV['RUBY'] ].compact.join('_') %>
86
+ database: <%= [ 'rails_blog', ENV['BRANCH'], ENV['RUBY'], ENV['PROJECT_NAME'] ].compact.join('_') %>
77
87
 
78
88
  # Shared properties for postgres. This won't work with our schema but
79
89
  # Does work with agent tests
data/test/test_helper.rb CHANGED
@@ -14,7 +14,7 @@ require 'rubygems'
14
14
 
15
15
  begin
16
16
  require 'config/environment'
17
- # require File.join(File.dirname(__FILE__),'..','..','rpm_test_app','config','environment')
17
+ # require File.join(File.dirname(__FILE__),'..','..','rpm_test_app','config','environment')
18
18
  begin
19
19
  require 'test_help'
20
20
  rescue LoadError
@@ -24,7 +24,7 @@ begin
24
24
  rescue LoadError
25
25
  # To run the tests against a standalone agent build, you need to
26
26
  # add a rails app to the load path. It can be 2.* to 3.*. It should
27
- # referenc newrelic_rpm in the Gemfile with a :path option pointing
27
+ # referenc newrelic_rpm in the Gemfile with a :path option pointing
28
28
  # to this work directory.
29
29
  guess = File.expand_path("../../../rpm", __FILE__)
30
30
  if $LOAD_PATH.include? guess
@@ -118,6 +118,13 @@ def compare_metrics(expected, actual)
118
118
  assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}")
119
119
  end
120
120
 
121
+ def with_config(config_hash, level=0)
122
+ config = NewRelic::Agent::Configuration::DottedHash.new(config_hash)
123
+ NewRelic::Agent.config.apply_config(config, level)
124
+ yield
125
+ NewRelic::Agent.config.remove_config(config)
126
+ end
127
+
121
128
  module TransactionSampleTestHelper
122
129
  def make_sql_transaction(*sql)
123
130
  sampler = NewRelic::Agent::TransactionSampler.new
@@ -70,7 +70,7 @@ module NewRelic::DeveloperModeHelper
70
70
  rescue
71
71
  # catch all other exceptions. We're going to create an invalid link below, but that's okay.
72
72
  end
73
- if using_textmate?
73
+ if NewRelic::Agent.config[:textmate]
74
74
  "txmt://open?url=file://#{file}&line=#{line}"
75
75
  else
76
76
  "show_source?file=#{file}&amp;line=#{line}&amp;anchor=selected_line"
@@ -105,7 +105,7 @@ module NewRelic::DeveloperModeHelper
105
105
 
106
106
  # write a link to the source for a trace
107
107
  def link_to_source(trace)
108
- image_url = 'file/images/' + (using_textmate? ? "textmate.png" : "file_icon.png")
108
+ image_url = 'file/images/' + (NewRelic::Agent.config[:textmate] ? "textmate.png" : "file_icon.png")
109
109
 
110
110
  link_to "<img src=#{image_url} alt=\"View Source\" title=\"View Source\"/>", url_for_source(application_caller(trace))
111
111
  end
@@ -239,11 +239,6 @@ module NewRelic::DeveloperModeHelper
239
239
  end
240
240
  end
241
241
 
242
- def using_textmate?
243
- NewRelic::Control.instance.use_textmate?
244
- end
245
-
246
-
247
242
  def render_segment_details(segment, depth=0)
248
243
  @detail_segment_count ||= 0
249
244
  @detail_segment_count += 1
metadata CHANGED
@@ -1,24 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
4
+ hash: -3470574200
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 4
9
+ - 2
10
+ - beta
9
11
  - 1
10
- version: 3.4.1
12
+ version: 3.4.2.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Bill Kayser
14
16
  - Jon Guymon
15
17
  - Justin George
16
18
  - Darin Swanson
19
+ - Rob Saul
17
20
  autorequire:
18
21
  bindir: bin
19
22
  cert_chain: []
20
23
 
21
- date: 2012-07-26 00:00:00 Z
24
+ date: 2012-08-31 00:00:00 Z
22
25
  dependencies:
23
26
  - !ruby/object:Gem::Dependency
24
27
  name: jeweler
@@ -72,9 +75,9 @@ description: |
72
75
 
73
76
  email: support@newrelic.com
74
77
  executables:
78
+ - newrelic
75
79
  - mongrel_rpm
76
80
  - newrelic_cmd
77
- - newrelic
78
81
  extensions: []
79
82
 
80
83
  extra_rdoc_files:
@@ -86,6 +89,7 @@ files:
86
89
  - CHANGELOG
87
90
  - LICENSE
88
91
  - README.rdoc
92
+ - ReleaseNotes.md
89
93
  - bin/mongrel_rpm
90
94
  - bin/newrelic
91
95
  - bin/newrelic_cmd
@@ -101,6 +105,12 @@ files:
101
105
  - lib/new_relic/agent/browser_monitoring.rb
102
106
  - lib/new_relic/agent/busy_calculator.rb
103
107
  - lib/new_relic/agent/chained_call.rb
108
+ - lib/new_relic/agent/configuration.rb
109
+ - lib/new_relic/agent/configuration/defaults.rb
110
+ - lib/new_relic/agent/configuration/environment_source.rb
111
+ - lib/new_relic/agent/configuration/manager.rb
112
+ - lib/new_relic/agent/configuration/server_source.rb
113
+ - lib/new_relic/agent/configuration/yaml_source.rb
104
114
  - lib/new_relic/agent/database.rb
105
115
  - lib/new_relic/agent/error_collector.rb
106
116
  - lib/new_relic/agent/instrumentation.rb
@@ -155,7 +165,6 @@ files:
155
165
  - lib/new_relic/commands/install.rb
156
166
  - lib/new_relic/control.rb
157
167
  - lib/new_relic/control/class_methods.rb
158
- - lib/new_relic/control/configuration.rb
159
168
  - lib/new_relic/control/frameworks.rb
160
169
  - lib/new_relic/control/frameworks/external.rb
161
170
  - lib/new_relic/control/frameworks/merb.rb
@@ -212,6 +221,10 @@ files:
212
221
  - test/new_relic/agent/beacon_configuration_test.rb
213
222
  - test/new_relic/agent/browser_monitoring_test.rb
214
223
  - test/new_relic/agent/busy_calculator_test.rb
224
+ - test/new_relic/agent/configuration/environment_source_test.rb
225
+ - test/new_relic/agent/configuration/manager_test.rb
226
+ - test/new_relic/agent/configuration/server_source_test.rb
227
+ - test/new_relic/agent/configuration/yaml_source_test.rb
215
228
  - test/new_relic/agent/database_test.rb
216
229
  - test/new_relic/agent/error_collector/notice_error_test.rb
217
230
  - test/new_relic/agent/error_collector_test.rb
@@ -248,7 +261,7 @@ files:
248
261
  - test/new_relic/collection_helper_test.rb
249
262
  - test/new_relic/command/deployments_test.rb
250
263
  - test/new_relic/control/class_methods_test.rb
251
- - test/new_relic/control/configuration_test.rb
264
+ - test/new_relic/control/frameworks/rails_test.rb
252
265
  - test/new_relic/control/logging_methods_test.rb
253
266
  - test/new_relic/control_test.rb
254
267
  - test/new_relic/delayed_job_injection_test.rb
@@ -401,12 +414,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
401
414
  required_rubygems_version: !ruby/object:Gem::Requirement
402
415
  none: false
403
416
  requirements:
404
- - - ">="
417
+ - - ">"
405
418
  - !ruby/object:Gem::Version
406
- hash: 3
419
+ hash: 25
407
420
  segments:
408
- - 0
409
- version: "0"
421
+ - 1
422
+ - 3
423
+ - 1
424
+ version: 1.3.1
410
425
  requirements: []
411
426
 
412
427
  rubyforge_project:
@@ -1,206 +0,0 @@
1
- module NewRelic
2
- class Control
3
- # used to contain methods to look up settings from the
4
- # configuration located in newrelic.yml
5
- module Configuration
6
- def settings
7
- unless @settings
8
- @settings = (@yaml && merge_defaults(@yaml[env])) || {}
9
- # At the time we bind the settings, we also need to run this little piece
10
- # of magic which allows someone to augment the id with the app name, necessary
11
- if self['multi_homed'] && app_names.size > 0
12
- if @local_env.dispatcher_instance_id
13
- @local_env.dispatcher_instance_id << ":#{app_names.first}"
14
- else
15
- @local_env.dispatcher_instance_id = app_names.first
16
- end
17
- end
18
-
19
- end
20
- @settings
21
- end
22
-
23
- def merge_defaults(settings_hash)
24
- s = {
25
- 'host' => 'collector.newrelic.com',
26
- 'ssl' => false,
27
- 'log_level' => 'info',
28
- 'apdex_t' => 0.5
29
- }
30
- s.merge! settings_hash if settings_hash
31
- # monitor_daemons replaced with agent_enabled
32
- s['agent_enabled'] = s.delete('monitor_daemons') if s['agent_enabled'].nil? && s.include?('monitor_daemons')
33
- s
34
- end
35
-
36
- # Merge the given options into the config options.
37
- # They might be a nested hash
38
- def merge_options(options, hash=self)
39
- options.each do |key, val|
40
- case
41
- when key == :config then next
42
- when val.is_a?(Hash)
43
- merge_options(val, hash[key.to_s] ||= {})
44
- when val.nil?
45
- hash.delete(key.to_s)
46
- else
47
- hash[key.to_s] = val
48
- end
49
- end
50
- end
51
-
52
- def merge_server_side_config(data)
53
- remove_server_controlled_configs
54
- config = Hash.new
55
- data.each_pair do |key, value|
56
- if key.include?('.')
57
- key = key.split('.')
58
- config[key.first] ||= Hash.new
59
- config[key.first][key[1]] = value
60
- else
61
- config[key] = value
62
- end
63
- end
64
- merge_options(config)
65
- end
66
-
67
- def remove_server_controlled_configs
68
- settings.delete('transaction_tracer')
69
- settings.delete('slow_sql')
70
- settings.delete('error_collector')
71
- settings.delete('capture_params')
72
- end
73
-
74
- def [](key)
75
- fetch(key)
76
- end
77
-
78
- def []=(key, value)
79
- settings[key] = value
80
- end
81
-
82
- def fetch(key, default=nil)
83
- settings.fetch(key, default)
84
- end
85
-
86
- def apdex_t
87
- # Always initialized with a default
88
- @apdex_t_float ||= fetch('apdex_t').to_f
89
- end
90
-
91
- def license_key
92
- env_setting = ENV['NEW_RELIC_LICENSE_KEY'] || ENV['NEWRELIC_LICENSE_KEY']
93
- fetch('license_key', env_setting)
94
- end
95
-
96
- def capture_params
97
- fetch('capture_params')
98
- end
99
-
100
- # True if we are sending data to the server, monitoring production
101
- def monitor_mode?
102
- fetch('monitor_mode', fetch('enabled'))
103
- end
104
-
105
- # True if we are capturing data and displaying in /newrelic
106
- def developer_mode?
107
- fetch('developer_mode', fetch('developer'))
108
- end
109
-
110
- # whether we should install the
111
- # NewRelic::Rack::BrowserMonitoring middleware automatically on
112
- # Rails applications
113
- def browser_monitoring_auto_instrument?
114
- fetch('browser_monitoring', {}).fetch('auto_instrument', true)
115
- end
116
-
117
- def multi_threaded?
118
- fetch('multi_threaded')
119
- end
120
-
121
- def disable_serialization?
122
- fetch('disable_serialization', true)
123
- end
124
- def disable_serialization=(b)
125
- self['disable_serialization'] = b
126
- end
127
-
128
- # True if we should view files in textmate
129
- def use_textmate?
130
- fetch('textmate')
131
- end
132
-
133
- # defaults to 2MiB
134
- def post_size_limit
135
- fetch('post_size_limit', 2 * 1024 * 1024)
136
- end
137
-
138
- # Configuration option of the same name to indicate that we should connect
139
- # to New Relic synchronously on startup. This means when the agent is loaded it
140
- # won't return without trying to set up the server connection at least once
141
- # which can make startup take longer. Defaults to false.
142
- def sync_startup
143
- fetch('sync_startup', false)
144
- end
145
-
146
- # Configuration option of the same name to indicate that we should flush
147
- # data to the server on exiting. Defaults to true.
148
- def send_data_on_exit
149
- fetch('send_data_on_exit', true)
150
- end
151
-
152
- def dispatcher_instance_id
153
- self['dispatcher_instance_id'] || @local_env.dispatcher_instance_id
154
- end
155
-
156
- def dispatcher
157
- (self['dispatcher'] && self['dispatcher'].to_sym) || @local_env.dispatcher
158
- end
159
- def app_names
160
- case self['app_name']
161
- when Array then self['app_name']
162
- when String then self['app_name'].split(';')
163
- else [ env ]
164
- end
165
- end
166
- def validate_seed
167
- self['validate_seed'] || ENV['NR_VALIDATE_SEED']
168
- end
169
- def validate_token
170
- self['validate_token'] || ENV['NR_VALIDATE_TOKEN']
171
- end
172
-
173
- def use_ssl?
174
- @use_ssl = fetch('ssl', false) unless @use_ssl
175
- @use_ssl
176
- end
177
-
178
- def log_file_path
179
- fetch('log_file_path', 'log/')
180
- end
181
-
182
- # only verify certificates if you're very sure you want this
183
- # level of security, it includes possibly app-crashing dns
184
- # lookups every connection to the server
185
- def verify_certificate?
186
- unless @verify_certificate
187
- unless use_ssl?
188
- @verify_certificate = false
189
- else
190
- @verify_certificate = fetch('verify_certificate', false)
191
- end
192
- end
193
- @verify_certificate
194
- end
195
-
196
- def disable_backtrace_cleanup?
197
- fetch('disable_backtrace_cleanup')
198
- end
199
-
200
- def has_slow_sql_config?
201
- self['slow_sql'] && self['slow_sql'].has_key?('enabled')
202
- end
203
- end
204
- include Configuration
205
- end
206
- end