newrelic_rpm 3.12.0.288 → 3.12.1.298

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +42 -0
  3. data/Rakefile +5 -5
  4. data/lib/new_relic/agent.rb +23 -11
  5. data/lib/new_relic/agent/agent.rb +17 -67
  6. data/lib/new_relic/agent/agent_logger.rb +9 -33
  7. data/lib/new_relic/agent/attribute_processing.rb +2 -2
  8. data/lib/new_relic/agent/autostart.rb +1 -18
  9. data/lib/new_relic/agent/aws_info.rb +90 -0
  10. data/lib/new_relic/agent/configuration/default_source.rb +45 -16
  11. data/lib/new_relic/agent/configuration/dotted_hash.rb +0 -2
  12. data/lib/new_relic/agent/configuration/high_security_source.rb +1 -1
  13. data/lib/new_relic/agent/configuration/manager.rb +1 -31
  14. data/lib/new_relic/agent/configuration/server_source.rb +0 -1
  15. data/lib/new_relic/agent/configuration/yaml_source.rb +26 -7
  16. data/lib/new_relic/agent/database.rb +5 -5
  17. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +0 -1
  18. data/lib/new_relic/agent/datastores/metric_helper.rb +15 -3
  19. data/lib/new_relic/agent/error_collector.rb +28 -18
  20. data/lib/new_relic/agent/instrumentation/active_record.rb +8 -2
  21. data/lib/new_relic/agent/instrumentation/active_record_4.rb +1 -0
  22. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +49 -1
  23. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
  24. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +9 -0
  25. data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
  26. data/lib/new_relic/agent/instrumentation/resque.rb +8 -20
  27. data/lib/new_relic/agent/instrumentation/sequel.rb +0 -2
  28. data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -0
  29. data/lib/new_relic/agent/log_once.rb +39 -0
  30. data/lib/new_relic/agent/memory_logger.rb +8 -1
  31. data/lib/new_relic/agent/method_tracer.rb +5 -1
  32. data/lib/new_relic/agent/new_relic_service.rb +13 -14
  33. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -0
  34. data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -3
  35. data/lib/new_relic/agent/sql_sampler.rb +4 -15
  36. data/lib/new_relic/agent/stats_engine/metric_stats.rb +1 -1
  37. data/lib/new_relic/agent/stats_engine/samplers.rb +0 -6
  38. data/lib/new_relic/agent/stats_engine/stats_hash.rb +92 -35
  39. data/lib/new_relic/agent/system_info.rb +53 -6
  40. data/lib/new_relic/agent/transaction.rb +4 -13
  41. data/lib/new_relic/agent/transaction/attributes.rb +2 -0
  42. data/lib/new_relic/agent/transaction/trace_node.rb +1 -1
  43. data/lib/new_relic/agent/transaction_event_aggregator.rb +1 -9
  44. data/lib/new_relic/agent/transaction_sample_builder.rb +0 -6
  45. data/lib/new_relic/agent/transaction_sampler.rb +1 -13
  46. data/lib/new_relic/agent/utilization_data.rb +29 -42
  47. data/lib/new_relic/agent/worker_loop.rb +2 -3
  48. data/lib/new_relic/cli/commands/deployments.rb +5 -0
  49. data/lib/new_relic/coerce.rb +1 -1
  50. data/lib/new_relic/collection_helper.rb +0 -2
  51. data/lib/new_relic/control/instance_methods.rb +4 -1
  52. data/lib/new_relic/control/instrumentation.rb +1 -9
  53. data/lib/new_relic/control/server_methods.rb +3 -56
  54. data/lib/new_relic/helper.rb +1 -0
  55. data/lib/new_relic/language_support.rb +21 -0
  56. data/lib/new_relic/local_environment.rb +1 -0
  57. data/lib/new_relic/metric_data.rb +1 -1
  58. data/lib/new_relic/noticed_error.rb +1 -1
  59. data/lib/new_relic/rack/agent_middleware.rb +9 -0
  60. data/lib/new_relic/version.rb +1 -1
  61. data/lib/sequel/extensions/newrelic_instrumentation.rb +2 -2
  62. data/lib/tasks/multiverse.rake +2 -0
  63. data/lib/tasks/multiverse.rb +50 -0
  64. data/test/agent_helper.rb +24 -5
  65. data/test/fixtures/cross_agent_tests/aws.json +218 -0
  66. data/test/fixtures/cross_agent_tests/docker_container_id/cases.json +40 -11
  67. data/test/fixtures/cross_agent_tests/docker_container_id/invalid-characters.txt +9 -0
  68. data/test/fixtures/cross_agent_tests/docker_container_id/invalid-length.txt +9 -0
  69. data/test/multiverse/lib/multiverse/suite.rb +3 -0
  70. data/test/multiverse/suites/active_record/Envfile +18 -12
  71. data/test/multiverse/suites/active_record/active_record_test.rb +203 -9
  72. data/test/multiverse/suites/active_record/app/models/models.rb +16 -9
  73. data/test/multiverse/suites/active_record/config/database.rb +3 -2
  74. data/test/multiverse/suites/active_record/db/migrate/20150413011200_add_timestamps_to_orders.rb +16 -0
  75. data/test/multiverse/suites/active_record/db/migrate/20150414084400_create_groups.rb +21 -0
  76. data/test/multiverse/suites/agent_only/agent_attributes_test.rb +26 -3
  77. data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -1
  78. data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +68 -0
  79. data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
  80. data/test/multiverse/suites/agent_only/ssl_test.rb +2 -1
  81. data/test/multiverse/suites/agent_only/start_up_test.rb +20 -1
  82. data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +43 -104
  83. data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +2 -2
  84. data/test/multiverse/suites/high_security/high_security_test.rb +2 -2
  85. data/test/multiverse/suites/rack/http_response_code_test.rb +4 -4
  86. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
  87. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +38 -0
  88. data/test/multiverse/suites/sidekiq/test_worker.rb +13 -1
  89. data/test/new_relic/agent/agent_test.rb +0 -70
  90. data/test/new_relic/agent/attribute_processing_test.rb +10 -5
  91. data/test/new_relic/agent/autostart_test.rb +0 -31
  92. data/test/new_relic/agent/aws_info_test.rb +61 -0
  93. data/test/new_relic/agent/configuration/manager_test.rb +1 -1
  94. data/test/new_relic/agent/configuration/yaml_source_test.rb +25 -1
  95. data/test/new_relic/agent/database_test.rb +16 -15
  96. data/test/new_relic/agent/datastores/metric_helper_test.rb +35 -0
  97. data/test/new_relic/agent/error_collector_test.rb +28 -5
  98. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +23 -20
  99. data/test/new_relic/agent/memory_logger_test.rb +18 -0
  100. data/test/new_relic/agent/new_relic_service_test.rb +2 -9
  101. data/test/new_relic/agent/rpm_agent_test.rb +0 -10
  102. data/test/new_relic/agent/sql_sampler_test.rb +4 -4
  103. data/test/new_relic/agent/stats_engine/stats_hash_test.rb +18 -22
  104. data/test/new_relic/agent/system_info_test.rb +81 -23
  105. data/test/new_relic/agent/transaction_event_aggregator_test.rb +0 -7
  106. data/test/new_relic/agent/transaction_test.rb +1 -1
  107. data/test/new_relic/agent/utilization_data_test.rb +135 -6
  108. data/test/new_relic/cli/commands/deployments_test.rb +12 -2
  109. data/test/new_relic/control/instrumentation_test.rb +0 -15
  110. data/test/new_relic/control_test.rb +0 -63
  111. data/test/new_relic/fake_collector.rb +4 -17
  112. data/test/new_relic/language_support_test.rb +30 -0
  113. data/test/new_relic/license_test.rb +2 -0
  114. data/test/new_relic/multiverse_helpers.rb +12 -0
  115. data/test/performance/suites/stats_hash.rb +6 -5
  116. data/test/test_helper.rb +1 -2
  117. metadata +13 -4
  118. data/lib/new_relic/agent/shim_agent.rb +0 -33
  119. data/test/new_relic/agent/shim_agent_test.rb +0 -20
