newrelic_rpm 8.15.0 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (342) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +26 -0
  3. data/CHANGELOG.md +538 -44
  4. data/CONTRIBUTING.md +1 -1
  5. data/Gemfile +1 -1
  6. data/README.md +11 -6
  7. data/Rakefile +9 -9
  8. data/Thorfile +1 -1
  9. data/bin/newrelic +1 -0
  10. data/bin/newrelic_cmd +1 -0
  11. data/bin/nrdebug +36 -36
  12. data/init.rb +1 -1
  13. data/lib/new_relic/agent/agent.rb +3 -16
  14. data/lib/new_relic/agent/agent_helpers/connect.rb +5 -10
  15. data/lib/new_relic/agent/agent_helpers/harvest.rb +4 -4
  16. data/lib/new_relic/agent/agent_helpers/shutdown.rb +5 -5
  17. data/lib/new_relic/agent/agent_helpers/special_startup.rb +3 -4
  18. data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +47 -39
  19. data/lib/new_relic/agent/agent_helpers/startup.rb +13 -13
  20. data/lib/new_relic/agent/agent_helpers/transmit.rb +6 -6
  21. data/lib/new_relic/agent/agent_logger.rb +9 -9
  22. data/lib/new_relic/agent/attribute_filter.rb +2 -4
  23. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  24. data/lib/new_relic/agent/attribute_processing.rb +2 -2
  25. data/lib/new_relic/agent/audit_logger.rb +5 -5
  26. data/lib/new_relic/agent/autostart.rb +1 -1
  27. data/lib/new_relic/agent/commands/agent_command.rb +2 -2
  28. data/lib/new_relic/agent/commands/agent_command_router.rb +5 -4
  29. data/lib/new_relic/agent/commands/thread_profiler_session.rb +8 -8
  30. data/lib/new_relic/agent/configuration/default_source.rb +428 -586
  31. data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
  32. data/lib/new_relic/agent/configuration/high_security_source.rb +3 -5
  33. data/lib/new_relic/agent/configuration/manager.rb +16 -2
  34. data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -26
  35. data/lib/new_relic/agent/configuration/server_source.rb +24 -24
  36. data/lib/new_relic/agent/configuration/yaml_source.rb +17 -4
  37. data/lib/new_relic/agent/connect/request_builder.rb +1 -1
  38. data/lib/new_relic/agent/connect/response_handler.rb +1 -1
  39. data/lib/new_relic/agent/custom_event_aggregator.rb +4 -4
  40. data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
  41. data/lib/new_relic/agent/database/obfuscation_helpers.rb +2 -2
  42. data/lib/new_relic/agent/database/obfuscator.rb +2 -2
  43. data/lib/new_relic/agent/database.rb +4 -18
  44. data/lib/new_relic/agent/datastores/metric_helper.rb +5 -5
  45. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -11
  46. data/lib/new_relic/agent/datastores/redis.rb +6 -6
  47. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +8 -10
  48. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -10
  49. data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +7 -7
  50. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
  51. data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +6 -6
  52. data/lib/new_relic/agent/distributed_tracing/trace_context.rb +7 -7
  53. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +4 -4
  54. data/lib/new_relic/agent/distributed_tracing.rb +6 -6
  55. data/lib/new_relic/agent/error_collector.rb +36 -8
  56. data/lib/new_relic/agent/error_filter.rb +5 -5
  57. data/lib/new_relic/agent/error_trace_aggregator.rb +5 -4
  58. data/lib/new_relic/agent/event_loop.rb +3 -3
  59. data/lib/new_relic/agent/external.rb +1 -1
  60. data/lib/new_relic/agent/harvester.rb +1 -3
  61. data/lib/new_relic/agent/heap.rb +2 -1
  62. data/lib/new_relic/agent/hostname.rb +1 -1
  63. data/lib/new_relic/agent/http_clients/abstract.rb +9 -21
  64. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
  65. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +7 -3
  66. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
  67. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +7 -5
  68. data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +4 -0
  69. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +6 -2
  70. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
  71. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
  72. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +8 -5
  73. data/lib/new_relic/agent/http_clients/uri_util.rb +2 -2
  74. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -19
  75. data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +42 -0
  76. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -2
  77. data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
  78. data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
  79. data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
  80. data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
  81. data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
  82. data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
  83. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +10 -10
  84. data/lib/new_relic/agent/instrumentation/active_job.rb +16 -3
  85. data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
  86. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
  87. data/lib/new_relic/agent/instrumentation/active_record.rb +4 -3
  88. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +38 -36
  89. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +5 -4
  90. data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
  91. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +3 -2
  92. data/lib/new_relic/agent/instrumentation/active_storage.rb +4 -0
  93. data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -30
  94. data/lib/new_relic/agent/instrumentation/active_support.rb +21 -6
  95. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  96. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
  97. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  98. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
  99. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  100. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
  101. data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
  102. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  103. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  104. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  105. data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
  106. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
  107. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +12 -3
  108. data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
  109. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
  110. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
  111. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
  112. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -6
  113. data/lib/new_relic/agent/instrumentation/curb/chain.rb +1 -1
  114. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +9 -5
  115. data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
  116. data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
  117. data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +2 -1
  118. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
  119. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -1
  120. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -1
  121. data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -2
  122. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +8 -4
  123. data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -2
  124. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  125. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  126. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  127. data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
  128. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +5 -1
  129. data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
  130. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +27 -0
  131. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +23 -0
  132. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +25 -0
  133. data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
  134. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +8 -4
  135. data/lib/new_relic/agent/instrumentation/grape.rb +4 -4
  136. data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
  137. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +7 -2
  138. data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
  139. data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
  140. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +8 -4
  141. data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
  142. data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
  143. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  144. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  145. data/lib/new_relic/agent/instrumentation/httprb.rb +1 -1
  146. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  147. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  148. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  149. data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
  150. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
  151. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  152. data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
  153. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +3 -1
  154. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +14 -5
  155. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +3 -1
  156. data/lib/new_relic/agent/instrumentation/memcache.rb +12 -12
  157. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +3 -3
  158. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
  159. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +6 -8
  160. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
  161. data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
  162. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +46 -1
  163. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +7 -3
  164. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
  165. data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
  166. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -1
  167. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +7 -2
  168. data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
  169. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +4 -4
  170. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +14 -1
  171. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +12 -15
  172. data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
  173. data/lib/new_relic/agent/instrumentation/redis/constants.rb +1 -1
  174. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +6 -1
  175. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  176. data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
  177. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  178. data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
  179. data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
  180. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  181. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
  182. data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
  183. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
  184. data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
  185. data/lib/new_relic/agent/instrumentation/sequel.rb +8 -9
  186. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +10 -10
  187. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  188. data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
  189. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  190. data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -3
  191. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
  192. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +10 -5
  193. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -4
  194. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  195. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
  196. data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
  197. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -8
  198. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
  199. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +6 -1
  200. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +10 -6
  201. data/lib/new_relic/agent/javascript_instrumentor.rb +29 -24
  202. data/lib/new_relic/agent/linking_metadata.rb +2 -2
  203. data/lib/new_relic/agent/log_event_aggregator.rb +64 -17
  204. data/lib/new_relic/agent/log_event_attributes.rb +115 -0
  205. data/lib/new_relic/agent/logging.rb +77 -37
  206. data/lib/new_relic/agent/messaging.rb +9 -7
  207. data/lib/new_relic/agent/method_tracer.rb +7 -7
  208. data/lib/new_relic/agent/method_tracer_helpers.rb +27 -6
  209. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -5
  210. data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -1
  211. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  212. data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
  213. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
  214. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
  215. data/lib/new_relic/agent/new_relic_service.rb +47 -32
  216. data/lib/new_relic/agent/obfuscator.rb +1 -1
  217. data/lib/new_relic/agent/parameter_filtering.rb +6 -6
  218. data/lib/new_relic/agent/pipe_channel_manager.rb +7 -6
  219. data/lib/new_relic/agent/pipe_service.rb +5 -3
  220. data/lib/new_relic/agent/priority_sampled_buffer.rb +1 -1
  221. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
  222. data/lib/new_relic/agent/rules_engine.rb +1 -1
  223. data/lib/new_relic/agent/sampler.rb +2 -1
  224. data/lib/new_relic/agent/sampler_collection.rb +1 -1
  225. data/lib/new_relic/agent/samplers/cpu_sampler.rb +5 -5
  226. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -9
  227. data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -9
  228. data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
  229. data/lib/new_relic/agent/span_event_aggregator.rb +4 -4
  230. data/lib/new_relic/agent/span_event_primitive.rb +18 -6
  231. data/lib/new_relic/agent/sql_sampler.rb +2 -2
  232. data/lib/new_relic/agent/stats.rb +1 -1
  233. data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
  234. data/lib/new_relic/agent/system_info.rb +36 -10
  235. data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
  236. data/lib/new_relic/agent/threading/backtrace_node.rb +3 -3
  237. data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
  238. data/lib/new_relic/agent/threading/thread_profile.rb +5 -5
  239. data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
  240. data/lib/new_relic/agent/tracer.rb +25 -16
  241. data/lib/new_relic/agent/transaction/abstract_segment.rb +109 -48
  242. data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
  243. data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -6
  244. data/lib/new_relic/agent/transaction/distributed_tracing.rb +13 -14
  245. data/lib/new_relic/agent/transaction/external_request_segment.rb +16 -13
  246. data/lib/new_relic/agent/transaction/message_broker_segment.rb +2 -3
  247. data/lib/new_relic/agent/transaction/request_attributes.rb +47 -11
  248. data/lib/new_relic/agent/transaction/segment.rb +1 -1
  249. data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
  250. data/lib/new_relic/agent/transaction/trace.rb +1 -1
  251. data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
  252. data/lib/new_relic/agent/transaction/trace_node.rb +8 -7
  253. data/lib/new_relic/agent/transaction/tracing.rb +10 -4
  254. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
  255. data/lib/new_relic/agent/transaction.rb +90 -58
  256. data/lib/new_relic/agent/transaction_error_primitive.rb +21 -5
  257. data/lib/new_relic/agent/transaction_event_aggregator.rb +4 -4
  258. data/lib/new_relic/agent/transaction_event_primitive.rb +22 -3
  259. data/lib/new_relic/agent/transaction_sampler.rb +3 -3
  260. data/lib/new_relic/agent/transaction_time_aggregator.rb +7 -3
  261. data/lib/new_relic/agent/utilization/aws.rb +1 -1
  262. data/lib/new_relic/agent/utilization/azure.rb +3 -3
  263. data/lib/new_relic/agent/utilization/gcp.rb +4 -6
  264. data/lib/new_relic/agent/utilization/pcf.rb +1 -1
  265. data/lib/new_relic/agent/utilization/vendor.rb +6 -8
  266. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
  267. data/lib/new_relic/agent/vm/mri_vm.rb +9 -8
  268. data/lib/new_relic/agent/worker_loop.rb +1 -1
  269. data/lib/new_relic/agent.rb +133 -36
  270. data/lib/new_relic/cli/command.rb +4 -3
  271. data/lib/new_relic/cli/commands/deployments.rb +26 -25
  272. data/lib/new_relic/cli/commands/install.rb +23 -23
  273. data/lib/new_relic/collection_helper.rb +2 -2
  274. data/lib/new_relic/constants.rb +10 -8
  275. data/lib/new_relic/control/class_methods.rb +4 -10
  276. data/lib/new_relic/control/frameworks/rails.rb +44 -20
  277. data/lib/new_relic/control/frameworks/roda.rb +20 -0
  278. data/lib/new_relic/control/instance_methods.rb +6 -6
  279. data/lib/new_relic/control/instrumentation.rb +1 -15
  280. data/lib/new_relic/control/private_instance_methods.rb +1 -1
  281. data/lib/new_relic/dependency_detection.rb +20 -18
  282. data/lib/new_relic/environment_report.rb +4 -4
  283. data/lib/new_relic/helper.rb +2 -1
  284. data/lib/new_relic/language_support.rb +10 -1
  285. data/lib/new_relic/latest_changes.rb +6 -6
  286. data/lib/new_relic/local_environment.rb +0 -10
  287. data/lib/new_relic/noticed_error.rb +25 -20
  288. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  289. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  290. data/lib/new_relic/rack/browser_monitoring.rb +21 -17
  291. data/lib/new_relic/recipes/capistrano3.rb +1 -1
  292. data/lib/new_relic/recipes/capistrano_legacy.rb +6 -6
  293. data/lib/new_relic/recipes/helpers/send_deployment.rb +5 -5
  294. data/lib/new_relic/supportability_helper.rb +4 -1
  295. data/lib/new_relic/traced_thread.rb +2 -3
  296. data/lib/new_relic/version.rb +2 -2
  297. data/lib/newrelic_rpm.rb +4 -4
  298. data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +6 -6
  299. data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +4 -4
  300. data/lib/tasks/bump_version.rake +21 -0
  301. data/lib/tasks/config.rake +13 -12
  302. data/lib/tasks/coverage_report.rake +4 -4
  303. data/lib/tasks/helpers/config.html.erb +93 -0
  304. data/lib/tasks/helpers/format.rb +19 -15
  305. data/lib/tasks/helpers/newrelicyml.rb +144 -0
  306. data/lib/tasks/helpers/version_bump.rb +62 -0
  307. data/lib/tasks/install.rake +4 -4
  308. data/lib/tasks/instrumentation_generator/instrumentation.thor +16 -19
  309. data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
  310. data/lib/tasks/instrumentation_generator/templates/chain.tt +1 -1
  311. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +1 -1
  312. data/lib/tasks/newrelic.rb +1 -0
  313. data/lib/tasks/newrelicyml.rake +13 -0
  314. data/lib/tasks/tests.rake +77 -6
  315. data/newrelic.yml +393 -274
  316. data/newrelic_rpm.gemspec +41 -30
  317. data/test/agent_helper.rb +25 -24
  318. metadata +172 -35
  319. data/.gitignore +0 -42
  320. data/.project +0 -23
  321. data/.rubocop.yml +0 -1946
  322. data/.rubocop_todo.yml +0 -62
  323. data/.simplecov +0 -15
  324. data/.snyk +0 -11
  325. data/.yardopts +0 -27
  326. data/Brewfile +0 -12
  327. data/DOCKER.md +0 -167
  328. data/Dockerfile +0 -10
  329. data/Guardfile +0 -26
  330. data/config/database.yml +0 -5
  331. data/config.dot +0 -278
  332. data/docker-compose.yml +0 -107
  333. data/lefthook.yml +0 -9
  334. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
  335. data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
  336. data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
  337. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
  338. data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
  339. data/lib/new_relic/agent/range_extensions.rb +0 -27
  340. data/lib/tasks/helpers/removers.rb +0 -33
  341. data/lib/tasks/multiverse.rake +0 -6
  342. data/lib/tasks/multiverse.rb +0 -77
