newrelic_rpm 8.2.0 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1936 -0
  3. data/CHANGELOG.md +17 -2
  4. data/CONTRIBUTING.md +14 -2
  5. data/Guardfile +8 -8
  6. data/Rakefile +5 -7
  7. data/bin/mongrel_rpm +8 -9
  8. data/bin/newrelic +1 -1
  9. data/bin/nrdebug +14 -14
  10. data/init.rb +0 -2
  11. data/lefthook.yml +9 -0
  12. data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
  13. data/lib/new_relic/agent/agent.rb +38 -40
  14. data/lib/new_relic/agent/agent_logger.rb +8 -9
  15. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  16. data/lib/new_relic/agent/attributes.rb +2 -2
  17. data/lib/new_relic/agent/autostart.rb +6 -7
  18. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  19. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  20. data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
  21. data/lib/new_relic/agent/configuration/default_source.rb +318 -324
  22. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  23. data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
  24. data/lib/new_relic/agent/configuration/event_harvest_config.rb +2 -4
  25. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  26. data/lib/new_relic/agent/configuration/manager.rb +57 -57
  27. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  28. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  29. data/lib/new_relic/agent/configuration/server_source.rb +10 -10
  30. data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
  31. data/lib/new_relic/agent/connect/request_builder.rb +13 -16
  32. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  33. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
  34. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  35. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  36. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  37. data/lib/new_relic/agent/database.rb +20 -24
  38. data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
  39. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  40. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  41. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  42. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  43. data/lib/new_relic/agent/datastores.rb +1 -3
  44. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
  45. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
  46. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
  47. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
  48. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
  49. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
  50. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +23 -23
  51. data/lib/new_relic/agent/distributed_tracing.rb +17 -18
  52. data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
  53. data/lib/new_relic/agent/error_collector.rb +17 -17
  54. data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
  55. data/lib/new_relic/agent/error_filter.rb +6 -8
  56. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
  57. data/lib/new_relic/agent/event_aggregator.rb +1 -1
  58. data/lib/new_relic/agent/event_buffer.rb +6 -7
  59. data/lib/new_relic/agent/event_listener.rb +0 -1
  60. data/lib/new_relic/agent/event_loop.rb +10 -10
  61. data/lib/new_relic/agent/external.rb +1 -2
  62. data/lib/new_relic/agent/guid_generator.rb +1 -3
  63. data/lib/new_relic/agent/harvester.rb +3 -4
  64. data/lib/new_relic/agent/heap.rb +1 -3
  65. data/lib/new_relic/agent/hostname.rb +3 -3
  66. data/lib/new_relic/agent/http_clients/abstract.rb +5 -7
  67. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
  68. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
  69. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
  70. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
  71. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +2 -3
  72. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
  73. data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
  74. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
  75. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +9 -10
  76. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  77. data/lib/new_relic/agent/instrumentation/active_job.rb +4 -3
  78. data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
  79. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
  80. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
  81. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
  82. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
  83. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
  84. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
  85. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  86. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
  87. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
  88. data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
  89. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  90. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
  91. data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
  92. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  93. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -6
  94. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
  95. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  96. data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
  97. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  98. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  99. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  100. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  101. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  102. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  103. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  104. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  105. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  106. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  107. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +0 -1
  108. data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
  109. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -1
  110. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +0 -1
  111. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -0
  112. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  113. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
  114. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
  115. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
  116. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
  117. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
  118. data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
  119. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
  120. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
  121. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
  122. data/lib/new_relic/agent/instrumentation/padrino.rb +0 -5
  123. data/lib/new_relic/agent/instrumentation/queue_time.rb +5 -5
  124. data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
  125. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
  126. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
  127. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
  128. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  129. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
  130. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
  131. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
  132. data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
  133. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
  134. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  135. data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
  136. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
  137. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
  138. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  139. data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
  140. data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
  141. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
  142. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
  143. data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
  144. data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
  145. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
  146. data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -4
  147. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
  148. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
  149. data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
  150. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +0 -1
  151. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
  152. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
  153. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
  154. data/lib/new_relic/agent/internal_agent_error.rb +1 -1
  155. data/lib/new_relic/agent/javascript_instrumentor.rb +28 -28
  156. data/lib/new_relic/agent/logging.rb +8 -4
  157. data/lib/new_relic/agent/memory_logger.rb +1 -1
  158. data/lib/new_relic/agent/messaging.rb +42 -43
  159. data/lib/new_relic/agent/method_tracer.rb +9 -12
  160. data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
  161. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +13 -12
  162. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
  163. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
  164. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
  165. data/lib/new_relic/agent/monitors.rb +1 -2
  166. data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
  167. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
  168. data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
  169. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
  170. data/lib/new_relic/agent/new_relic_service.rb +20 -20
  171. data/lib/new_relic/agent/noticible_error.rb +0 -2
  172. data/lib/new_relic/agent/null_logger.rb +6 -2
  173. data/lib/new_relic/agent/obfuscator.rb +6 -8
  174. data/lib/new_relic/agent/parameter_filtering.rb +3 -5
  175. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  176. data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
  177. data/lib/new_relic/agent/pipe_service.rb +1 -1
  178. data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
  179. data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
  180. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
  181. data/lib/new_relic/agent/rules_engine.rb +2 -2
  182. data/lib/new_relic/agent/sampler.rb +2 -3
  183. data/lib/new_relic/agent/sampler_collection.rb +2 -3
  184. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +3 -3
  185. data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
  186. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  187. data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
  188. data/lib/new_relic/agent/span_event_primitive.rb +39 -39
  189. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  190. data/lib/new_relic/agent/stats.rb +16 -16
  191. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  192. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  193. data/lib/new_relic/agent/stats_engine.rb +6 -6
  194. data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
  195. data/lib/new_relic/agent/system_info.rb +22 -20
  196. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  197. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  198. data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
  199. data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
  200. data/lib/new_relic/agent/tracer.rb +37 -43
  201. data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
  202. data/lib/new_relic/agent/transaction/datastore_segment.rb +5 -7
  203. data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -9
  204. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  205. data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -5
  206. data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
  207. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  208. data/lib/new_relic/agent/transaction/segment.rb +3 -3
  209. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  210. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  211. data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
  212. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  213. data/lib/new_relic/agent/transaction/tracing.rb +1 -3
  214. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  215. data/lib/new_relic/agent/transaction.rb +79 -81
  216. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
  217. data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
  218. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  219. data/lib/new_relic/agent/transaction_metrics.rb +3 -3
  220. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  221. data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
  222. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  223. data/lib/new_relic/agent/utilization_data.rb +3 -4
  224. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  225. data/lib/new_relic/agent/vm/snapshot.rb +3 -3
  226. data/lib/new_relic/agent/worker_loop.rb +3 -5
  227. data/lib/new_relic/agent.rb +22 -22
  228. data/lib/new_relic/cli/command.rb +15 -17
  229. data/lib/new_relic/cli/commands/deployments.rb +20 -22
  230. data/lib/new_relic/cli/commands/install.rb +6 -10
  231. data/lib/new_relic/coerce.rb +5 -8
  232. data/lib/new_relic/collection_helper.rb +48 -47
  233. data/lib/new_relic/control/class_methods.rb +2 -2
  234. data/lib/new_relic/control/frameworks/external.rb +1 -1
  235. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  236. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  237. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  238. data/lib/new_relic/control/instance_methods.rb +4 -5
  239. data/lib/new_relic/control/instrumentation.rb +4 -5
  240. data/lib/new_relic/control/server_methods.rb +2 -3
  241. data/lib/new_relic/control.rb +0 -1
  242. data/lib/new_relic/dependency_detection.rb +6 -8
  243. data/lib/new_relic/environment_report.rb +16 -18
  244. data/lib/new_relic/helper.rb +5 -5
  245. data/lib/new_relic/language_support.rb +1 -1
  246. data/lib/new_relic/latest_changes.rb +2 -2
  247. data/lib/new_relic/local_environment.rb +7 -7
  248. data/lib/new_relic/metric_data.rb +6 -7
  249. data/lib/new_relic/metric_spec.rb +3 -3
  250. data/lib/new_relic/noticed_error.rb +14 -15
  251. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  252. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  253. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  254. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  255. data/lib/new_relic/supportability_helper.rb +1 -2
  256. data/lib/new_relic/version.rb +3 -4
  257. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  258. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  259. data/lib/tasks/all.rb +1 -1
  260. data/lib/tasks/config.rake +21 -21
  261. data/lib/tasks/multiverse.rb +4 -6
  262. data/lib/tasks/tests.rake +3 -7
  263. data/newrelic_rpm.gemspec +13 -12
  264. data/recipes/newrelic.rb +1 -1
  265. data/test/agent_helper.rb +55 -55
  266. metadata +33 -4
