newrelic_rpm 7.0.0 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rubocop.yml +1941 -0
  4. data/.yardopts +1 -0
  5. data/Brewfile +10 -0
  6. data/CHANGELOG.md +431 -1
  7. data/CONTRIBUTING.md +32 -5
  8. data/DOCKER.md +167 -0
  9. data/Dockerfile +10 -0
  10. data/Guardfile +8 -8
  11. data/LICENSE +0 -6
  12. data/README.md +20 -18
  13. data/Rakefile +39 -29
  14. data/THIRD_PARTY_NOTICES.md +14 -199
  15. data/bin/mongrel_rpm +8 -9
  16. data/bin/newrelic +1 -1
  17. data/bin/nrdebug +14 -14
  18. data/docker-compose.yml +85 -0
  19. data/init.rb +0 -2
  20. data/lefthook.yml +9 -0
  21. data/lib/new_relic/agent/adaptive_sampler.rb +9 -5
  22. data/lib/new_relic/agent/agent.rb +72 -49
  23. data/lib/new_relic/agent/agent_logger.rb +15 -9
  24. data/lib/new_relic/agent/attribute_filter.rb +31 -31
  25. data/lib/new_relic/agent/attributes.rb +2 -2
  26. data/lib/new_relic/agent/audit_logger.rb +4 -0
  27. data/lib/new_relic/agent/autostart.rb +19 -17
  28. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  29. data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
  30. data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -6
  31. data/lib/new_relic/agent/configuration/default_source.rb +731 -476
  32. data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
  33. data/lib/new_relic/agent/configuration/environment_source.rb +5 -4
  34. data/lib/new_relic/agent/configuration/event_harvest_config.rb +39 -16
  35. data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
  36. data/lib/new_relic/agent/configuration/manager.rb +74 -64
  37. data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
  38. data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
  39. data/lib/new_relic/agent/configuration/server_source.rb +14 -12
  40. data/lib/new_relic/agent/configuration/yaml_source.rb +26 -5
  41. data/lib/new_relic/agent/connect/request_builder.rb +14 -15
  42. data/lib/new_relic/agent/connect/response_handler.rb +0 -3
  43. data/lib/new_relic/agent/custom_event_aggregator.rb +9 -9
  44. data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
  45. data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
  46. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
  47. data/lib/new_relic/agent/database.rb +30 -31
  48. data/lib/new_relic/agent/datastores/metric_helper.rb +13 -11
  49. data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
  50. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
  51. data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
  52. data/lib/new_relic/agent/datastores/mongo.rb +5 -10
  53. data/lib/new_relic/agent/datastores/redis.rb +2 -4
  54. data/lib/new_relic/agent/datastores.rb +7 -9
  55. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +9 -9
  56. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +21 -16
  57. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -12
  58. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +42 -43
  59. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
  60. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
  61. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +25 -25
  62. data/lib/new_relic/agent/distributed_tracing.rb +17 -18
  63. data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
  64. data/lib/new_relic/agent/error_collector.rb +65 -50
  65. data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
  66. data/lib/new_relic/agent/error_filter.rb +173 -0
  67. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
  68. data/lib/new_relic/agent/event_aggregator.rb +1 -1
  69. data/lib/new_relic/agent/event_buffer.rb +6 -7
  70. data/lib/new_relic/agent/event_listener.rb +0 -1
  71. data/lib/new_relic/agent/event_loop.rb +14 -14
  72. data/lib/new_relic/agent/external.rb +1 -34
  73. data/lib/new_relic/agent/guid_generator.rb +2 -9
  74. data/lib/new_relic/agent/harvester.rb +3 -4
  75. data/lib/new_relic/agent/heap.rb +1 -3
  76. data/lib/new_relic/agent/hostname.rb +16 -10
  77. data/lib/new_relic/agent/http_clients/abstract.rb +7 -9
  78. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
  79. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
  80. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
  81. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
  82. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +8 -3
  83. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
  84. data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
  85. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
  86. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +28 -26
  87. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  88. data/lib/new_relic/agent/instrumentation/active_job.rb +12 -5
  89. data/lib/new_relic/agent/instrumentation/active_merchant.rb +17 -3
  90. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
  91. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +56 -46
  92. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
  93. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
  94. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +22 -16
  95. data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
  96. data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +23 -0
  97. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +20 -0
  98. data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +12 -0
  99. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +24 -0
  100. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +18 -9
  101. data/lib/new_relic/agent/instrumentation/authlogic.rb +10 -0
  102. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  103. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +8 -9
  104. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +52 -46
  105. data/lib/new_relic/agent/instrumentation/curb/chain.rb +20 -21
  106. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
  107. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +10 -11
  108. data/lib/new_relic/agent/instrumentation/data_mapper.rb +22 -10
  109. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
  110. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
  111. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +23 -4
  112. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
  113. data/lib/new_relic/agent/instrumentation/excon.rb +3 -23
  114. data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
  115. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
  116. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  117. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
  118. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
  119. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
  120. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
  121. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
  122. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
  123. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
  124. data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
  125. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
  126. data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
  127. data/lib/new_relic/agent/instrumentation/logger.rb +26 -0
  128. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
  129. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
  130. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
  131. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
  132. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +5 -6
  133. data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
  134. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
  135. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
  136. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
  137. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
  138. data/lib/new_relic/agent/instrumentation/net_http.rb +7 -2
  139. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
  140. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
  141. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
  142. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +2 -2
  143. data/lib/new_relic/agent/instrumentation/padrino.rb +2 -5
  144. data/lib/new_relic/agent/instrumentation/queue_time.rb +8 -8
  145. data/lib/new_relic/agent/instrumentation/rack/chain.rb +8 -7
  146. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +2 -1
  147. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
  148. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -2
  149. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  150. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +11 -47
  151. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
  152. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
  153. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +11 -0
  154. data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
  155. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
  156. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  157. data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
  158. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
  159. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
  160. data/lib/new_relic/agent/instrumentation/redis.rb +5 -1
  161. data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
  162. data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
  163. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +9 -7
  164. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
  165. data/lib/new_relic/agent/instrumentation/resque.rb +17 -8
  166. data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
  167. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
  168. data/lib/new_relic/agent/instrumentation/sidekiq.rb +22 -1
  169. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
  170. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +12 -5
  171. data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -11
  172. data/lib/new_relic/agent/instrumentation/sunspot.rb +11 -1
  173. data/lib/new_relic/agent/instrumentation/thread/chain.rb +24 -0
  174. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +27 -0
  175. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +22 -0
  176. data/lib/new_relic/agent/instrumentation/thread.rb +20 -0
  177. data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
  178. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +40 -0
  179. data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
  180. data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
  181. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
  182. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
  183. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
  184. data/lib/new_relic/agent/internal_agent_error.rb +1 -1
  185. data/lib/new_relic/agent/javascript_instrumentor.rb +38 -33
  186. data/lib/new_relic/agent/linking_metadata.rb +45 -0
  187. data/lib/new_relic/agent/local_log_decorator.rb +37 -0
  188. data/lib/new_relic/agent/log_event_aggregator.rb +234 -0
  189. data/lib/new_relic/agent/log_priority.rb +20 -0
  190. data/lib/new_relic/agent/logging.rb +11 -8
  191. data/lib/new_relic/agent/memory_logger.rb +1 -1
  192. data/lib/new_relic/agent/messaging.rb +46 -62
  193. data/lib/new_relic/agent/method_tracer.rb +145 -144
  194. data/lib/new_relic/agent/method_tracer_helpers.rb +82 -2
  195. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +21 -13
  196. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
  197. data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
  198. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
  199. data/lib/new_relic/agent/monitors.rb +1 -2
  200. data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
  201. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
  202. data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
  203. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
  204. data/lib/new_relic/agent/new_relic_service.rb +61 -53
  205. data/lib/new_relic/agent/noticible_error.rb +0 -2
  206. data/lib/new_relic/agent/null_logger.rb +6 -2
  207. data/lib/new_relic/agent/obfuscator.rb +6 -8
  208. data/lib/new_relic/agent/parameter_filtering.rb +16 -8
  209. data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
  210. data/lib/new_relic/agent/pipe_channel_manager.rb +15 -12
  211. data/lib/new_relic/agent/pipe_service.rb +6 -3
  212. data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
  213. data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
  214. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
  215. data/lib/new_relic/agent/rules_engine.rb +2 -2
  216. data/lib/new_relic/agent/sampler.rb +2 -3
  217. data/lib/new_relic/agent/sampler_collection.rb +2 -3
  218. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  219. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +10 -7
  220. data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -3
  221. data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
  222. data/lib/new_relic/agent/span_event_aggregator.rb +10 -10
  223. data/lib/new_relic/agent/span_event_primitive.rb +48 -45
  224. data/lib/new_relic/agent/sql_sampler.rb +9 -9
  225. data/lib/new_relic/agent/stats.rb +62 -37
  226. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
  227. data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
  228. data/lib/new_relic/agent/stats_engine.rb +7 -7
  229. data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -2
  230. data/lib/new_relic/agent/system_info.rb +22 -20
  231. data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
  232. data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
  233. data/lib/new_relic/agent/threading/backtrace_service.rb +12 -13
  234. data/lib/new_relic/agent/threading/thread_profile.rb +16 -19
  235. data/lib/new_relic/agent/tracer.rb +57 -72
  236. data/lib/new_relic/agent/transaction/abstract_segment.rb +38 -10
  237. data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
  238. data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
  239. data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
  240. data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
  241. data/lib/new_relic/agent/transaction/message_broker_segment.rb +24 -30
  242. data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
  243. data/lib/new_relic/agent/transaction/segment.rb +6 -3
  244. data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
  245. data/lib/new_relic/agent/transaction/trace.rb +8 -8
  246. data/lib/new_relic/agent/transaction/trace_context.rb +14 -16
  247. data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
  248. data/lib/new_relic/agent/transaction/tracing.rb +9 -6
  249. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
  250. data/lib/new_relic/agent/transaction.rb +132 -119
  251. data/lib/new_relic/agent/transaction_error_primitive.rb +18 -16
  252. data/lib/new_relic/agent/transaction_event_aggregator.rb +7 -8
  253. data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
  254. data/lib/new_relic/agent/transaction_event_recorder.rb +1 -1
  255. data/lib/new_relic/agent/transaction_metrics.rb +8 -7
  256. data/lib/new_relic/agent/transaction_sampler.rb +0 -1
  257. data/lib/new_relic/agent/transaction_time_aggregator.rb +11 -11
  258. data/lib/new_relic/agent/utilization/aws.rb +32 -2
  259. data/lib/new_relic/agent/utilization/azure.rb +1 -1
  260. data/lib/new_relic/agent/utilization/vendor.rb +15 -2
  261. data/lib/new_relic/agent/utilization_data.rb +3 -4
  262. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  263. data/lib/new_relic/agent/vm/mri_vm.rb +13 -1
  264. data/lib/new_relic/agent/vm/snapshot.rb +4 -4
  265. data/lib/new_relic/agent/worker_loop.rb +8 -10
  266. data/lib/new_relic/agent.rb +36 -41
  267. data/lib/new_relic/cli/command.rb +15 -17
  268. data/lib/new_relic/cli/commands/deployments.rb +21 -23
  269. data/lib/new_relic/cli/commands/install.rb +6 -10
  270. data/lib/new_relic/coerce.rb +5 -8
  271. data/lib/new_relic/collection_helper.rb +48 -47
  272. data/lib/new_relic/constants.rb +0 -4
  273. data/lib/new_relic/control/class_methods.rb +2 -2
  274. data/lib/new_relic/control/frameworks/external.rb +1 -1
  275. data/lib/new_relic/control/frameworks/rails.rb +5 -6
  276. data/lib/new_relic/control/frameworks/rails3.rb +2 -3
  277. data/lib/new_relic/control/frameworks/ruby.rb +2 -2
  278. data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
  279. data/lib/new_relic/control/instance_methods.rb +4 -5
  280. data/lib/new_relic/control/instrumentation.rb +35 -5
  281. data/lib/new_relic/control/server_methods.rb +2 -3
  282. data/lib/new_relic/control.rb +0 -1
  283. data/lib/new_relic/dependency_detection.rb +7 -9
  284. data/lib/new_relic/environment_report.rb +16 -18
  285. data/lib/new_relic/helper.rb +45 -5
  286. data/lib/new_relic/language_support.rb +20 -2
  287. data/lib/new_relic/latest_changes.rb +2 -2
  288. data/lib/new_relic/local_environment.rb +9 -7
  289. data/lib/new_relic/metric_data.rb +6 -7
  290. data/lib/new_relic/metric_spec.rb +3 -3
  291. data/lib/new_relic/noticed_error.rb +18 -19
  292. data/lib/new_relic/rack/agent_middleware.rb +2 -2
  293. data/lib/new_relic/rack/browser_monitoring.rb +9 -9
  294. data/lib/new_relic/recipes/capistrano3.rb +11 -13
  295. data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
  296. data/lib/new_relic/supportability_helper.rb +2 -2
  297. data/lib/new_relic/traced_thread.rb +35 -0
  298. data/lib/new_relic/version.rb +5 -16
  299. data/lib/newrelic_rpm.rb +10 -34
  300. data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
  301. data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
  302. data/lib/tasks/all.rb +2 -2
  303. data/lib/tasks/config.html.erb +14 -25
  304. data/lib/tasks/config.rake +36 -27
  305. data/lib/tasks/multiverse.rb +4 -6
  306. data/lib/tasks/tests.rake +3 -7
  307. data/newrelic.yml +610 -3
  308. data/newrelic_rpm.gemspec +14 -14
  309. data/recipes/newrelic.rb +1 -1
  310. data/test/agent_helper.rb +98 -59
  311. metadata +69 -20
  312. data/ROADMAP.md +0 -24
  313. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
  314. data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
  315. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
  316. data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
  317. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
  318. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
  319. data/lib/new_relic/agent/supported_versions.rb +0 -275
  320. data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -13,8 +13,9 @@ module NewRelic
