newrelic_rpm 6.1.0.352 → 6.6.0.358

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +34 -96
  4. data/CHANGELOG.md +139 -0
  5. data/lib/new_relic/agent/agent.rb +51 -134
  6. data/lib/new_relic/agent/commands/agent_command_router.rb +2 -21
  7. data/lib/new_relic/agent/configuration/default_source.rb +53 -41
  8. data/lib/new_relic/agent/configuration/environment_source.rb +4 -2
  9. data/lib/new_relic/agent/configuration/event_harvest_config.rb +39 -0
  10. data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
  11. data/lib/new_relic/agent/configuration/manager.rb +13 -1
  12. data/lib/new_relic/agent/configuration/server_source.rb +34 -1
  13. data/lib/new_relic/agent/connect/request_builder.rb +69 -0
  14. data/lib/new_relic/agent/connect/response_handler.rb +61 -0
  15. data/lib/new_relic/agent/error_collector.rb +2 -2
  16. data/lib/new_relic/agent/error_event_aggregator.rb +2 -1
  17. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -0
  18. data/lib/new_relic/agent/event_aggregator.rb +26 -32
  19. data/lib/new_relic/agent/hostname.rb +1 -1
  20. data/lib/new_relic/agent/inbound_request_monitor.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +24 -42
  22. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +46 -74
  23. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +70 -53
  24. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +168 -0
  25. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +41 -48
  26. data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +4 -4
  27. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  28. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +76 -0
  29. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_cable.rb +5 -6
  30. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_controller.rb +3 -3
  31. data/lib/new_relic/agent/instrumentation/{rails4 → rails_notifications}/action_view.rb +3 -3
  32. data/lib/new_relic/agent/javascript_instrumentor.rb +1 -1
  33. data/lib/new_relic/agent/new_relic_service.rb +0 -4
  34. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +0 -1
  35. data/lib/new_relic/agent/parameter_filtering.rb +18 -5
  36. data/lib/new_relic/agent/priority_sampled_buffer.rb +2 -0
  37. data/lib/new_relic/agent/span_event_aggregator.rb +2 -5
  38. data/lib/new_relic/agent/threading/backtrace_service.rb +3 -3
  39. data/lib/new_relic/agent/threading/thread_profile.rb +9 -23
  40. data/lib/new_relic/agent/transaction.rb +0 -2
  41. data/lib/new_relic/agent/transaction/trace.rb +3 -8
  42. data/lib/new_relic/agent/transaction/trace_builder.rb +0 -1
  43. data/lib/new_relic/agent/transaction_event_recorder.rb +3 -3
  44. data/lib/new_relic/agent/transaction_sampler.rb +1 -5
  45. data/lib/new_relic/agent/transaction_time_aggregator.rb +19 -4
  46. data/lib/new_relic/control/class_methods.rb +7 -1
  47. data/lib/new_relic/control/frameworks/{rails5.rb → rails_notifications.rb} +1 -1
  48. data/lib/new_relic/rack/browser_monitoring.rb +10 -8
  49. data/lib/new_relic/version.rb +1 -1
  50. data/lib/tasks/config.rake +1 -2
  51. data/newrelic_rpm.gemspec +2 -9
  52. data/test/agent_helper.rb +18 -5
  53. metadata +18 -51
  54. data/lib/new_relic/agent/commands/xray_session.rb +0 -55
  55. data/lib/new_relic/agent/commands/xray_session_collection.rb +0 -161
  56. data/lib/new_relic/agent/instrumentation/active_record_4.rb +0 -42
  57. data/lib/new_relic/agent/instrumentation/active_record_5.rb +0 -41
  58. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +0 -104
  59. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -32
  60. data/lib/new_relic/agent/instrumentation/rails5/action_view.rb +0 -27
  61. data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +0 -64
  62. data/lib/new_relic/control/frameworks/rails6.rb +0 -14
@@ -9,7 +9,6 @@
9
9
  # like the ThreadProfiler, so it's simpler to just keep it together here.
10
10
 
11
11
  require 'new_relic/agent/commands/agent_command'
12
- require 'new_relic/agent/commands/xray_session_collection'
13
12
  require 'new_relic/agent/threading/backtrace_service'