@@ -6,7 +6,7 @@ module NewRelic
6
6
  module Agent
7
7
  module Configuration
8
8
  class DottedHash < ::Hash
9
- def initialize(hash, keep_nesting=false)
9
+ def initialize(hash, keep_nesting = false)
10
10
  # Add the hash keys to our collection explicitly so they survive the
11
11
  # dot flattening. This is typical for full config source instances,
12
12
  # but not for uses of DottedHash serializing for transmission.
@@ -31,8 +31,9 @@ module NewRelic
31
31
  end
32
32
 
33
33
  protected
34
+
34
35
  # turns {'a' => {'b' => 'c'}} into {'a.b' => 'c'}
35
- def dot_flattened(nested_hash, names=[], result={})
36
+ def dot_flattened(nested_hash, names = [], result = {})
36
37
  nested_hash.each do |key, val|
37
38
  next if val == nil
38
39
  if val.respond_to?(:has_key?)
@@ -44,7 +45,6 @@ module NewRelic
44
45
  result
45
46
  end
46
47
  end
47
-
48
48
  end
49
49
  end
50
50
  end
@@ -7,9 +7,9 @@ module NewRelic
7
7
  module Configuration
8
8
  class EnvironmentSource < DottedHash
9
9
  SUPPORTED_PREFIXES = /^new_relic_|^newrelic_/i