@@ -0,0 +1,115 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic
6
+ module Agent
7
+ class LogEventAttributes
8
+ MAX_ATTRIBUTE_COUNT = 240 # limit is 255, assume we send 15
9
+ ATTRIBUTE_KEY_CHARACTER_LIMIT = 255
10
+ ATTRIBUTE_VALUE_CHARACTER_LIMIT = 4094
11
+
12
+ def add_custom_attributes(attributes)
13
+ return if defined?(@custom_attribute_limit_reached) && @custom_attribute_limit_reached
14
+
15
+ attributes.each do |key, value|
16
+ next if absent?(key) || absent?(value)
17
+
18
+ add_custom_attribute(key, value)
19
+ end
20
+ end
21
+
22
+ def custom_attributes
23
+ @custom_attributes ||= {}
24
+ end
25
+
26
+ private
27
+
28
+ class TruncationError < StandardError
29
+ attr_reader :attribute, :limit
30
+
31
+ def initialize(attribute, limit, msg = "Can't truncate")
32
+ @attribute = attribute
33
+ @limit = limit
34
+ super(msg)
35
+ end
36
+ end
37
+
38
+ class InvalidTypeError < StandardError
39
+ attr_reader :attribute
40
+
41
+ def initialize(attribute, msg = 'Invalid attribute type')
42
+ @attribute = attribute
43
+ super(msg)
44
+ end
45
+ end
46
+
47
+ def absent?(value)
48
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
49
+ end
50
+
51
+ def add_custom_attribute(key, value)
52
+ if custom_attributes.size >= MAX_ATTRIBUTE_COUNT
53
+ NewRelic::Agent.logger.warn(
54
+ 'Too many custom log attributes defined. ' \
55
+ "Only taking the first #{MAX_ATTRIBUTE_COUNT}."
56
+ )
57
+ @custom_attribute_limit_reached = true
58
+ return
59
+ end
60
+
61
+ @custom_attributes.merge!(truncate_attributes(key_to_string(key), value))
62
+ end
63
+
64
+ def key_to_string(key)
65
+ key.is_a?(String) ? key : key.to_s
66
+ end
67
+
68
+ def truncate_attribute(attribute, limit)
69
+ case attribute
70
+ when Integer
71
+ if attribute.digits.length > limit
72
+ raise TruncationError.new(attribute, limit)
73
+ end
74
+ when Float
75
+ if attribute.to_s.length > limit
76
+ raise TruncationError.new(attribute, limit)
77
+ end
78
+ when String, Symbol
79
+ if attribute.length > limit
80
+ attribute = attribute.slice(0..(limit - 1))
81
+ end
82
+ when TrueClass, FalseClass
83
+ attribute
84
+ else
85
+ raise InvalidTypeError.new(attribute)
86
+ end
87
+
88
+ attribute
89
+ end
90
+
91
+ def truncate_attributes(key, value)
92
+ key = truncate_attribute(key, ATTRIBUTE_KEY_CHARACTER_LIMIT)
93
+ value = truncate_attribute(value, ATTRIBUTE_VALUE_CHARACTER_LIMIT)
94
+
95
+ {key => value}
96
+ rescue TruncationError => e
97
+ NewRelic::Agent.logger.warn(
98
+ "Dropping custom log attribute #{key} => #{value} \n" \
99
+ "Length exceeds character limit of #{e.limit}. " \
100
+ "Can't truncate: #{e.attribute}"
101
+ )
102
+
103
+ {}
104
+ rescue InvalidTypeError => e
105
+ NewRelic::Agent.logger.warn(
106
+ "Dropping custom log attribute #{key} => #{value} \n" \
107
+ "Invalid type of #{e.attribute.class} given. " \
108
+ "Can't send #{e.attribute}."
109
+ )
110
+
111
+ {}
112
+ end
113
+ end
114
+ end
115
+ end
@@ -22,16 +22,21 @@ module NewRelic
22
22
  #