14
13
 
15
14
  module NewRelic
@@ -18,8 +17,7 @@ module NewRelic
18
17
  class AgentCommandRouter
19
18
  attr_reader :handlers
20
19
 
21
- attr_accessor :thread_profiler_session, :backtrace_service,
22
- :xray_session_collection
20
+ attr_accessor :thread_profiler_session, :backtrace_service
23
21
 
24
22
  def initialize(event_listener=nil)
25
23
  @handlers = Hash.new { |*| Proc.new { |cmd| self.unrecognized_agent_command(cmd) } }
@@ -27,11 +25,9 @@ module NewRelic
27
25
  @backtrace_service = Threading::BacktraceService.new(event_listener)
28
26
 
29
27
  @thread_profiler_session = ThreadProfilerSession.new(@backtrace_service)
30
- @xray_session_collection = XraySessionCollection.new(@backtrace_service, event_listener)
31
28
 
32
29
  @handlers['start_profiler'] = Proc.new { |cmd| thread_profiler_session.handle_start_command(cmd) }
33
30
  @handlers['stop_profiler'] = Proc.new { |cmd| thread_profiler_session.handle_stop_command(cmd) }
34
- @handlers['active_xray_sessions'] = Proc.new { |cmd| xray_session_collection.handle_active_xray_sessions(cmd) }
35
31
 
36
32
  if event_listener
37
33
  event_listener.subscribe(:before_shutdown, &method(:on_before_shutdown))
@@ -45,20 +41,10 @@ module NewRelic
45
41
  def check_for_and_handle_agent_commands
46
42
  commands = get_agent_commands
47
43
 
48
- stop_xray_sessions unless active_xray_command?(commands)
49
-
50
44
  results = invoke_commands(commands)
51
45
  new_relic_service.agent_command_results(results) unless results.empty?
52
46
  end
53
47
 
54
- def stop_xray_sessions
55
- self.xray_session_collection.stop_all_sessions
56
- end
57
-
58
- def active_xray_command?(commands)
59
- commands.any? {|command| command.name == 'active_xray_sessions'}
60
- end
61
-
62
48
  def on_before_shutdown(*args)
63
49
  if self.thread_profiler_session.running?
64
50
  self.thread_profiler_session.stop(true)
@@ -67,7 +53,6 @@ module NewRelic
67
53
 
68
54
  def harvest!
69
55
  profiles = []
70
- profiles += harvest_from_xray_session_collection
71
56
  profiles += harvest_from_thread_profiler_session
72
57
  log_profiles(profiles)
73
58
  profiles
@@ -76,14 +61,10 @@ module NewRelic
76
61
  # We don't currently support merging thread profiles that failed to send
77
62
  # back into the AgentCommandRouter, so we just no-op this method.
78
63
  # Same with reset! - we don't support asynchronous cancellation of a
79
- # running thread profile or X-Ray session currently.
64
+ # running thread profile currently.
80
65
  def merge!(*args); end
81
66
  def reset!; end
82
67
 
83
- def harvest_from_xray_session_collection
84
- self.xray_session_collection.harvest_thread_profiles
85
- end
86
-
87
68
  def harvest_from_thread_profiler_session
88
69
  if self.thread_profiler_session.ready_to_harvest?
89
70
  self.thread_profiler_session.stop(true)
@@ -91,12 +91,8 @@ module NewRelic
91
91
  :rails
92
92
  when 3
93
93
  :rails3
94
- when 4
95
- :rails4
96
- when 5
97
- :rails5
98
- when 6
99
- :rails6
94
+ when 4..6
95
+ :rails_notifications
100
96
  else
101
97
  ::NewRelic::Agent.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
102
98
  end
@@ -172,6 +168,16 @@ module NewRelic
172
168
  end
173
169
  end
174
170
 
171
+ def self.api_host
172
+ Proc.new do
173
+ if String(NewRelic::Agent.config[:license_key]).start_with? 'eu'
174
+ 'rpm.eu.newrelic.com'
175
+ else
176
+ 'rpm.newrelic.com'
177
+ end
178
+ end
179
+ end
180
+
175
181
  def self.convert_to_regexp_list(raw_value)