13
13
  DEFAULT_PROC = Proc.new { |hash, name| hash[name] = NewRelic::Agent::Stats.new }
14
14
 
15
15
  def initialize
16
+ @lock = Mutex.new
16
17
  @unscoped = Hash.new(&DEFAULT_PROC)
17
- @scoped = Hash.new(&DEFAULT_PROC)
18
+ @scoped = Hash.new(&DEFAULT_PROC)
18
19
  end
19
20
 
20
21
  # As a general rule, when recording a scoped metric, the corresponding
@@ -25,11 +26,11 @@ module NewRelic
25
26
  # propagate them into unscoped metrics as well when instances of this
26
27
  # class are merged into the global metric store.
27
28
  #
28
- def record_scoped_and_unscoped(names, value=nil, aux=nil, &blk)
29
+ def record_scoped_and_unscoped(names, value = nil, aux = nil, &blk)
29
30
  _record_metrics(names, value, aux, @scoped, &blk)
30
31
  end
31
32
 
32
- def record_unscoped(names, value=nil, aux=nil, &blk)
33
+ def record_unscoped(names, value = nil, aux = nil, &blk)
33
34
  _record_metrics(names, value, aux, @unscoped, &blk)
34
35
  end
35
36
 
@@ -42,11 +43,11 @@ module NewRelic
42
43
  end