@@ -2,7 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'new_relic/agent/database'
6
5
  require 'new_relic/agent/database/obfuscation_helpers'
7
6
 
8
7
  module NewRelic
@@ -44,10 +44,12 @@ module NewRelic
44
44
  end
45
45
  end
46
46
 
47
- def self.metrics_for(product, operation, collection = nil)
47
+ def self.metrics_for(product, operation, collection = nil, generic_product = nil)
48
48
  if overrides = overridden_operation_and_collection
49
- operation = overrides[0] || operation
50
- collection = overrides[1] || collection
49
+ if should_override?(overrides, product, generic_product)
50
+ operation = overrides[0] || operation
51
+ collection = overrides[1] || collection
52
+ end
51
53
  end
52
54
 
53
55
  suffix = all_suffix
@@ -80,6 +82,16 @@ module NewRelic
80
82
  txn ? txn.instrumentation_state[:datastore_override] : nil
81
83
  end
82
84
 
85
+ # If the override declared a product affiliation, abide by that
86
+ # ActiveRecord has database-specific product names, so we recognize
87
+ # it by the generic_product it passes.
88
+ def self.should_override?(overrides, product, generic_product)
89
+ override_product = overrides[2]
90
+
91
+ override_product.nil? ||
92
+ override_product == product ||
93
+ override_product == generic_product
94
+ end
83
95
  end