176
182
  value_list = convert_to_list(raw_value)
177
183
  value_list.map do |value|
@@ -472,7 +478,7 @@ module NewRelic
472
478
  :description => "URI for the New Relic data collection service."
473
479
  },
474
480
  :api_host => {
475
- :default => 'rpm.newrelic.com',
481
+ :default => DefaultSource.api_host,
476
482
  :public => false,
477
483
  :type => String,
478
484
  :allowed_from_server => false,
@@ -553,12 +559,20 @@ module NewRelic
553
559
  :public => false,
554
560
  :type => Integer,
555
561
  :allowed_from_server => true,
556
- :description => 'Number of seconds betwixt connections to the New Relic data collection service. Note that transaction events have a separate report period, specified by data_report_periods.analytic_event_data.'
562
+ :description => 'Number of seconds betwixt connections to the New Relic data collection service.'
563
+ },
564
+ :event_report_period => {
565
+ :default => 60,
566
+ :public => false,
567
+ :type => Integer,
568
+ :allowed_from_server => true,
569
+ :description => 'Number of seconds betwixt connections to the New Relic event collection services.'
557
570
  },
558
571
  :'data_report_periods.analytic_event_data' => {
559
572
  :default => 60,
560
573
  :public => false,
561
574
  :type => Integer,
575
+ :deprecated => true,
562
576
  :dynamic_name => true,
563
577
  :allowed_from_server => true,
564
578
  :description => 'Number of seconds between connections to the New Relic data collection service for sending transaction event data.'
@@ -1003,6 +1017,7 @@ module NewRelic
1003
1017
  :public => true,
1004
1018
  :type => Boolean,
1005
1019
  :allowed_from_server => true,
1020
+ :dynamic_name => true,
1006
1021
  :description => 'If <code>true</code>, the agent collects <a href="https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/error-event-default-attributes-insights">TransactionError events</a>.'
1007
1022
  },
1008
1023
  :'error_collector.max_event_samples_stored' => {
@@ -1157,35 +1172,7 @@ module NewRelic
1157
1172
  :allowed_from_server => true,
1158
1173
  :description => 'If <code>true</code>, enables use of the <a href="https://docs.newrelic.com/docs/apm/applications-menu/events/thread-profiler-tool">thread profiler</a>.'
1159
1174
  },