23
23
  # @api public
24
24
  class DecoratingFormatter < ::Logger::Formatter
25
- TIMESTAMP_KEY = 'timestamp'.freeze
26
- MESSAGE_KEY = 'message'.freeze
27
- LOG_LEVEL_KEY = 'log.level'.freeze
28
- LOG_NAME_KEY = 'logger.name'.freeze
29
- NEWLINE = "\n".freeze
30
-
31
- QUOTE = '"'.freeze
32
- COLON = ':'.freeze
33
- COMMA = ','.freeze
34
- CLOSING_BRACE = '}'.freeze
25
+ MESSAGE_ELEMENT = 'message'
26
+ LOG_LEVEL_ELEMENT = 'log_level'
27
+ PROG_NAME_ELEMENT = 'prog_name'
28
+ ELEMENTS = ['app_name', 'entity_type', 'hostname', 'entity_guid', 'trace_id', 'span_id', MESSAGE_ELEMENT,
29
+ LOG_LEVEL_ELEMENT, PROG_NAME_ELEMENT].freeze
30
+ TIMESTAMP_KEY = 'timestamp'
31
+ MESSAGE_KEY = 'message'
32
+ LOG_LEVEL_KEY = 'log.level'
33
+ LOG_NAME_KEY = 'logger.name'
34
+ NEWLINE = "\n"
35
+
36
+ QUOTE = '"'
37
+ COLON = ':'
38
+ COMMA = ','
39
+ CLOSING_BRACE = '}'
35
40
  REPLACEMENT_CHAR = '�'