43
44
 
44
45
  def each_unscoped
45
- @unscoped.each { |name, stats| yield name, stats }
46
+ @lock.synchronize { @unscoped.each { |name, stats| yield name, stats } }
46
47
  end
47
48
 
48
49
  def each_scoped
49
- @scoped.each { |name, stats| yield name, stats }
50
+ @lock.synchronize { @scoped.each { |name, stats| yield name, stats } }
50
51
  end
51
52
 
52
53
  def _record_metrics(names, value, aux, target, &blk)
@@ -54,10 +55,10 @@ module NewRelic
54
55
  case names
55
56
  when Array
56
57
  names.each do |name|
57
- target[name].record(value, aux, &blk)
58
+ @lock.synchronize { target[name].record(value, aux, &blk) }
58
59
  end
59
60
  else
60
- target[names].record(value, aux, &blk)
61
+ @lock.synchronize { target[names].record(value, aux, &blk) }
61
62
  end
62
63
  end
63
64
  end
@@ -8,7 +8,6 @@ require 'new_relic/agent/transaction/trace_builder'
8
8
 
9
9
  module NewRelic
10
10
  module Agent
11
-
12
11
  # This class contains the logic for recording and storing transaction
13
12
  # traces (sometimes referred to as 'transaction samples').
14
13
  #