10
- SPECIAL_CASE_KEYS = [
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
13
  /^NEW_RELIC_METADATA_/ # read by NewRelic::Agent::Connect::RequestBuilder
14
14
  ]
15
15
 
@@ -43,7 +43,7 @@ module NewRelic
43
43
  config_setting = original_config_setting.to_s
44
44
 
45
45
  if config_setting.include? '.'
46
- config_alias = config_setting.gsub(/\./,'_').to_sym
46
+ config_alias = config_setting.gsub(/\./, '_').to_sym
47
47
  self.alias_map[config_alias] = original_config_setting
48
48
  end
49
49
  end
@@ -111,7 +111,6 @@ module NewRelic
111
111
  def collect_new_relic_environment_variable_keys
112
112
  ENV.keys.select { |key| key.match(SUPPORTED_PREFIXES) }
113
113
  end
114
-
115
114
  end
116
115
  end
117
116
  end
@@ -6,13 +6,12 @@ module NewRelic
6
6
  module Agent
7
7
  module Configuration
8
8
  module EventHarvestConfig
9
-
10
9
  extend self
11
10
 
12
11
  EVENT_HARVEST_CONFIG_KEY_MAPPING = {
13
12
  :analytic_event_data => :'analytics_events.max_samples_stored',
14
13
  :custom_event_data => :'custom_insights_events.max_samples_stored',
15
- :error_event_data => :'error_collector.max_event_samples_stored',
14
+ :error_event_data => :'error_collector.max_event_samples_stored'
16
15
  }
17
16
 
18
17
  def from_config(config)
@@ -22,8 +21,7 @@ module NewRelic
22
21
  ).inject({}) do |connect_payload, (connect_payload_key, config_key)|
23
22
  connect_payload[connect_payload_key] = config[config_key]
24
23
  connect_payload
25
- end
26
- }
24
+ end}
27
25
  end
28
26
 
29
27
  def to_config_hash(connect_reply)
@@ -10,17 +10,17 @@ module NewRelic
10
10
  class HighSecuritySource < DottedHash
11
11
  def initialize(local_settings)
12
12
  super({
13
- :capture_params => false,
14
- :'resque.capture_params' => false,
13
+ :capture_params => false,
14
+ :'resque.capture_params' => false,
15
15
  :'sidekiq.capture_params' => false,
16
- :'attributes.include' => [],
16
+ :'attributes.include' => [],
17
17
 
18
18
  :'transaction_tracer.record_sql' => record_sql_setting(local_settings, :'transaction_tracer.record_sql'),
19
- :'slow_sql.record_sql' => record_sql_setting(local_settings, :'slow_sql.record_sql'),
20
- :'mongo.obfuscate_queries' => true,
19
+ :'slow_sql.record_sql' => record_sql_setting(local_settings, :'slow_sql.record_sql'),
20
+ :'mongo.obfuscate_queries' => true,
21
21
  :'transaction_tracer.record_redis_arguments' => false,
22
22
 
23
- :'custom_insights_events.enabled' => false,
23
+ :'custom_insights_events.enabled' => false,
24
24
  :'strip_exception_messages.enabled' => true
25
25
  })