36
41
 
37
42
  def initialize
@@ -41,41 +46,80 @@ module NewRelic
41
46
  end
42
47
 
43
48
  def call(severity, time, progname, msg)
44
- message = String.new('{')
45
- if app_name
46
- add_key_value(message, ENTITY_NAME_KEY, app_name)
47
- message << COMMA
49
+ message = +'{'
50
+ ELEMENTS.each do |element|
51
+ args = case element
52
+ when MESSAGE_ELEMENT then [message, msg]
53
+ when LOG_LEVEL_ELEMENT then [message, severity]
54
+ when PROG_NAME_ELEMENT then [message, progname]
55
+ else [message]
56
+ end
57
+
58
+ send("add_#{element}", *args)
48
59
  end
60
+ message << COMMA
61
+ message << QUOTE << TIMESTAMP_KEY << QUOTE << COLON << (time.to_f * 1000).round.to_s
62
+ message << CLOSING_BRACE << NEWLINE
63
+ end
64
+
65
+ def clear_tags!
66
+ # No-op; just avoiding issues with act-fluent-logger-rails
67
+ end
68
+
69
+ private
70
+
71
+ def add_app_name(message)
72
+ return unless app_name
73
+
74
+ add_key_value(message, ENTITY_NAME_KEY, app_name)
75
+ message << COMMA
76
+ end
77
+
78
+ def add_entity_type(message)
49
79
  add_key_value(message, ENTITY_TYPE_KEY, ENTITY_TYPE)