@@ -14,25 +14,25 @@ module NewRelic
14
14
  module TransactionTimeAggregator
15
15
  TransactionStats = Struct.new :transaction_started_at, :elapsed_transaction_time
16
16
 
17
- @lock = Mutex.new
18
- @harvest_cycle_started_at = Time.now
17
+ @lock = Mutex.new
18
+ @harvest_cycle_started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
19
19
 
20
20
  @stats = Hash.new do |h, k|
21
21
  h[k] = TransactionStats.new nil, 0.0
22
22
  end
23
23
 
24
- def reset!(timestamp = Time.now)
24
+ def reset!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
25
25
  @harvest_cycle_started_at = timestamp
26
26
  @stats.clear
27
27
  end
28
28
 
29
- def transaction_start(timestamp = Time.now)
29
+ def transaction_start(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
30
30
  @lock.synchronize do
31
31
  set_transaction_start_time timestamp
32
32
  end
33
33
  end
34
34
 
35
- def transaction_stop(timestamp = Time.now, starting_thread_id = current_thread)
35
+ def transaction_stop(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), starting_thread_id = current_thread)
36
36
  @lock.synchronize do
37
37
  record_elapsed_transaction_time_until timestamp, starting_thread_id
38
38
  set_transaction_start_time nil, starting_thread_id
@@ -41,7 +41,7 @@ module NewRelic
41
41
 
42
42
  INSTANCE_BUSY_METRIC = 'Instance/Busy'.freeze
43
43
 
44
- def harvest!(timestamp = Time.now)
44
+ def harvest!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
45
45
  active_threads = 0
46
46
  result = @lock.synchronize do
47
47
  # Sum up the transaction times spent in each thread
@@ -50,7 +50,7 @@ module NewRelic
50
50
  end
51
51
 
52
52
  active_threads = @stats.size
53
- elapsed_harvest_time = (timestamp - @harvest_cycle_started_at) * active_threads
53
+ elapsed_harvest_time = (timestamp - @harvest_cycle_started_at) * active_threads
54
54
  @harvest_cycle_started_at = timestamp
55
55
 
56
56
  # Clear out the stats for all threads, _except_ the live ones
@@ -75,9 +75,9 @@ module NewRelic
75
75
  end
76
76
 
77
77
  module_function :reset!,
78
- :transaction_start,
79
- :transaction_stop,
80
- :harvest!
78
+ :transaction_start,
79
+ :transaction_stop,
80
+ :harvest!
81
81
 
82
82
  class << self
83
83
  private
@@ -146,7 +146,7 @@ module NewRelic
146
146
  def log_missing_elapsed_transaction_time
147
147
  transaction_name = Tracer.current_transaction &&
148
148
  Tracer.current_transaction.best_name ||
149
- "unknown"
149
+ "unknown"
150
150
  NewRelic::Agent.logger.warn("Unable to calculate elapsed transaction time for #{transaction_name}")
151
151
  end
152
152
  end
@@ -8,9 +8,39 @@ module NewRelic
8
8
  module Agent
9
9
  module Utilization
10
10
  class AWS < Vendor
11
+ IMDS_BASE_URL = 'http://169.254.169.254/latest'.freeze
12
+ IMDS_KEYS = %w[instanceId instanceType availabilityZone].freeze
13
+ IMDS_TOKEN_TTL_SECS = '60'.freeze
14
+ TOKEN_OPEN_TIMEOUT_SECS = 1.freeze
15
+ TOKEN_READ_TIMEOUT_SECS = 1.freeze
16
+
17
+ class << self
18
+ def imds_token
19
+ uri = URI.parse("#{IMDS_BASE_URL}/api/token")
20
+ http = Net::HTTP.new(uri.hostname)
21
+ http.open_timeout = TOKEN_OPEN_TIMEOUT_SECS
22
+ http.read_timeout = TOKEN_READ_TIMEOUT_SECS
23
+ response = http.send_request('PUT',
24
+ uri.path,
25
+ '',
26
+ {'X-aws-ec2-metadata-token-ttl-seconds' => IMDS_TOKEN_TTL_SECS})
27
+ unless response.code == Vendor::SUCCESS
28
+ NewRelic::Agent.logger.debug 'Failed to obtain an AWS token for use with IMDS - encountered ' \
29
+ "#{response.class} with HTTP response code #{response.code} - " \
30
+ 'assuming non AWS'
31
+ return
32
+ end
33
+
34
+ response.body
35
+ rescue Net::OpenTimeout
36
+ NewRelic::Agent.logger.debug 'Timed out waiting for AWS IMDS - assuming non AWS'
37
+ end
38
+ end
39
+
11
40
  vendor_name "aws"