84
96
  end
85
97
  end
@@ -9,16 +9,11 @@ module NewRelic
9
9
  class ErrorCollector
10
10
  include NewRelic::CollectionHelper
11
11
 
12
- # Defined the methods that need to be stubbed out when the
13
- # agent is disabled
14
- module Shim #:nodoc:
15
- def notice_error(*args); end
16
- end
17
-
18
12
  # Maximum possible length of the queue - defaults to 20, may be
19
13
  # made configurable in the future. This is a tradeoff between
20
14
  # memory and data retention
21
15
  MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
16
+ EXCEPTION_TAG_IVAR = :'@__nr_seen_exception' unless defined? EXCEPTION_TAG_IVAR
22
17
 
23
18
  attr_accessor :errors
24
19
 
@@ -113,14 +108,30 @@ module NewRelic
113
108
  false
114
109
  end
115
110
 
116
- def seen?(txn, exception)
117
- error_ids = txn.nil? ? [] : txn.noticed_error_ids
118
- error_ids.include?(exception.object_id)
111
+ # Calling instance_variable_set on a wrapped Java object in JRuby will
112
+ # generate a warning unless that object's class has already been marked
113
+ # as persistent, so we skip tagging of exception objects that are actually
114
+ # wrapped Java objects on JRuby.
115
+ #
116
+ # See https://github.com/jruby/jruby/wiki/Persistence
117
+ #
118
+ def exception_is_java_object?(exception)
119
+ NewRelic::LanguageSupport.jruby? && exception.respond_to?(:java_class)
119
120
  end
120
121
 
121
- def tag_as_seen(state, exception)
122
- txn = state.current_transaction
123
- txn.noticed_error_ids << exception.object_id if txn
122
+ def exception_tagged?(exception)
123
+ return false if exception_is_java_object?(exception)
124
+ exception.instance_variable_get(EXCEPTION_TAG_IVAR)
125
+ end
126
+
127
+ def tag_exception(exception)
128
+ return if exception_is_java_object?(exception)
129
+ return if exception.frozen?
130
+ begin
131
+ exception.instance_variable_set(EXCEPTION_TAG_IVAR, true)
132
+ rescue => e
133
+ NewRelic::Agent.logger.warn("Failed to tag exception: #{exception}: ", e)
134
+ end
124
135
  end
125
136
 
126
137
  def blamed_metric_name(txn, options)
@@ -158,11 +169,11 @@ module NewRelic
158
169
  end
159
170
  end
160
171
 
161
- def skip_notice_error?(state, exception)
172
+ def skip_notice_error?(exception)
162
173
  disabled? ||
163
174
  error_is_ignored?(exception) ||
164
175
  exception.nil? ||
165
- seen?(state.current_transaction, exception)
176
+ exception_tagged?(exception)
166
177
  end
167
178
 
168
179
  # calls a method on an object, if it responds to it - used for
@@ -198,13 +209,12 @@ module NewRelic
198
209
  end
199
210
 
200
211
  # See NewRelic::Agent.notice_error for options and commentary
201
-
202
212
  def notice_error(exception, options={}) #THREAD_LOCAL_ACCESS
203
- state = ::NewRelic::Agent::TransactionState.tl_get
213
+ return if skip_notice_error?(exception)
204
214
 
205
- return if skip_notice_error?(state, exception)
215
+ tag_exception(exception)
206
216
 
207
- tag_as_seen(state, exception)
217
+ state = ::NewRelic::Agent::TransactionState.tl_get
208
218
  increment_error_count!(state, exception, options)
209
219
  add_to_error_queue(create_noticed_error(exception, options))