50
80
  message << COMMA
81
+ end
82
+
83
+ def add_hostname(message)
51
84
  add_key_value(message, HOSTNAME_KEY, Hostname.get)
85
+ end
52
86
 
53
- if entity_guid = Agent.config[:entity_guid]
54
- message << COMMA
55
- add_key_value(message, ENTITY_GUID_KEY, entity_guid)
56
- end
87
+ def add_entity_guid(message)
88
+ return unless entity_guid = Agent.config[:entity_guid]
57
89
 
58
- if trace_id = Tracer.trace_id
59
- message << COMMA
60
- add_key_value(message, TRACE_ID_KEY, trace_id)
61
- end
62
- if span_id = Tracer.span_id
63
- message << COMMA
64
- add_key_value(message, SPAN_ID_KEY, span_id)
65
- end
90
+ message << COMMA
91
+ add_key_value(message, ENTITY_GUID_KEY, entity_guid)
92
+ end
93
+
94
+ def add_trace_id(message)
95
+ return unless trace_id = Tracer.trace_id
66
96
 
97
+ message << COMMA
98
+ add_key_value(message, TRACE_ID_KEY, trace_id)
99
+ end
100
+
101
+ def add_span_id(message)
102
+ return unless span_id = Tracer.span_id
103
+
104
+ message << COMMA
105
+ add_key_value(message, SPAN_ID_KEY, span_id)
106
+ end
107
+
108
+ def add_message(message, msg)
67
109
  message << COMMA
68
110
  message << QUOTE << MESSAGE_KEY << QUOTE << COLON << escape(msg)
69
111
  message << COMMA
112
+ end
113
+
114
+ def add_log_level(message, severity)
70
115
  add_key_value(message, LOG_LEVEL_KEY, severity)
71
- if progname
72
- message << COMMA
73
- add_key_value(message, LOG_NAME_KEY, progname)
74
- end
116
+ end
117
+
118
+ def add_prog_name(message, progname)
119
+ return unless progname
75
120
 
76
121
  message << COMMA
77
- message << QUOTE << TIMESTAMP_KEY << QUOTE << COLON << (time.to_f * 1000).round.to_s
78
- message << CLOSING_BRACE << NEWLINE
122
+ add_key_value(message, LOG_NAME_KEY, progname)
79
123
  end
80
124
 
81
125
  def app_name
@@ -98,10 +142,6 @@ module NewRelic
98
142
  end
99
143
  message.to_json
100
144
  end
101
-
102
- def clear_tags!
103
- # No-op; just avoiding issues with act-fluent-logger-rails
104
- end
105
145
  end
106
146
 
107
147
  # This logger decorates logs with trace and entity metadata, and emits log
@@ -125,7 +165,7 @@ module NewRelic
125
165
  # Positional and Keyword arguments are separated beginning with Ruby 2.7
126
166
  # Signature of ::Logger constructor changes in Ruby 2.4 to have both positional and keyword args
127
167
  # We pivot on Ruby 2.7 for widest supportability with least amount of hassle.
128
- if RUBY_VERSION < "2.7.0"
168
+ if RUBY_VERSION < '2.7.0'
129
169
  def initialize(*args)
130
170
  super(*args)
131
171
  self.formatter = DecoratingFormatter.new
@@ -14,7 +14,7 @@ module NewRelic
14
14
  module Messaging