26
26
  end
@@ -32,7 +32,7 @@ module NewRelic
32
32
  SET_TO_OBFUSCATED = [RAW, OBFUSCATED]
33
33
 
34
34
  def record_sql_setting(local_settings, key)
35
- original_value = local_settings[key]
35
+ original_value = local_settings[key]
36
36
  result = if SET_TO_OBFUSCATED.include?(original_value)
37
37
  OBFUSCATED
38
38
  else
@@ -31,10 +31,10 @@ module NewRelic
31
31
 
32
32
  def initialize
33
33
  reset_to_defaults
34
- @callbacks = Hash.new {|hash,key| hash[key] = [] }
34
+ @callbacks = Hash.new { |hash, key| hash[key] = [] }
35
35
  end
36
36
 
37
- def add_config_for_testing(source, level=0)
37
+ def add_config_for_testing(source, level = 0)
38
38
  raise 'Invalid config type for testing' unless [Hash, DottedHash].include?(source.class)
39
39
  invoke_callbacks(:add, source)
40
40
  @configs_for_testing << [source.freeze, level]
@@ -45,12 +45,12 @@ module NewRelic
45
45
  def remove_config_type(sym)
46
46
  source = case sym
47
47
  when :security_policy then @security_policy_source
48
- when :high_security then @high_security_source
49
- when :environment then @environment_source
50
- when :server then @server_source
51
- when :manual then @manual_source
52
- when :yaml then @yaml_source
53
- when :default then @default_source
48
+ when :high_security then @high_security_source
49
+ when :environment then @environment_source
50
+ when :server then @server_source
51
+ when :manual then @manual_source
52
+ when :yaml then @yaml_source
53
+ when :default then @default_source
54
54
  end
55
55
 
56
56
  remove_config(source)
@@ -59,14 +59,14 @@ module NewRelic
59
59
  def remove_config(source)
60
60
  case source
61
61
  when SecurityPolicySource then @security_policy_source = nil
62
- when HighSecuritySource then @high_security_source = nil
63
- when EnvironmentSource then @environment_source = nil
64
- when ServerSource then @server_source = nil
65
- when ManualSource then @manual_source = nil
66
- when YamlSource then @yaml_source = nil
67
- when DefaultSource then @default_source = nil
62
+ when HighSecuritySource then @high_security_source = nil
63
+ when EnvironmentSource then @environment_source = nil
64
+ when ServerSource then @server_source = nil
65
+ when ManualSource then @manual_source = nil
66
+ when YamlSource then @yaml_source = nil
67
+ when DefaultSource then @default_source = nil
68
68
  else
69
- @configs_for_testing.delete_if {|src,lvl| src == source}
69
+ @configs_for_testing.delete_if { |src, lvl| src == source }
70
70
  end
71
71
 
72
72
  reset_cache
@@ -82,12 +82,12 @@ module NewRelic
82
82
 
83
83
  case source
84
84
  when SecurityPolicySource then @security_policy_source = source
85
- when HighSecuritySource then @high_security_source = source
86
- when EnvironmentSource then @environment_source = source
87
- when ServerSource then @server_source = source
88
- when ManualSource then @manual_source = source
89
- when YamlSource then @yaml_source = source
90
- when DefaultSource then @default_source = source
85
+ when HighSecuritySource then @high_security_source = source
86
+ when EnvironmentSource then @environment_source = source
87
+ when ServerSource then @server_source = source
88
+ when ManualSource then @manual_source = source
89
+ when YamlSource then @yaml_source = source
90
+ when DefaultSource then @default_source = source
91
91
  else
92
92
  NewRelic::Agent.logger.warn("Invalid config format; config will be ignored: #{source}")
93
93
  end
@@ -191,9 +191,9 @@ module NewRelic
191
191
  end
192
192
 
193
193
  def flattened
194
- config_stack.reverse.inject({}) do |flat,layer|
194
+ config_stack.reverse.inject({}) do |flat, layer|
195
195
  thawed_layer = layer.to_hash.dup
196
- thawed_layer.each do |k,v|
196
+ thawed_layer.each do |k, v|
197
197
  begin
198
198
  thawed_layer[k] = instance_eval(&v) if v.respond_to?(:call)
199
199
  rescue => e
@@ -207,9 +207,9 @@ module NewRelic
207
207
  end
208
208
 
209
209
  def apply_mask(hash)