210
220
 
@@ -17,6 +17,10 @@ module NewRelic
17
17
  end
18
18
 
19
19
  def self.insert_instrumentation
20
+ if defined?(::ActiveRecord::VERSION::MAJOR) && ::ActiveRecord::VERSION::MAJOR.to_i >= 3
21
+ ::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_writer_methods
22
+ end
23
+
20
24
  ::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
21
25
  include ::NewRelic::Agent::Instrumentation::ActiveRecord
22
26
  end
@@ -58,10 +62,10 @@ module NewRelic
58
62
 
59
63
  NewRelic::Agent.instance.transaction_sampler.notice_sql(sql,
60
64
  @config, elapsed_time,
61
- state, &EXPLAINER)
65
+ state, EXPLAINER)
62
66
  NewRelic::Agent.instance.sql_sampler.notice_sql(sql, scoped_metric,
63
67
  @config, elapsed_time,
64
- state, &EXPLAINER)
68
+ state, EXPLAINER)
65
69
  end
66
70
  end
67
71
  end
@@ -88,6 +92,8 @@ DependencyDetection.defer do
88
92
  end
89
93
 
90
94
  executes do
95
+ require 'new_relic/agent/instrumentation/active_record_helper'
96
+
91
97
  if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
92
98
  ActiveSupport.on_load(:active_record) do
93
99
  ::NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
@@ -24,5 +24,6 @@ DependencyDetection.defer do
24
24
  executes do
25
25
  ActiveSupport::Notifications.subscribe('sql.active_record',
26
26
  NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.new)
27
+ ::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_writer_methods
27
28
  end
28
29
  end
@@ -11,6 +11,53 @@ module NewRelic
11
11
  module ActiveRecordHelper
12
12
  module_function
13
13
 
14
+ # Used by both the AR 3.x and 4.x instrumentation
15
+ def instrument_writer_methods
16
+ ::ActiveRecord::Base.class_eval do
17
+ alias_method :save_without_newrelic, :save
18
+
19
+ def save(*args, &blk)
20
+ ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
21
+ save_without_newrelic(*args, &blk)
22
+ end
23
+ end
24
+
25
+ alias_method :save_without_newrelic!, :save!
26
+
27
+ def save!(*args, &blk)
28
+ ::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
29
+ save_without_newrelic!(*args, &blk)
30
+ end
31
+ end
32
+ end
33
+
34
+ ::ActiveRecord::Relation.class_eval do
35
+ alias_method :update_all_without_newrelic, :update_all
36
+
37
+ def update_all(*args, &blk)
38
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
39
+ update_all_without_newrelic(*args, &blk)
40
+ end
41
+ end
42
+
43
+ alias_method :delete_all_without_newrelic, :delete_all
44
+
45
+ def delete_all(*args, &blk)
46
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
47
+ delete_all_without_newrelic(*args, &blk)
48
+ end
49
+ end
50
+
51
+ alias_method :destroy_all_without_newrelic, :destroy_all
52
+
53
+ def destroy_all(*args, &blk)
54
+ ::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
55
+ destroy_all_without_newrelic(*args, &blk)
56
+ end
57
+ end
58
+ end
59
+ end
60
+
14
61
  ACTIVE_RECORD = "ActiveRecord".freeze unless defined?(ACTIVE_RECORD)
15
62
  OTHER = "other".freeze unless defined?(OTHER)
16
63
 
@@ -22,7 +69,8 @@ module NewRelic
22
69
 
23
70
  NewRelic::Agent::Datastores::MetricHelper.metrics_for(product,
24
71
  operation,
25
- model)
72
+ model,
73
+ ACTIVE_RECORD)
26
74
  end
27
75
 
28
76
  # @deprecated
@@ -59,12 +59,12 @@ module NewRelic
59
59
  NewRelic::Agent.instance.transaction_sampler \
60
60
  .notice_sql(event.payload[:sql], config,
61
61
  Helper.milliseconds_to_seconds(event.duration),
62
- state, &@explainer)
62
+ state, @explainer)
63
63
 
64
64
  NewRelic::Agent.instance.sql_sampler \
65
65
  .notice_sql(event.payload[:sql], metric, config,
66
66
  Helper.milliseconds_to_seconds(event.duration),
67
- state, &@explainer)
67
+ state, @explainer)
68
68
 
69
69
  # exit transaction trace node