15
15
  extend self
16
16
 
17
- RABBITMQ_TRANSPORT_TYPE = "RabbitMQ"
17
+ RABBITMQ_TRANSPORT_TYPE = 'RabbitMQ'
18
18
 
19
19
  ATTR_DESTINATION = AttributeFilter::DST_TRANSACTION_EVENTS |
20
20
  AttributeFilter::DST_TRANSACTION_TRACER |
@@ -142,15 +142,16 @@ module NewRelic
142
142
  txn.add_agent_attribute(:'message.queueName', queue_name, ATTR_DESTINATION) if queue_name
143
143
  txn.add_agent_attribute(:'message.replyTo', reply_to, AttributeFilter::DST_NONE) if reply_to
144
144
  rescue => e
145
- NewRelic::Agent.logger.error("Error starting Message Broker consume transaction", e)
145
+ NewRelic::Agent.logger.error('Error starting Message Broker consume transaction', e)
146
146
  end
147
147
 
148
148
  yield
149
149
  ensure
150
150
  begin
151
- txn.finish if txn
151
+ # the following line needs else branch coverage
152
+ txn.finish if txn # rubocop:disable Style/SafeNavigation
152
153
  rescue => e
153
- NewRelic::Agent.logger.error("Error stopping Message Broker consume transaction", e)
154
+ NewRelic::Agent.logger.error('Error stopping Message Broker consume transaction', e)
154
155
  end
155
156
  end
156
157
 
@@ -190,7 +191,8 @@ module NewRelic
190
191
 
191
192
  raise ArgumentError, 'missing required argument: headers' if headers.nil? && CrossAppTracing.cross_app_enabled?
192
193
 
193
- original_headers = headers.nil? ? nil : headers.dup
194
+ # The following line needs else branch coverage
195
+ original_headers = headers.nil? ? nil : headers.dup # rubocop:disable Style/SafeNavigation
194
196
 