210
- MASK_DEFAULTS. \
211
- select {|_, proc| proc.call}. \
212
- each {|key, _| hash.delete(key) }
210
+ MASK_DEFAULTS \
211
+ .select { |_, proc| proc.call } \
212
+ .each { |key, _| hash.delete(key) }
213
213
  hash
214
214
  end
215
215
 
@@ -228,9 +228,9 @@ module NewRelic
228
228
  end
229
229
 
230
230
  MALFORMED_LABELS_WARNING = "Skipping malformed labels configuration"
231
- PARSING_LABELS_FAILURE = "Failure during parsing labels. Ignoring and carrying on with connect."
231
+ PARSING_LABELS_FAILURE = "Failure during parsing labels. Ignoring and carrying on with connect."
232
232
 
233
- MAX_LABEL_COUNT = 64
233
+ MAX_LABEL_COUNT = 64
234
234
  MAX_LABEL_LENGTH = 255
235
235
 
236
236
  def parsed_labels
@@ -252,7 +252,7 @@ module NewRelic
252
252
  end
253
253
 
254
254
  def break_label_string_into_pairs(labels)
255
- stripped_labels = labels.strip.sub(/^;*/,'').sub(/;*$/,'')
255
+ stripped_labels = labels.strip.sub(/^;*/, '').sub(/;*$/, '')
256
256
  stripped_labels.split(';').map do |pair|
257
257
  pair.split(':').map(&:strip)
258
258
  end
@@ -268,10 +268,10 @@ module NewRelic
268
268
 
269
269
  def valid_label_item?(item)
270
270
  case item
271
- when String then !item.empty?
271
+ when String then !item.empty?
272
272
  when Numeric then true
273
- when true then true
274
- when false then true
273
+ when true then true
274
+ when false then true
275
275
  else false
276
276
  end
277
277
  end
@@ -281,7 +281,7 @@ module NewRelic
281
281
  pairs = Array(pairs)
282
282
 
283
283
  unless valid_label_pairs?(pairs)
284
- NewRelic::Agent.logger.warn("#{MALFORMED_LABELS_WARNING}: #{labels||pairs}")
284
+ NewRelic::Agent.logger.warn("#{MALFORMED_LABELS_WARNING}: #{labels || pairs}")
285
285
  return []
286
286
  end
287
287
 
@@ -289,13 +289,13 @@ module NewRelic
289
289
  pairs = remove_duplicates(pairs)
290
290
  pairs.map do |key, value|
291
291
  {
292
- 'label_type' => truncate(key),
292
+ 'label_type' => truncate(key),
293
293
  'label_value' => truncate(value.to_s, key)
294
294
  }
295
295
  end
296
296
  end
297
297
 
298
- def truncate(text, key=nil)
298
+ def truncate(text, key = nil)
299
299
  if text.length > MAX_LABEL_LENGTH
300
300
  if key
301
301
  msg = "The value for the label '#{key}' is longer than the allowed #{MAX_LABEL_LENGTH} and will be truncated. Value = '#{text}'"
@@ -303,7 +303,7 @@ module NewRelic
303
303
  msg = "Label name longer than the allowed #{MAX_LABEL_LENGTH} will be truncated. Name = '#{text}'"
304
304
  end
305
305
  NewRelic::Agent.logger.warn(msg)
306
- text[0..MAX_LABEL_LENGTH-1]
306
+ text[0..MAX_LABEL_LENGTH - 1]
307
307
  else
308
308
  text
309
309
  end
@@ -331,20 +331,20 @@ module NewRelic
331
331
  # Generally only useful during initial construction and tests
332
332
  def reset_to_defaults
333
333
  @security_policy_source = nil
334
- @high_security_source = nil
335
- @environment_source = EnvironmentSource.new
336
- @server_source = nil
337
- @manual_source = nil
338
- @yaml_source = nil
339
- @default_source = DefaultSource.new
334
+ @high_security_source = nil
335
+ @environment_source = EnvironmentSource.new
336
+ @server_source = nil
337
+ @manual_source = nil
338
+ @yaml_source = nil
339
+ @default_source = DefaultSource.new
340
340
 
341
- @configs_for_testing = []
341
+ @configs_for_testing = []
342
342
 
343
343
  reset_cache
344
344
  end
345
345
 
346
346
  def reset_cache
347
- @cache = Hash.new { |hash,key| hash[key] = self.fetch(key) }
347
+ @cache = Hash.new { |hash, key| hash[key] = self.fetch(key) }
348
348
  end
349
349
 
350
350
  def log_config(direction, source)