70
70
  stack.pop_frame(state, frame, metric, event.end)
@@ -79,6 +79,15 @@ module NewRelic
79
79
  elsif ! (Hash === specifiers)
80
80
  ::NewRelic::Agent.logger.error "newrelic_#{property} takes an optional hash with :only and :except lists of actions (illegal argument type '#{specifiers.class}')"
81
81
  else
82
+ # symbolize the incoming values
83
+ specifiers = specifiers.inject({}) do |memo, (key, values)|
84
+ if values.is_a?(Array)
85
+ memo[key] = values.map(&:to_sym)
86
+ else
87
+ memo[key] = values.to_sym
88
+ end
89
+ memo
90
+ end
82
91
  self.newrelic_write_attr property, specifiers
83
92
  end
84
93
  end
@@ -76,7 +76,7 @@ DependencyDetection.defer do
76
76
  true
77
77
  end
78
78
  rescue => e
79
- ::NewRelic::Agent.logger.info("Could not determine if third party newrelic-grape gem is installed")
79
+ ::NewRelic::Agent.logger.info("Could not determine if third party newrelic-grape gem is installed", e)
80
80
  true
81
81
  end
82
82
  end
@@ -14,6 +14,14 @@ DependencyDetection.defer do
14
14
  ::NewRelic::Agent.logger.info 'Installing Resque instrumentation'
15
15
  end
16
16
 
17
+ executes do
18
+ if NewRelic::Agent.config[:'resque.use_ruby_dns'] && NewRelic::Agent.config[:dispatcher] == :resque
19
+ ::NewRelic::Agent.logger.info 'Requiring resolv-replace'
20
+ require 'resolv'
21
+ require 'resolv-replace'
22
+ end
23
+ end
24
+
17
25
  executes do
18
26
  module Resque
19
27
  module Plugins
@@ -62,26 +70,6 @@ DependencyDetection.defer do
62
70
  end
63
71
 
64
72
  if NewRelic::LanguageSupport.can_fork?
65
- # Resque::Worker#fork isn't around in Resque 2.x
66
- if NewRelic::VersionNumber.new(::Resque::VERSION) < NewRelic::VersionNumber.new("2.0.0")
67
- ::Resque::Worker.class_eval do
68
- if NewRelic::Agent.config[:'resque.use_harvest_lock']
69
- ::NewRelic::Agent.logger.info 'Installing Resque harvest/fork synchronization'
70
- def fork_with_newrelic(*args, &block)
71
- NewRelic::Agent.instance.synchronize_with_harvest do
72
- fork_without_newrelic(*args, &block)
73
-
74
- # Reached in parent, not expected in the child since Resque
75
- # uses the block form of fork
76
- end
77
- end
78
-
79
- alias_method :fork_without_newrelic, :fork
80
- alias_method :fork, :fork_with_newrelic
81
- end
82
- end
83
- end
84
-
85
73
  ::Resque.before_first_fork do