1160
- :'xray_session.enabled' => {
1161
- :default => true,
1162
- :public => true,
1163
- :type => Boolean,
1164
- :allowed_from_server => true,
1165
- :description => 'If <code>true</code>, enables <a href="https://docs.newrelic.com/docs/apm/transactions-menu/x-ray-sessions/x-ray-sessions">X-Ray sessions</a>.'
1166
- },
1167
- :'xray_session.allow_traces' => {
1168
- :default => true,
1169
- :public => false,
1170
- :type => Boolean,
1171
- :allowed_from_server => true,
1172
- :description => 'Enable or disable X-Ray sessions recording transaction traces.'
1173
- },
1174
- :'xray_session.allow_profiles' => {
1175
- :default => true,
1176
- :public => false,
1177
- :type => Boolean,
1178
- :allowed_from_server => true,
1179
- :description => 'Enable or disable X-Ray sessions taking thread profiles.'
1180
- },
1181
- :'xray_session.max_samples' => {
1182
- :default => 10,
1183
- :public => false,
1184
- :type => Integer,
1185
- :allowed_from_server => true,
1186
- :description => 'Maximum number of transaction traces to buffer for active X-Ray sessions'
1187
- },
1188
- :'xray_session.max_profile_overhead' => {
1175
+ :'thread_profiler.max_profile_overhead' => {
1189
1176
  :default => 0.05,
1190
1177
  :public => false,
1191
1178
  :type => Float,
@@ -1235,6 +1222,13 @@ module NewRelic
1235
1222
  :allowed_from_server => false,
1236
1223
  :description => 'Controls whether to normalize string encodings prior to serializing data for the collector to JSON.'
1237
1224
  },
1225
+ :backport_fast_active_record_connection_lookup => {
1226
+ :default => false,
1227
+ :public => true,
1228
+ :type => Boolean,
1229
+ :allowed_from_server => false,
1230
+ :description => 'Backports the faster ActiveRecord connection lookup introduced in Rails 6, which improves agent performance when instrumenting ActiveRecord. Note that this setting may not be compatible with other gems that patch ActiveRecord.'
1231
+ },
1238
1232
  :disable_vm_sampler => {
1239
1233
  :default => false,
1240
1234
  :public => true,
@@ -1273,7 +1267,12 @@ module NewRelic
1273
1267
  :type => Boolean,
1274
1268
  :dynamic_name => true,
1275
1269
  :allowed_from_server => false,
1276
- :description => 'If <code>true</code>, disables instrumentation for ActiveRecord 4.'
1270
+ :deprecated => true,
1271
+ :description => 'Deprecated. ' \
1272
+ 'For agent versions 6.3 or higher, ' \
1273
+ 'use <a href="#disable_active_record_notifications"><code>' \
1274
+ 'disable_active_record_notifications' \
1275
+ '</code></a> instead.'
1277
1276
  },
1278
1277
  :disable_active_record_5 => {
1279
1278
  :default => false,
@@ -1281,7 +1280,20 @@ module NewRelic
1281
1280
  :type => Boolean,
1282
1281
  :dynamic_name => true,
1283
1282
  :allowed_from_server => false,
1284
- :description => 'If <code>true</code>, disables instrumentation for ActiveRecord 5.'
1283
+ :deprecated => true,
1284
+ :description => 'Deprecated. ' \
1285
+ 'For agent versions 6.3 or higher, ' \
1286
+ 'use <a href="#disable_active_record_notifications"><code>' \
1287
+ 'disable_active_record_notifications' \
1288
+ '</code></a> instead.'
1289
+ },
1290
+ :disable_active_record_notifications => {
1291
+ :default => false,
1292
+ :public => true,
1293
+ :type => Boolean,
1294
+ :dynamic_name => true,
1295
+ :allowed_from_server => false,
1296
+ :description => 'If <code>true</code>, disables instrumentation for ActiveRecord 4, 5, and 6.'
1285
1297
  },
1286
1298
  :disable_bunny => {
1287
1299
  :default => false,
@@ -1793,14 +1805,14 @@ module NewRelic
1793
1805
  },
1794
1806
  :'span_events.enabled' => {
1795
1807
  :default => true,
1796
- :public => false,
1808
+ :public => true,
1797
1809
  :type => Boolean,
1798
1810
  :allowed_from_server => true,
1799
1811
  :description => 'If <code>true</code>, enables span event sampling.'
1800
1812
  },
1801
1813
  :'span_events.max_samples_stored' => {
1802
1814
  :default => 1000,
1803
- :public => false,
1815
+ :public => true,
1804
1816
  :type => Integer,
1805
1817
  :allowed_from_server => true,
1806
1818
  :description => 'Defines the maximum number of span events reported from a single harvest.'
@@ -9,7 +9,8 @@ module NewRelic
9
9
  SUPPORTED_PREFIXES = /^new_relic_|^newrelic_/i
10
10
  SPECIAL_CASE_KEYS = [
11
11
  'NEW_RELIC_ENV', # read by NewRelic::Control::Frameworks::Ruby
12
- 'NEW_RELIC_LOG' # read by set_log_file
12
+ 'NEW_RELIC_LOG', # read by set_log_file
13
+ /^NEW_RELIC_METADATA_/ # read by NewRelic::Agent::Connect::RequestBuilder
13
14
  ]
14
15
 
15
16
  attr_accessor :alias_map, :type_map
@@ -66,7 +67,8 @@ module NewRelic
66
67
  nr_env_var_keys = collect_new_relic_environment_variable_keys
67
68
 
68
69
  nr_env_var_keys.each do |key|
69
- next if SPECIAL_CASE_KEYS.include?(key.upcase)
70
+ next if SPECIAL_CASE_KEYS.any? { |pattern| pattern === key.upcase }
71
+
70
72
  set_value_from_environment_variable(key)
71
73
  end
72
74
  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 Configuration
8
+ module EventHarvestConfig
9
+
10
+ extend self
11
+
12
+ EVENT_HARVEST_CONFIG_KEY_MAPPING = {
13
+ :analytic_event_data => :'analytics_events.max_samples_stored',
14
+ :custom_event_data => :'custom_insights_events.max_samples_stored',
15
+ :error_event_data => :'error_collector.max_event_samples_stored'
16
+ }
17
+
18
+ def from_config(config)
19
+ {:harvest_limits => EVENT_HARVEST_CONFIG_KEY_MAPPING.inject({}) do
20
+ |connect_payload, (connect_payload_key, config_key)|
21
+ connect_payload[connect_payload_key] = config[config_key]
22
+ connect_payload
23
+ end
24
+ }
25
+ end
26
+
27
+ def to_config_hash(connect_reply)
28
+ config_hash = EVENT_HARVEST_CONFIG_KEY_MAPPING.inject({}) do
29
+ |event_harvest_config, (connect_payload_key, config_key)|
30
+ event_harvest_config[config_key] = connect_reply['event_harvest_config']['harvest_limits'][connect_payload_key.to_s]
31
+ event_harvest_config
32
+ end
33
+ config_hash[:event_report_period] = connect_reply['event_harvest_config']['report_period_ms'] / 1000
34
+ config_hash
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -13,6 +13,7 @@ module NewRelic
13
13
  :capture_params => false,
14
14
  :'resque.capture_params' => false,
15
15
  :'sidekiq.capture_params' => false,
16
+ :'attributes.include' => [],
16
17
 
17
18
  :'transaction_tracer.record_sql' => record_sql_setting(local_settings, :'transaction_tracer.record_sql'),
18
19
  :'slow_sql.record_sql' => record_sql_setting(local_settings, :'slow_sql.record_sql'),
@@ -95,6 +95,7 @@ module NewRelic
95
95
  reset_cache
96
96
  log_config(:add, source)
97
97
 
98
+ notify_server_source_added if ServerSource === source
98
99
  notify_finished_configuring if !was_finished && finished_configuring?
99
100
  end
100
101
 
@@ -171,8 +172,19 @@ module NewRelic
171
172
  end
172
173
  end
173
174
 
175
+ # This event is intended to be fired every time the server source is
176
+ # applied. This happens after the agent's initial connect, and again
177
+ # on every forced reconnect.
178
+ def notify_server_source_added
179
+ NewRelic::Agent.instance.events.notify(:server_source_configuration_added)
180
+ end
181
+
182
+ # This event is intended to be fired once during the entire lifespan of
183
+ # an agent run, after the server source has been applied for the first
184
+ # time. This should indicate that all configuration has been applied,
185
+ # and the main functions of the agent are safe to start.
174
186
  def notify_finished_configuring
175
- NewRelic::Agent.instance.events.notify(:finished_configuring)
187
+ NewRelic::Agent.instance.events.notify(:initial_configuration_complete)
176
188
  end
177
189
 
178
190
  def finished_configuring?
@@ -20,7 +20,6 @@ module NewRelic
20
20
  "browser_monitoring.loader_version",
21
21
  "cross_process_id",
22
22
  "data_report_period",
23
- "data_report_periods.analytic_event_data",
24
23
  "encoding_key",
25
24
  "error_beacon",
26
25
  "js_agent_file",
@@ -39,6 +38,7 @@ module NewRelic
39
38
  merge_top_level_keys(merged_settings, connect_reply)
40
39
  merge_agent_config_hash(merged_settings, connect_reply)
41
40
  fix_transaction_threshold(merged_settings)
41
+ add_event_harvest_config(merged_settings, connect_reply)
42
42
  filter_keys(merged_settings)
43
43
 
44
44
  apply_feature_gates(merged_settings, connect_reply, existing_config)
@@ -74,6 +74,39 @@ module NewRelic
74
74
  end
75
75
  end
76
76
 
77
+ EVENT_HARVEST_CONFIG_SUPPORTABILITY_METRIC_NAMES = {
78
+ :'analytics_events.max_samples_stored' => 'Supportability/EventHarvest/AnalyticEventData/HarvestLimit',
79
+ :'custom_insights_events.max_samples_stored' => 'Supportability/EventHarvest/CustomEventData/HarvestLimit',
80
+ :'error_collector.max_event_samples_stored'=> 'Supportability/EventHarvest/ErrorEventData/HarvestLimit',
81
+ :event_report_period => 'Supportability/EventHarvest/ReportPeriod'
82
+ }
83
+
84
+ def add_event_harvest_config(merged_settings, connect_reply)
85
+ return unless event_harvest_config_is_valid connect_reply
86
+
87
+ event_harvest_config = EventHarvestConfig.to_config_hash(connect_reply)
88
+ EVENT_HARVEST_CONFIG_SUPPORTABILITY_METRIC_NAMES.each do |config_key, metric_name|
89
+ NewRelic::Agent.record_metric metric_name, event_harvest_config[config_key]
90
+ end
91
+
92
+ merged_settings.merge! event_harvest_config
93
+ end
94
+
95
+ def event_harvest_config_is_valid connect_reply
96
+ event_harvest_config = connect_reply['event_harvest_config']
97
+
98
+ if event_harvest_config.nil? \
99
+ || event_harvest_config['harvest_limits'].values.min < 0 \
100
+ || (event_harvest_config['report_period_ms'] / 1000) <= 0
101
+ NewRelic::Agent.logger.warn "Invalid event harvest config found " \
102
+ "in connect response; using default event report period."
103
+ NewRelic::Agent.record_metric('Supportability/Agent/Collector/MissingEventHarvestConfig', 1)
104
+ false
105
+ else
106
+ true
107
+ end
108
+ end
109
+
77
110
  def filter_keys(merged_settings)
78
111
  merged_settings.delete_if do |key, _|
79
112
  setting_spec = DEFAULTS[key.to_sym]
@@ -0,0 +1,69 @@
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
+ require 'new_relic/environment_report'
6
+ require 'new_relic/agent/configuration/event_harvest_config'
7
+
8
+ module NewRelic
9
+ module Agent
10
+ module Connect
11
+
12
+ class RequestBuilder
13
+
14
+ def initialize(new_relic_service, config, event_harvest_config)
15
+ @service = new_relic_service
16
+ @config = config
17
+ @event_harvest_config = event_harvest_config
18
+ end
19
+
20
+
21
+ # Initializes the hash of settings that we send to the
22
+ # server. Returns a literal hash containing the options
23
+ def connect_payload
24
+ {
25
+ :pid => $$,
26
+ :host => local_host,
27
+ :display_host => Agent.config[:'process_host.display_name'],
28
+ :app_name => Agent.config.app_names,
29
+ :language => 'ruby',
30
+ :labels => Agent.config.parsed_labels,
31
+ :agent_version => NewRelic::VERSION::STRING,
32
+ :environment => sanitize_environment_report(environment_report),
33
+ :metadata => environment_metadata,
34
+ :settings => Agent.config.to_collector_hash,
35
+ :high_security => Agent.config[:high_security],
36
+ :utilization => UtilizationData.new.to_collector_hash,
37
+ :identifier => "ruby:#{local_host}:#{Agent.config.app_names.sort.join(',')}",
38
+ :event_harvest_config => @event_harvest_config
39
+ }
40
+ end
41
+
42
+ # We've seen objects in the environment report (Rails.env in
43
+ # particular) that can't seralize to JSON. Cope with that here and
44
+ # clear out so downstream code doesn't have to check again.
45
+ def sanitize_environment_report(environment_report)
46
+ return [] unless @service.valid_to_marshal?(environment_report)
47
+ environment_report
48
+ end
49
+
50
+ # Checks whether we should send environment info, and if so,
51
+ # returns the snapshot from the local environment.
52
+ # Generating the EnvironmentReport has the potential to trigger
53
+ # require calls in Rails environments, so this method should only
54
+ # be called synchronously from on the main thread.
55
+ def environment_report
56
+ Agent.config[:send_environment_info] ? Array(EnvironmentReport.new) : []
57
+ end
58
+
59
+ def environment_metadata
60
+ ENV.select {|k, v| k =~ /^NEW_RELIC_METADATA_/}
61
+ end
62
+
63
+ def local_host
64
+ NewRelic::Agent::Hostname.get
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end