@@ -359,13 +359,13 @@ module NewRelic
359
359
 
360
360
  def delete_all_configs_for_testing
361
361
  @security_policy_source = nil
362
- @high_security_source = nil
363
- @environment_source = nil
364
- @server_source = nil
365
- @manual_source = nil
366
- @yaml_source = nil
367
- @default_source = nil
368
- @configs_for_testing = []
362
+ @high_security_source = nil
363
+ @environment_source = nil
364
+ @server_source = nil
365
+ @manual_source = nil
366
+ @yaml_source = nil
367
+ @default_source = nil
368
+ @configs_for_testing = []
369
369
  end
370
370
 
371
371
  def num_configs_for_testing
@@ -380,12 +380,12 @@ module NewRelic
380
380
 
381
381
  def config_stack
382
382
  stack = [@security_policy_source,
383
- @high_security_source,
384
- @environment_source,
385
- @server_source,
386
- @manual_source,
387
- @yaml_source,
388
- @default_source]
383
+ @high_security_source,
384
+ @environment_source,
385
+ @server_source,
386
+ @manual_source,
387
+ @yaml_source,
388
+ @default_source]
389
389
 
390
390
  stack.compact!
391
391
 
@@ -6,7 +6,7 @@ module NewRelic
6
6
  module Agent
7
7
  module Configuration
8
8
  MASK_DEFAULTS = {
9
- :'thread_profiler' => Proc.new { !NewRelic::Agent::Threading::BacktraceService.is_supported? },
9
+ :'thread_profiler' => Proc.new { !NewRelic::Agent::Threading::BacktraceService.is_supported? },
10
10
  :'thread_profiler.enabled' => Proc.new { !NewRelic::Agent::Threading::BacktraceService.is_supported? }
11
11
  }
12
12
  end