86
74
  NewRelic::Agent.manual_start(:dispatcher => :resque,
87
75
  :sync_startup => true,
@@ -3,8 +3,6 @@
3
3
  # This file is distributed under New Relic's license terms.
4
4
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
5
5
 
6
- require 'newrelic_rpm'
7
-
8
6
  DependencyDetection.defer do
9
7
  @name = :sequel
10
8
 
@@ -61,6 +61,12 @@ DependencyDetection.defer do
61
61
  config.server_middleware do |chain|
62
62
  chain.add NewRelic::SidekiqInstrumentation
63
63
  end
64
+
65
+ if config.respond_to?(:error_handlers)
66
+ config.error_handlers << Proc.new do |error, *_|
67
+ NewRelic::Agent.notice_error(error)
68
+ end
69
+ end
64
70
  end
65
71
  end
66
72
  end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ module NewRelic
6
+ module Agent
7
+ module LogOnce
8
+ NUM_LOG_ONCE_KEYS = 1000
9
+
10
+ def log_once(level, key, *msgs)
11
+ @already_logged_lock.synchronize do
12
+ return if @already_logged.include?(key)
13
+
14
+ if @already_logged.size >= NUM_LOG_ONCE_KEYS && key.kind_of?(String)
15
+ # The reason for preventing too many keys in `logged` is for
16
+ # memory concerns.
17
+ # The reason for checking the type of the key is that we always want
18
+ # to allow symbols to log, since there are very few of them.
19
+ # The assumption here is that you would NEVER pass dynamically-created
20
+ # symbols, because you would never create symbols dynamically in the
21
+ # first place, as that would already be a memory leak in most Rubies,
22
+ # even if we didn't hang on to them all here.
23
+ return
24
+ end
25
+
26
+ @already_logged[key] = true
27
+ end
28
+
29
+ self.send(level, *msgs)
30
+ end
31
+
32
+ def clear_already_logged
33
+ @already_logged_lock.synchronize do
34
+ @already_logged = {}
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,10 +4,17 @@
4
4
 
5
5
  # Base class for startup logging and testing in multiverse
6
6
 
7
+ require 'new_relic/agent/log_once'
8
+
7
9
  module NewRelic
8
10
  module Agent
9
11
  class MemoryLogger
12
+ include LogOnce
13
+
10
14
  def initialize
15
+ @already_logged_lock = Mutex.new
16
+ clear_already_logged
17
+
11
18
  @messages = []
12
19
  end
13
20
 
@@ -15,7 +22,7 @@ module NewRelic
15
22
  true
16
23
  end
17
24
 
18
- attr_accessor :messages, :level
25
+ attr_accessor :messages, :level, :log_formatter
19
26
 
20
27
  def fatal(*msgs, &blk)
21
28
  messages << [:fatal, msgs, blk]
@@ -2,7 +2,11 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'new_relic/control'
5
+ # This file may be independently required to set up method tracing prior to
6
+ # the full agent loading. In those cases, we do need at least this require to
7
+ # bootstrap things.
8
+ require 'new_relic/control' unless defined?(NewRelic::Control)
9
+
6
10
  require 'new_relic/agent/method_tracer_helpers'
7
11
 
8
12
  module NewRelic
@@ -181,10 +181,6 @@ module NewRelic
181
181
  :item_count => data.size)
182
182
  end
183
183
 
184
- def utilization_data(data)
185
- invoke_remote(:utilization_data, data)
186
- end
187
-
188
184
  # We do not compress if content is smaller than 64kb. There are
189
185
  # problems with bugs in Ruby in some versions that expose us
190
186
  # to a risk of segfaults if we compress aggressively.
@@ -303,18 +299,21 @@ module NewRelic
303
299
  end
304
300
  end
305
301
 
306
- # Return the Net::HTTP with proxy configuration given the NewRelic::Control::Server object.
307
302
  def create_http_connection
308
- proxy_server = control.proxy_server
309
- # Proxy returns regular HTTP if @proxy_host is nil (the default)
310
- http_class = Net::HTTP::Proxy(proxy_server.name, proxy_server.port,
311
- proxy_server.user, proxy_server.password)
312
-
313
- if proxy_server.name
314
- ::NewRelic::Agent.logger.debug("Using proxy server #{proxy_server.name}:#{proxy_server.port}")
303
+ if Agent.config[:proxy_host]
304
+ ::NewRelic::Agent.logger.debug("Using proxy server #{Agent.config[:proxy_host]}:#{Agent.config[:proxy_port]}")
305
+
306
+ proxy = Net::HTTP::Proxy(
307
+ Agent.config[:proxy_host],
308
+ Agent.config[:proxy_port],
309
+ Agent.config[:proxy_user],
310
+ Agent.config[:proxy_pass]
311
+ )
312
+ conn = proxy.new(@collector.name, @collector.port)
313
+ else
314
+ conn = Net::HTTP.new(@collector.name, @collector.port)
315
315
  end
316
316
 
317
- conn = http_class.new((@collector.ip || @collector.name), @collector.port)
318
317
  setup_connection_for_ssl(conn) if Agent.config[:ssl]
319
318
  setup_connection_timeouts(conn)
320
319
 
@@ -332,7 +331,7 @@ module NewRelic
332
331
  # connection if verify_peer is enabled
333
332
  def cert_file_path
334
333
  if path_override = NewRelic::Agent.config[:ca_bundle_path]
335
- NewRelic::Agent.logger.warn("Couldn't find CA bundle from configured ca_bundle_path: #{path_override}") unless File.exists? path_override
334
+ NewRelic::Agent.logger.warn("Couldn't find CA bundle from configured ca_bundle_path: #{path_override}") unless File.exist? path_override
336
335
  path_override
337
336
  else
338
337
  File.expand_path(File.join(control.newrelic_root, 'cert', 'cacert.pem'))