12
- endpoint "http://169.254.169.254/2016-09-02/dynamic/instance-identity/document"
13
- keys ["instanceId", "instanceType", "availabilityZone"]
41
+ endpoint "#{IMDS_BASE_URL}/dynamic/instance-identity/document"
42
+ keys IMDS_KEYS
43
+ headers 'X-aws-ec2-metadata-token' => -> { imds_token }
14
44
  key_transforms :to_sym
15
45
  end
16
46
  end
@@ -14,4 +14,4 @@ module NewRelic
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -18,7 +18,7 @@ module NewRelic
18
18
  end
19
19
 
20
20
  def headers headers = nil
21
- headers ? @headers = headers.freeze : @headers
21
+ headers ? @headers = headers.freeze : processed_headers
22
22
  end
23
23
 
24
24
  def keys keys = nil
@@ -28,6 +28,16 @@ module NewRelic
28
28
  def key_transforms key_transforms = nil
29
29
  key_transforms ? @key_transforms = Array(key_transforms).freeze : @key_transforms
30
30
  end
31
+
32
+ def processed_headers
33
+ return unless @headers
34
+
35
+ @headers.each_with_object({}) do |(key, value), processed_hash|
36
+ # Header lambdas are expected to return string values. If nil comes back, replace it with :error
37
+ # to signify that the call failed.
38
+ processed_hash[key] = value.class.eql?(Proc) ? value.call || :error : value
39
+ end
40
+ end
31
41
  end
32
42
 
33
43
  attr_reader :metadata
@@ -62,10 +72,13 @@ module NewRelic
62
72
  private
63
73
 
64
74
  def request_metadata
75
+ processed_headers = headers
76
+ raise if processed_headers.values.include?(:error)
77
+
65
78
  Timeout.timeout 1 do
66
79
  response = nil
67
80
  Net::HTTP.start endpoint.host, endpoint.port do |http|
68
- req = Net::HTTP::Get.new endpoint, headers
81
+ req = Net::HTTP::Get.new endpoint, processed_headers
69
82
  response = http.request req
70
83
  end
71
84
  response
@@ -7,17 +7,16 @@ require 'new_relic/agent/utilization/gcp'
7
7
  require 'new_relic/agent/utilization/azure'
8
8
  require 'new_relic/agent/utilization/pcf'
9
9
 
10
-
11
10
  module NewRelic
12
11
  module Agent
13
12
  class UtilizationData
14
13
  METADATA_VERSION = 5
15
14
 
16
15
  VENDORS = {
17
- Utilization::AWS => :'utilization.detect_aws',
18
- Utilization::GCP => :'utilization.detect_gcp',
16
+ Utilization::AWS => :'utilization.detect_aws',
17
+ Utilization::GCP => :'utilization.detect_gcp',
19
18
  Utilization::Azure => :'utilization.detect_azure',
20
- Utilization::PCF => :'utilization.detect_pcf'
19
+ Utilization::PCF => :'utilization.detect_pcf'
21
20
  }
22
21
 
23
22
  def hostname
@@ -16,7 +16,7 @@ module NewRelic
16
16
  class MonotonicGCProfiler
17
17
  def initialize
18
18
  @total_time_s = 0
19
- @lock = Mutex.new
19
+ @lock = Mutex.new
20
20
  end
21
21
 
22
22
  def total_time_s
@@ -49,7 +49,19 @@ module NewRelic
49
49
  end
50
50
 
51
51
  if supports?(:constant_cache_invalidations)
52
- snap.constant_cache_invalidations = RubyVM.stat[:global_constant_state]
52
+ snap.constant_cache_invalidations = gather_constant_cache_invalidations
53
+ end
54
+ end
55
+
56
+ def gather_constant_cache_invalidations
57
+ # Ruby >= 3.2 uses :constant_cache
58
+ # see: https://github.com/ruby/ruby/pull/5433 and https://bugs.ruby-lang.org/issues/18589
59
+ # TODO: now that 3.2+ provides more granual cache invalidation data, should we report it instead of summing?
60
+ if RUBY_VERSION >= '3.2.0'
61
+ RubyVM.stat[:constant_cache].values.sum
62
+ # Ruby < 3.2 uses :global_constant_state
63
+ else
64
+ RubyVM.stat[:global_constant_state]
53
65
  end
54
66
  end
55
67
 
@@ -7,12 +7,12 @@ module NewRelic
7
7
  module VM
8
8
  class Snapshot
9
9
  attr_accessor :gc_total_time, :gc_runs, :major_gc_count, :minor_gc_count,
10
- :total_allocated_object, :heap_live, :heap_free,
11
- :method_cache_invalidations, :constant_cache_invalidations,
12
- :thread_count, :taken_at
10
+ :total_allocated_object, :heap_live, :heap_free,
11
+ :method_cache_invalidations, :constant_cache_invalidations,
12
+ :thread_count, :taken_at
13
13
 