@@ -52,150 +52,150 @@ module NewRelic
52
52
  SECURITY_SETTINGS_MAP = {
53
53
  "record_sql" => [
54
54
  {
55
- option: :'transaction_tracer.record_sql',
56
- supported: true,
57
- enabled_fn: method(:record_sql_enabled?),
55
+ option: :'transaction_tracer.record_sql',
56
+ supported: true,
57
+ enabled_fn: method(:record_sql_enabled?),
58
58
  disabled_value: 'off',
59
- permitted_fn: proc { |policies|
59
+ permitted_fn: proc { |policies|
60
60
  change_setting(policies, :'transaction_tracer.record_sql', 'obfuscated')
61
61
  }
62
62
  },
63
63
  {
64
- option: :'slow_sql.record_sql',
65
- supported: true,
66
- enabled_fn: method(:record_sql_enabled?),
64
+ option: :'slow_sql.record_sql',
65
+ supported: true,
66
+ enabled_fn: method(:record_sql_enabled?),
67
67
  disabled_value: 'off',
68
- permitted_fn: proc { |policies|
68
+ permitted_fn: proc { |policies|
69
69
  change_setting(policies, :'slow_sql.record_sql', 'obfuscated')
70
70
  }
71
71
  },
72
72
  {
73
- option: :'mongo.capture_queries',
74
- supported: true,
75
- enabled_fn: method(:enabled?),
73
+ option: :'mongo.capture_queries',
74
+ supported: true,
75
+ enabled_fn: method(:enabled?),
76
76
  disabled_value: false,
77
- permitted_fn: proc{ |policies|
77
+ permitted_fn: proc { |policies|
78
78
  change_setting(policies, :'mongo.obfuscate_queries', true)
79
79
  }
80
80
  },
81
81
  {
82
- option: :'transaction_tracer.record_redis_arguments',
83
- supported: true,
84
- enabled_fn: method(:enabled?),
82
+ option: :'transaction_tracer.record_redis_arguments',
83
+ supported: true,
84
+ enabled_fn: method(:enabled?),
85
85
  disabled_value: false,
86
- permitted_fn: nil
86
+ permitted_fn: nil
87
87
  }
88
88
  ],
89
89
  "attributes_include" => [
90
90
  {
91
- option: :'attributes.include',
92
- supported: true,
93
- enabled_fn: method(:not_empty?),
91
+ option: :'attributes.include',
92
+ supported: true,
93
+ enabled_fn: method(:not_empty?),
94
94
  disabled_value: [],
95
- permitted_fn: nil
95
+ permitted_fn: nil
96
96
  },
97
97
  {
98
- option: :'transaction_tracer.attributes.include',
99
- supported: true,
100
- enabled_fn: method(:not_empty?),
98
+ option: :'transaction_tracer.attributes.include',
99
+ supported: true,
100
+ enabled_fn: method(:not_empty?),
101
101
  disabled_value: [],
102
- permitted_fn: nil
102
+ permitted_fn: nil
103
103
  },
104
104
  {
105
- option: :'transaction_events.attributes.include',
106
- supported: true,
107
- enabled_fn: method(:not_empty?),
105
+ option: :'transaction_events.attributes.include',
106
+ supported: true,
107
+ enabled_fn: method(:not_empty?),
108
108
  disabled_value: [],
109
- permitted_fn: nil
109
+ permitted_fn: nil
110
110
  },
111
111
  {
112
- option: :'error_collector.attributes.include',
113
- supported: true,
114
- enabled_fn: method(:not_empty?),
112
+ option: :'error_collector.attributes.include',
113
+ supported: true,
114
+ enabled_fn: method(:not_empty?),
115
115
  disabled_value: [],
116
- permitted_fn: nil
116
+ permitted_fn: nil
117
117
  },
118
118
  {
119
- option: :'browser_monitoring.attributes.include',
120
- supported: true,
121
- enabled_fn: method(:not_empty?),
119
+ option: :'browser_monitoring.attributes.include',
120
+ supported: true,
121
+ enabled_fn: method(:not_empty?),
122
122
  disabled_value: [],
123
- permitted_fn: nil
123
+ permitted_fn: nil
124
124
  },
125
125
  {
126
- option: :'span_events.attributes.include',
127
- supported: true,
128
- enabled_fn: method(:not_empty?),
126
+ option: :'span_events.attributes.include',
127
+ supported: true,
128
+ enabled_fn: method(:not_empty?),
129
129
  disabled_value: [],
130
- permitted_fn: nil
130
+ permitted_fn: nil
131
131
  },
132
132
  {
133
- option: :'transaction_segments.attributes.include',
134
- supported: true,
135
- enabled_fn: method(:not_empty?),
133
+ option: :'transaction_segments.attributes.include',
134
+ supported: true,
135
+ enabled_fn: method(:not_empty?),
136
136
  disabled_value: [],
137
- permitted_fn: nil
137
+ permitted_fn: nil
138
138
  }
139
139
  ],
140
140
  "allow_raw_exception_messages" => [
141
141
  {
142
- option: :'strip_exception_messages.enabled',
143
- supported: true,
144
- enabled_fn: method(:enabled?),
142
+ option: :'strip_exception_messages.enabled',
143
+ supported: true,
144
+ enabled_fn: method(:enabled?),
145
145
  disabled_value: false,
146
- permitted_fn: nil
146
+ permitted_fn: nil
147
147
  }
148
148
  ],
149
149
  "custom_events" => [
150
150
  {
151
- option: :'custom_insights_events.enabled',
152
- supported: true,
153
- enabled_fn: method(:enabled?),
151
+ option: :'custom_insights_events.enabled',
152
+ supported: true,
153
+ enabled_fn: method(:enabled?),
154
154
  disabled_value: false,
155
- permitted_fn: nil
155
+ permitted_fn: nil
156
156
  }
157
157
  ],
158
158
  "custom_parameters" => [
159
159
  {
160
- option: :'custom_attributes.enabled',
161
- supported: true,
162
- enabled_fn: method(:enabled?),
160
+ option: :'custom_attributes.enabled',
161
+ supported: true,
162
+ enabled_fn: method(:enabled?),
163
163
  disabled_value: false,
164
- permitted_fn: nil
164
+ permitted_fn: nil
165
165
  }
166
166
  ],
167
167
  "custom_instrumentation_editor" => [
168
168
  {
169
- option: nil,
170
- supported: false,
171
- enabled_fn: nil,
169
+ option: nil,
170
+ supported: false,
171
+ enabled_fn: nil,
172
172
  disabled_value: nil,
173
- permitted_fn: nil
173
+ permitted_fn: nil
174
174
  }
175
175
  ],
176
176
  "message_parameters" => [
177
177
  {
178
- option: :'message_tracer.segment_parameters.enabled',
179
- supported: true,
180
- enabled_fn: method(:enabled?),
178
+ option: :'message_tracer.segment_parameters.enabled',
179
+ supported: true,
180
+ enabled_fn: method(:enabled?),
181
181
  disabled_value: false,
182
- permitted_fn: nil
182
+ permitted_fn: nil
183
183
  }
184
184
  ],
185
185
  "job_arguments" => [
186
186
  {
187
- option: :'resque.capture_params',
188
- supported: true,
189
- enabled_fn: method(:enabled?),
187
+ option: :'resque.capture_params',
188
+ supported: true,
189
+ enabled_fn: method(:enabled?),
190
190
  disabled_value: false,
191
- permitted_fn: nil
191
+ permitted_fn: nil
192
192
  },
193
193
  {
194
- option: :'sidekiq.capture_params',
195
- supported: true,
196
- enabled_fn: method(:enabled?),
194
+ option: :'sidekiq.capture_params',
195
+ supported: true,
196
+ enabled_fn: method(:enabled?),
197
197
  disabled_value: false,
198
- permitted_fn: nil
198
+ permitted_fn: nil
199
199
  }
200
200
  ]
201
201
  }
@@ -223,7 +223,7 @@ module NewRelic
223
223
  "Source: #{config_source}"
224
224
  end
225
225
  else
226
- settings[policy[:option]] = policy[:disabled_value]
226
+ settings[policy[:option]] = policy[:disabled_value]
227
227
  NewRelic::Agent.logger.info \
228
228
  "Setting applied: {#{policy[:option]}: #{policy[:disabled_value]}}. " \
229
229
  "Source: SecurityPolicySource"
@@ -33,7 +33,7 @@ module NewRelic
33
33
  "trusted_account_key"
34
34
  ]
35
35
 
36
- def initialize(connect_reply, existing_config={})
36
+ def initialize(connect_reply, existing_config = {})
37
37
  merged_settings = {}
38
38
 
39
39
  merge_top_level_keys(merged_settings, connect_reply)
@@ -78,10 +78,10 @@ module NewRelic
78
78
  EVENT_HARVEST_CONFIG_SUPPORTABILITY_METRIC_NAMES = {
79
79
  :'analytics_events.max_samples_stored' => 'Supportability/EventHarvest/AnalyticEventData/HarvestLimit',
80
80
  :'custom_insights_events.max_samples_stored' => 'Supportability/EventHarvest/CustomEventData/HarvestLimit',
81
- :'error_collector.max_event_samples_stored'=> 'Supportability/EventHarvest/ErrorEventData/HarvestLimit',
81
+ :'error_collector.max_event_samples_stored' => 'Supportability/EventHarvest/ErrorEventData/HarvestLimit',
82
82
  :'span_events.max_samples_stored' => 'Supportability/SpanEvent/Limit',
83
83
  :event_report_period => 'Supportability/EventHarvest/ReportPeriod',
84
- :'event_report_period.span_event_data' => 'Supportability/SpanEvent/ReportPeriod',
84
+ :'event_report_period.span_event_data' => 'Supportability/SpanEvent/ReportPeriod'
85
85
  }
86
86
 
87
87
  def add_event_harvest_config(merged_settings, connect_reply)
@@ -133,19 +133,19 @@ module NewRelic
133
133
  # do the real enforcement there.
134
134
  def apply_feature_gates(merged_settings, connect_reply, existing_config)
135
135
  gated_features = {
136
- 'transaction_tracer.enabled' => 'collect_traces',
137
- 'slow_sql.enabled' => 'collect_traces',
138
- 'error_collector.enabled' => 'collect_errors',
139
- 'analytics_events.enabled' => 'collect_analytics_events',
136
+ 'transaction_tracer.enabled' => 'collect_traces',
137
+ 'slow_sql.enabled' => 'collect_traces',
138
+ 'error_collector.enabled' => 'collect_errors',
139
+ 'analytics_events.enabled' => 'collect_analytics_events',
140
140
  'custom_insights_events.enabled' => 'collect_custom_events',
141
141
  'error_collector.capture_events' => 'collect_error_events',
142
- 'span_events.enabled' => 'collect_span_events'
142
+ 'span_events.enabled' => 'collect_span_events'
143
143
  }
144
144
  gated_features.each do |config_key, gate_key|
145
145
  if connect_reply.has_key?(gate_key)
146
146
  allowed_by_server = connect_reply[gate_key]
147
- requested_value = ungated_value(config_key, merged_settings, existing_config)
148
- effective_value = (allowed_by_server && requested_value)
147
+ requested_value = ungated_value(config_key, merged_settings, existing_config)
148
+ effective_value = (allowed_by_server && requested_value)
149
149
  merged_settings[config_key] = effective_value
150
150
  end
151
151
  end