195
197
  segment = Tracer.start_message_broker_segment(
196
198
  action: :produce,
@@ -327,9 +329,9 @@ module NewRelic
327
329
 
328
330
  def transaction_name(library, destination_type, destination_name)
329
331
  transaction_name = Transaction::MESSAGE_PREFIX + library
330
- transaction_name << Transaction::MessageBrokerSegment::SLASH
332
+ transaction_name << NewRelic::SLASH
331
333
  transaction_name << Transaction::MessageBrokerSegment::TYPES[destination_type]
332
- transaction_name << Transaction::MessageBrokerSegment::SLASH
334
+ transaction_name << NewRelic::SLASH
333
335
 
334
336
  case destination_type
335
337
  when :queue
@@ -103,7 +103,7 @@ module NewRelic
103
103
  module AddMethodTracer
104
104
  ALLOWED_KEYS = [:metric, :push_scope, :code_header, :code_information, :code_footer].freeze
105
105
 
106
- DEFAULT_SETTINGS = {:push_scope => true, :metric => true, :code_header => "", :code_footer => ""}.freeze
106
+ DEFAULT_SETTINGS = {:push_scope => true, :metric => true, :code_header => '', :code_footer => ''}.freeze
107
107
 
108
108
  # Checks the provided options to make sure that they make
109
109
  # sense. Raises an error if the options are incorrect to
@@ -134,7 +134,7 @@ module NewRelic
134
134
  # Foo._nr_default_metric_name_code('bar') #=> "Custom/#{Foo.name}/bar"
135
135
  def _nr_default_metric_name(method_name)
136
136
  class_name = _nr_derived_class_name
137
- -> (*) { "Custom/#{class_name}/#{method_name}" }
137
+ ->(*) { "Custom/#{class_name}/#{method_name}" }
138
138
  end
139
139
 
140
140
  # Checks to see if the method we are attempting to trace
@@ -170,14 +170,14 @@ module NewRelic
170
170
 
171
171
  def _nr_derived_class_name
172
172
  return self.name if self.name && !self.name.empty?
173
- return "AnonymousModule" if self.to_s.start_with?("#<Module:")
173
+ return 'AnonymousModule' if self.to_s.start_with?('#<Module:')
174
174
 
175
175
  # trying to get the "MyClass" portion of "#<Class:MyClass>"
176
176
  name = self.to_s[/^#<Class:(.+)>$/, 1]
177
- if name.start_with?("0x")
178
- "AnonymousClass"
179
- elsif name.start_with?("#<Class:")
180
- "AnonymousClass/Class"
177
+ if name.start_with?('0x')
178
+ 'AnonymousClass'
179
+ elsif name.start_with?('#<Class:')
180
+ 'AnonymousClass/Class'
181
181
  else
182
182
  "#{name}/Class"
183
183
  end
@@ -11,7 +11,7 @@ module NewRelic
11
11
  # function: the name of the Ruby method
12
12
  # namespace: the Ruby class' namespace as a string, ex: 'MyModule::MyClass'
13
13
  SOURCE_CODE_INFORMATION_PARAMETERS = %i[filepath lineno function namespace].freeze
14
- SOURCE_CODE_INFORMATION_FAILURE_METRIC = "Supportability/CodeLevelMetrics/Ruby/Failure".freeze
14
+ SOURCE_CODE_INFORMATION_FAILURE_METRIC = 'Supportability/CodeLevelMetrics/Ruby/Failure'.freeze
15
15
  MAX_ALLOWED_METRIC_DURATION = 1_000_000_000 # roughly 31 years
16
16
 
17
17
  extend self
@@ -46,13 +46,15 @@ module NewRelic
46
46
  cache_key = "#{object.object_id}#{method_name}".freeze
47
47
  return @code_information[cache_key] if @code_information.key?(cache_key)
48
48
 
49
- namespace, location, is_class_method = namespace_and_location(object, method_name.to_sym)
49
+ info = namespace_and_location(object, method_name.to_sym)
50
+ return ::NewRelic::EMPTY_HASH if info.empty?
50
51
 
52
+ namespace, location, is_class_method = info
51
53
  @code_information[cache_key] = {filepath: location.first,
52
54
  lineno: location.last,
53
55
  function: "#{'self.' if is_class_method}#{method_name}",
54
56
  namespace: namespace}.freeze
55
- rescue => e
57
+ rescue StandardError => e
56
58
  ::NewRelic::Agent.logger.warn("Unable to determine source code info for '#{object}', " \
57
59
  "method '#{method_name}' - #{e.class}: #{e.message}")
58
60
  ::NewRelic::Agent.increment_metric(SOURCE_CODE_INFORMATION_FAILURE_METRIC, 1)
@@ -66,10 +68,10 @@ module NewRelic
66
68
  end
67
69
 
68
70
  # The string representation of a singleton class looks like
69
- # '#<Class:MyModule::MyClass>'. Return the 'MyModule::MyClass' part of
70
- # that string
71
+ # '#<Class:MyModule::MyClass>', or '#<Class:MyModule::MyClass(id: integer, attribute: string)>'
72
+ # Return the 'MyModule::MyClass' part of that string
71
73
  def klass_name(object)
72
- name = Regexp.last_match(1) if object.to_s =~ /^#<Class:(.*)>$/
74
+ name = Regexp.last_match(1) if object.to_s =~ /^#<Class:([\w:]+).*>$/
73
75
  return name if name
74
76
 
75
77
  raise "Unable to glean a class name from string '#{object}'"
@@ -101,6 +103,9 @@ module NewRelic
101
103
  klass = object.singleton_class? ? klassify_singleton(object) : object
102
104
  name = klass.name || '(Anonymous)'
103
105
  is_class_method = false
106
+
107
+ return controller_info(klass, name, is_class_method) if controller_without_method?(klass, method_name)
108
+
104
109
  method = if (klass.instance_methods + klass.private_instance_methods).include?(method_name)
105
110
  klass.instance_method(method_name)
106
111
  else
@@ -109,6 +114,22 @@ module NewRelic
109
114
  end
110
115
  [name, method.source_location, is_class_method]
111
116
  end
117
+
118
+ # Rails controllers can be a special case because by default, controllers in Rails
119
+ # automatically render views with names that correspond to valid routes. This means
120
+ # that a controller method may not have a corresponding method in the controller class.
121
+ def controller_without_method?(klass, method_name)
122
+ defined?(Rails) &&
123
+ defined?(ApplicationController) &&
124
+ klass < ApplicationController &&
125
+ !klass.method_defined?(method_name)
126
+ end
127
+
128
+ def controller_info(klass, name, is_class_method)
129
+ path = Rails.root.join("app/controllers/#{klass.name.underscore}.rb")
130
+
131
+ File.exist?(path) ? [name, [path.to_s, 1], is_class_method] : []
132
+ end
112
133
  end
113
134
  end
114
135
  end
@@ -12,7 +12,6 @@ module NewRelic
12
12
  module Agent
13
13
  module DistributedTracing
14
14
  class CrossAppMonitor < InboundRequestMonitor
15
- NEWRELIC_ID_HEADER = 'X-NewRelic-ID'.freeze
16
15
  NEWRELIC_TXN_HEADER = 'X-NewRelic-Transaction'.freeze
17
16
  NEWRELIC_APPDATA_HEADER = 'X-NewRelic-App-Data'.freeze
18
17
 
@@ -24,7 +23,7 @@ module NewRelic
24
23
  if CrossAppTracing.cross_app_enabled?
25
24
  Deprecator.deprecate('cross_application_tracer')
26
25
  ::NewRelic::Agent.logger.warn(
27
- "[DEPRECATED] Cross application tracing is enabled. Distributed tracing is replacing cross application tracing as the default means of tracing between services. To continue using cross application tracing, enable it with `cross_application_tracer.enabled: true` and `distributed_tracing.enabled: false`"
26
+ '[DEPRECATED] Cross application tracing is enabled. Distributed tracing is replacing cross application tracing as the default means of tracing between services. To continue using cross application tracing, enable it with `cross_application_tracer.enabled: true` and `distributed_tracing.enabled: false`'
28
27
  )
29
28
  end
30
29
 
@@ -35,7 +34,7 @@ module NewRelic
35
34
  rotated = ((seed << 1) | (seed >> 31)) & 0xffffffff
36
35
  app_name = NewRelic::Agent.config[:app_name].first
37
36
  identifier = "#{app_name};#{txn_name}"
38
- sprintf("%08x", rotated ^ hash_transaction_name(identifier))
37
+ sprintf('%08x', rotated ^ hash_transaction_name(identifier))
39
38
  end
40
39
 
41
40
  private
@@ -45,7 +44,7 @@ module NewRelic
45
44
  # :after_call will write our response headers/metrics and clean up the thread
46
45
  def register_event_listeners(events)
47
46
  NewRelic::Agent.logger
48
- .debug("Wiring up Cross Application Tracing to events after finished configuring")
47
+ .debug('Wiring up Cross Application Tracing to events after finished configuring')
49
48
 
50
49
  events.subscribe(:before_call) do |env| # THREAD_LOCAL_ACCESS
51
50
  if id = decoded_id(env) and should_process_request?(id)
@@ -110,7 +109,7 @@ module NewRelic
110
109
  end
111
110
 
112
111
  def hash_transaction_name(identifier)
113
- Digest::MD5.digest(identifier).unpack("@12N").first & 0xffffffff
112
+ Digest::MD5.digest(identifier).unpack('@12N').first & 0xffffffff
114
113
  end
115
114
  end
116
115
  end
@@ -14,7 +14,7 @@ module NewRelic
14
14
 
15
15
  def on_before_call(request)
16
16
  unless NewRelic::Agent.config[:'distributed_tracing.enabled']
17
- NewRelic::Agent.logger.warn("Not configured to accept distributed trace headers")
17
+ NewRelic::Agent.logger.warn('Not configured to accept distributed trace headers')
18
18
  return
19
19
  end
20
20
 
@@ -5,7 +5,8 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  class SyntheticsMonitor < InboundRequestMonitor
8
- SYNTHETICS_HEADER_KEY = 'HTTP_X_NEWRELIC_SYNTHETICS'.freeze
8
+ SYNTHETICS_HEADER_KEY = 'HTTP_X_NEWRELIC_SYNTHETICS'
9
+ SYNTHETICS_INFO_HEADER_KEY = 'HTTP_X_NEWRELIC_SYNTHETICS_INFO'
9
10
 
10
11
  SUPPORTED_VERSION = 1
11
12
  EXPECTED_PAYLOAD_LENGTH = 5
@@ -16,6 +17,7 @@ module NewRelic
16
17
 
17
18
  def on_before_call(request) # THREAD_LOCAL_ACCESS
18
19
  encoded_header = request[SYNTHETICS_HEADER_KEY]
20
+ info_header = request[SYNTHETICS_INFO_HEADER_KEY]
19
21
  return unless encoded_header
20
22
 
21
23
  incoming_payload = deserialize_header(encoded_header, SYNTHETICS_HEADER_KEY)
@@ -27,7 +29,16 @@ module NewRelic
27
29
 
28
30
  txn = Tracer.current_transaction
29
31
  txn.raw_synthetics_header = encoded_header
32
+ txn.raw_synthetics_info_header = info_header
30
33
  txn.synthetics_payload = incoming_payload
34
+ txn.synthetics_info_payload = load_json(info_header, SYNTHETICS_INFO_HEADER_KEY)
35
+ end
36
+
37
+ def load_json(header, key)
38
+ ::JSON.load(header)
39
+ rescue => err
40
+ NewRelic::Agent.logger.debug("Failure loading json header '#{key}' in #{self.class}, #{err.class}, #{err.message}")
41
+ nil
31
42
  end
32
43
 
33
44
  class << self
@@ -25,7 +25,7 @@ module NewRelic
25
25
  end
26
26
 
27
27
  module Gzip
28
- BINARY = "BINARY".freeze
28
+ BINARY = 'BINARY'.freeze
29
29
 
30
30
  def self.encode(data, opts = nil)
31
31
  output = StringIO.new
@@ -14,7 +14,7 @@ module NewRelic
14
14
  warn_for_yajl
15
15
  end
16
16
 
17
- OK_YAJL_VERSION = Gem::Version.new("1.2.1")
17
+ OK_YAJL_VERSION = Gem::Version.new('1.2.1')
18
18
 
19
19
  def warn_for_yajl
20
20
  if defined?(::Yajl)
@@ -24,7 +24,7 @@ module NewRelic
24
24
  end
25
25
  end
26
26
  rescue => err
27
- ::NewRelic::Agent.logger.warn("Failed trying to watch for problematic yajl-ruby version.", err)
27
+ ::NewRelic::Agent.logger.warn('Failed trying to watch for problematic yajl-ruby version.', err)
28
28
  end
29
29
 
30
30
  def dump(ruby, opts = {})
@@ -14,7 +14,6 @@ module NewRelic
14
14
  custom_parameters
15
15
  custom_instrumentation_editor
16
16
  message_parameters
17
- job_arguments
18
17
  ].map(&:freeze)
19
18
 
20
19
  def self.preliminary_settings(security_policies)