14
14
  def initialize
15
- @taken_at = Time.now.to_f
15
+ @taken_at = Process.clock_gettime(Process::CLOCK_REALTIME)
16
16
  end
17
17
  end
18
18
  end
@@ -6,19 +6,17 @@ require 'thread'
6
6
 
7
7
  module NewRelic
8
8
  module Agent
9
-
10
9
  # A worker loop executes a set of registered tasks on a single thread.
11
10
  # A task is a proc or block with a specified call period in seconds.
12
11
  class WorkerLoop
13
-
14
12
  attr_accessor :period, :propagate_errors
15
13
  attr_reader :iterations
16
14
 
17
15
  # Optional argument :duration (in seconds) for how long the worker loop runs
18
16
  # or :limit (integer) for max number of iterations
19
- def initialize(opts={})
17
+ def initialize(opts = {})
20
18
  @should_run = true
21
- @next_invocation_time = Time.now
19
+ @next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
22
20
  @period = 60.0
23
21
  @duration = opts[:duration]
24
22
  @limit = opts[:limit]
@@ -34,7 +32,7 @@ module NewRelic
34
32
  @should_run = true
35
33
  @iterations = 0
36
34
 
37
- now = Time.now
35
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
38
36
  @deadline = now + @duration if @duration
39
37
  @next_invocation_time = (now + @period)
40
38
  end
@@ -42,9 +40,9 @@ module NewRelic
42
40
  # Run infinitely, calling the registered tasks at their specified
43
41
  # call periods. The caller is responsible for creating the thread
44
42
  # that runs this worker loop. This will run the task immediately.
45
- def run(period=nil, &block)
43
+ def run(period = nil, &block)
46
44
  setup(period, block)
47
- while keep_running? do
45
+ while keep_running?
48
46
  sleep_time = schedule_next_invocation
49
47
  sleep(sleep_time) if sleep_time > 0
50
48
  run_task if keep_running?
@@ -53,11 +51,11 @@ module NewRelic
53
51
  end
54
52
 
55
53
  def schedule_next_invocation
56
- now = Time.now
54
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
57
55
  while @next_invocation_time <= now && @period > 0
58
56
  @next_invocation_time += @period
59
57
  end
60
- @next_invocation_time - Time.now
58
+ @next_invocation_time - Process.clock_gettime(Process::CLOCK_REALTIME)
61
59
  end
62
60
 
63
61
  # a simple accessor for @should_run
@@ -66,7 +64,7 @@ module NewRelic
66
64
  end
67
65
 
68
66
  def under_duration?
69
- !@deadline || Time.now < @deadline
67
+ !@deadline || Process.clock_gettime(Process::CLOCK_REALTIME) < @deadline
70
68
  end
71
69
 
72
70
  def under_limit?
@@ -44,6 +44,7 @@ module NewRelic
44
44
  require 'new_relic/agent/sql_sampler'
45
45
  require 'new_relic/agent/commands/thread_profiler_session'
46
46
  require 'new_relic/agent/error_collector'
47
+ require 'new_relic/agent/error_filter'
47
48
  require 'new_relic/agent/sampler'
48
49
  require 'new_relic/agent/database'
49
50
  require 'new_relic/agent/database_adapter'
@@ -58,6 +59,8 @@ module NewRelic
58
59
  require 'new_relic/agent/logging'
59
60
  require 'new_relic/agent/distributed_tracing'
60
61
  require 'new_relic/agent/attribute_processing'
62
+ require 'new_relic/agent/linking_metadata'
63
+ require 'new_relic/agent/local_log_decorator'
61
64
 
62
65
  require 'new_relic/agent/instrumentation/controller_instrumentation'
63
66
 
@@ -110,19 +113,19 @@ module NewRelic
110
113
  @tracer_queue = []
111
114
 
112
115
  # The singleton Agent instance. Used internally.
113
- def agent #:nodoc:
116
+ def agent # :nodoc:
114
117
  return @agent if @agent
115
118
  NewRelic::Agent.logger.warn("Agent unavailable as it hasn't been started.")
116
119
  NewRelic::Agent.logger.warn(caller.join("\n"))
117
120
  nil
118
121
  end
119
122
 
120
- def agent=(new_instance)#:nodoc:
123
+ def agent=(new_instance) # :nodoc:
121
124
  @agent = new_instance
122
125
  add_deferred_method_tracers_now
123
126
  end
124
127
 
125
- alias instance agent #:nodoc:
128
+ alias instance agent # :nodoc:
126
129
 
127
130
  # Primary interface to logging is fronted by this accessor
128
131
  # Access via ::NewRelic::Agent.logger
@@ -138,20 +141,22 @@ module NewRelic
138
141
  # is initialized; these methods enable us to defer these calls
139
142
  # until we have started up and can process them.
140
143
  #
141
- def add_or_defer_method_tracer(receiver, method_name, metric_name_code, options)
144
+ def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
142
145
  @tracer_lock.synchronize do
146
+ options[:code_information] = NewRelic::Agent::MethodTracerHelpers.code_information(receiver, method_name)
147
+
143
148
  if @agent
144
- receiver.send(:_add_method_tracer_now, method_name, metric_name_code, options)
149
+ receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
145
150
  else
146
- @tracer_queue << [receiver, method_name, metric_name_code, options]
151
+ @tracer_queue << [receiver, method_name, metric_name, options]
147
152
  end
148
153
  end
149
154
  end
150
155
 
151
156
  def add_deferred_method_tracers_now
152
157
  @tracer_lock.synchronize do
153
- @tracer_queue.each do |receiver, method_name, metric_name_code, options|
154
- receiver.send(:_add_method_tracer_now, method_name, metric_name_code, options)
158
+ @tracer_queue.each do |receiver, method_name, metric_name, options|
159
+ receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
155
160
  end
156
161
 
157
162
  @tracer_queue = []
@@ -186,7 +191,7 @@ module NewRelic
186
191
  # This method is safe to use from any thread.
187
192
  #
188
193
  # @api public
189
- def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
194
+ def record_metric(metric_name, value) # THREAD_LOCAL_ACCESS
190
195
  record_api_supportability_metric(:record_metric)
191
196
 
192
197
  return unless agent
@@ -216,14 +221,14 @@ module NewRelic
216
221
 
217
222
  SUPPORTABILITY_INCREMENT_METRIC = 'Supportability/API/increment_metric'.freeze
218
223
 
219
- def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
224
+ def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS
220
225
  return unless agent
221
226
  if amount == 1
222
227
  metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]
223
- agent.stats_engine.tl_record_unscoped_metrics(metrics) {|stats| stats.increment_count}
228
+ agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }
224
229
  else
225
- agent.stats_engine.tl_record_unscoped_metrics(metric_name) {|stats| stats.increment_count(amount)}
226
- agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) {|stats| stats.increment_count}
230
+ agent.stats_engine.tl_record_unscoped_metrics(metric_name) { |stats| stats.increment_count(amount) }
231
+ agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) { |stats| stats.increment_count }
227
232
  end
228
233
  end
229
234
 
@@ -280,7 +285,7 @@ module NewRelic
280
285
  #
281
286
  # @api public
282
287
  #
283
- def notice_error(exception, options={})
288
+ def notice_error(exception, options = {})
284
289
  record_api_supportability_metric(:notice_error)
285
290
 
286
291
  Transaction.notice_error(exception, options)
@@ -346,9 +351,9 @@ module NewRelic
346
351
  #
347
352
  # @api public
348
353
  #
349
- def manual_start(options={})
354
+ def manual_start(options = {})
350
355
  raise "Options must be a hash" unless Hash === options
351
- NewRelic::Control.instance.init_plugin({ :agent_enabled => true, :sync_startup => true }.merge(options))
356
+ NewRelic::Control.instance.init_plugin({:agent_enabled => true, :sync_startup => true}.merge(options))
352
357
  record_api_supportability_metric(:manual_start)
353
358
  end
354
359
 
@@ -377,7 +382,7 @@ module NewRelic
377
382
  #
378
383
  # @api public
379
384
  #
380
- def after_fork(options={})
385
+ def after_fork(options = {})
381
386
  record_api_supportability_metric(:after_fork)
382
387
  agent.after_fork(options) if agent
383
388
  end
@@ -389,7 +394,7 @@ module NewRelic
389
394
  #
390
395
  # @api public
391
396
  #
392
- def shutdown(options={})
397
+ def shutdown(options = {})
393
398
  record_api_supportability_metric(:shutdown)
394
399
  agent.shutdown if agent
395
400
  end
@@ -511,7 +516,7 @@ module NewRelic
511
516
  #
512
517
  def disable_transaction_tracing
513
518
  Deprecator.deprecate :disable_transaction_tracing,
514
- 'disable_all_tracing or ignore_transaction'
519
+ 'disable_all_tracing or ignore_transaction'
515
520
  record_api_supportability_metric(:disable_transaction_tracing)
516
521
  yield
517
522
  end
@@ -571,7 +576,7 @@ module NewRelic
571
576
  #
572
577
  # @api public
573
578
  #
574
- def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
579
+ def add_custom_attributes(params) # THREAD_LOCAL_ACCESS
575
580
  record_api_supportability_metric(:add_custom_attributes)
576
581
 
577
582
  if params.is_a? Hash
@@ -643,7 +648,7 @@ module NewRelic
643
648
  #
644
649
  # @api public
645
650
  #
646
- def set_transaction_name(name, options={})
651
+ def set_transaction_name(name, options = {})
647
652
  record_api_supportability_metric(:set_transaction_name)
648
653
  Transaction.set_overriding_transaction_name(name, options[:category])
649
654
  end
@@ -653,7 +658,7 @@ module NewRelic
653
658
  #
654
659
  # @api public
655
660
  #
656
- def get_transaction_name #THREAD_LOCAL_ACCESS
661
+ def get_transaction_name # THREAD_LOCAL_ACCESS
657
662
  record_api_supportability_metric(:get_transaction_name)
658
663
 
659
664
  txn = Transaction.tl_current
@@ -685,13 +690,13 @@ module NewRelic
685
690
  # Subscribe to events of +event_type+, calling the given +handler+
686
691
  # when one is sent.
687
692
  def subscribe(event_type, &handler)
688
- agent.events.subscribe( event_type, &handler )
693
+ agent.events.subscribe(event_type, &handler)
689
694
  end
690
695
 
691
696
  # Fire an event of the specified +event_type+, passing it an the given +args+
692
697
  # to any registered handlers.
693
698
  def notify(event_type, *args)
694
- agent.events.notify( event_type, *args )
699
+ agent.events.notify(event_type, *args)
695
700
  rescue
696
701
  NewRelic::Agent.logger.debug "Ignoring exception during %p event notification" % [event_type]
697
702
  end
@@ -725,24 +730,12 @@ module NewRelic
725
730
  # @api public
726
731
  def linking_metadata
727
732
  metadata = Hash.new
728
- metadata[ENTITY_NAME_KEY] = config[:app_name][0]
729
- metadata[ENTITY_TYPE_KEY] = ENTITY_TYPE
730
- metadata[HOSTNAME_KEY] = Hostname.get
731
-
732
- if entity_guid = config[:entity_guid]
733
- metadata[ENTITY_GUID_KEY] = entity_guid
734
- end
735
-
736
- if trace_id = Tracer.current_trace_id
737
- metadata[TRACE_ID_KEY] = trace_id
738
- end
739
- if span_id = Tracer.current_span_id
740
- metadata[SPAN_ID_KEY] = span_id
741
- end
733
+ LinkingMetadata.append_service_linking_metadata(metadata)
734
+ LinkingMetadata.append_trace_linking_metadata(metadata)
742
735
  metadata
743
736
  end
744
737
 
745
- #@!endgroup
738
+ # @!endgroup
746
739
 
747
740
  # @!group Manual browser monitoring configuration
748
741
 
@@ -758,13 +751,15 @@ module NewRelic
758
751
  # In previous agents there was a corresponding footer required, but all the
759
752
  # work is now done by this single method.
760
753
  #
754
+ # @param [String] nonce The nonce to use in the javascript tag for browser instrumentation
755
+ #
761
756
  # @api public
762
757
  #
763
- def browser_timing_header
758
+ def browser_timing_header(nonce = nil)
764
759
  record_api_supportability_metric(:browser_timing_header)
765
760
 
766
761
  return "" unless agent
767
- agent.javascript_instrumentor.browser_timing_header
762
+ agent.javascript_instrumentor.browser_timing_header(nonce)
768
763
  end
769
764
 
770
765
  # @!endgroup
@@ -15,7 +15,7 @@ module NewRelic
15
15
  # Capture a failure to execute the command.
16
16
  class CommandFailure < StandardError
17
17
  attr_reader :options
18
- def initialize message, opt_parser=nil
18
+ def initialize message, opt_parser = nil
19
19
  super message
20
20
  @options = opt_parser
21
21
  end
@@ -32,13 +32,13 @@ module NewRelic
32
32
  def initialize(command_line_args)
33
33
  if Hash === command_line_args
34
34
  # command line args is an options hash
35
- command_line_args.each do | key, value |
35
+ command_line_args.each do |key, value|
36
36
  instance_variable_set "@#{key}", value.to_s if value
37
37
  end
38
38
  else
39
39
  # parse command line args. Throw an exception on a bad arg.
40
- @options = options do | opts |
41
- opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
40
+ @options = options do |opts|
41
+ opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
42
42
  end
43
43
  @leftover = @options.parse(command_line_args)
44
44
  end
@@ -55,8 +55,7 @@ module NewRelic
55
55
  Dir[cmds].each { |command| require command }
56
56
 
57
57
  def self.run
58
-
59
- @command_names = @commands.map{ |c| c.command }
58
+ @command_names = @commands.map { |c| c.command }
60
59
 
61
60
  extra = []
62
61
  options = ARGV.options do |opts|
@@ -65,7 +64,7 @@ module NewRelic
65
64
  $stdout.puts "warning: the 'newrelic_cmd' script has been renamed 'newrelic'"
66
65
  script_name = 'newrelic'
67
66
  end
68
- opts.banner = "Usage: #{script_name} [ #{ @command_names.join(" | ")} ] [options]"
67
+ opts.banner = "Usage: #{script_name} [ #{@command_names.join(" | ")} ] [options]"
69
68
  opts.separator "use '#{script_name} <command> -h' to see detailed command options"
70
69
  opts
71
70
  end
@@ -73,19 +72,18 @@ module NewRelic
73
72
  command = extra.shift
74
73
  # just make it a little easier on them
75
74
  command = 'deployments' if command =~ /deploy/
76
- if command.nil?
77
- STDERR.puts options
78
- elsif !@command_names.include?(command)
79
- STDERR.puts "Unrecognized command: #{command}"
80
- STDERR.puts options
81
- else
82
- command_class = @commands.find{ |c| c.command == command}
83
- command_class.new(extra).run
84
- end
75
+ if command.nil?
76
+ STDERR.puts options
77
+ elsif !@command_names.include?(command)
78
+ STDERR.puts "Unrecognized command: #{command}"
79
+ STDERR.puts options
80
+ else
81
+ command_class = @commands.find { |c| c.command == command }
82
+ command_class.new(extra).run
83
+ end
85
84
  rescue OptionParser::InvalidOption => e
86
85
  raise NewRelic::Cli::Command::CommandFailure, e.message
87
86
  end
88
87
  end
89
-
90
88
  end
91
89
  end