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
@@ -10,8 +10,7 @@ module NewRelic
10
10
 
11
11
  def initialize(channel_id)
12
12
  @channel_id = channel_id
13
- @collector = NewRelic::Control::Server.new(:name => 'parent',
14
- :port => 0)
13
+ @collector = NewRelic::Control::Server.new({name: 'parent', port: 0})
15
14
  @pipe = NewRelic::Agent::PipeChannelManager.channels[@channel_id]
16
15
  if @pipe && @pipe.parent_pid != $$
17
16
  @pipe.after_fork_in_child
@@ -61,7 +60,11 @@ module NewRelic
61
60
  write_to_pipe(:sql_trace_data, sql) if sql
62
61
  end
63
62
 
64
- def shutdown(time)
63
+ def log_event_data(logs)
64
+ write_to_pipe(:log_event_data, logs) if logs
65
+ end
66
+
67
+ def shutdown
65
68
  @pipe.close if @pipe
66
69
  end
67
70
 
@@ -15,12 +15,12 @@ module NewRelic
15
15
  def initialize(capacity)
16
16
  super
17
17
  @captured_lifetime = 0
18
- @seen_lifetime = 0
18
+ @seen_lifetime = 0
19
19
  end
20
20
 
21
21
  def heapify_items_array
22
22
  if @items.is_a?(Array)
23
- @items = Heap.new(@items) { |x| priority_for(x) }
23
+ @items = Heap.new(@items) { |x| priority_for(x) }
24
24
  end
25
25
  end
26
26
 
@@ -38,8 +38,6 @@ module NewRelic
38
38
  @items[0] = incoming
39
39
  @items.fix(0)
40
40
  incoming
41
- else
42
- nil
43
41
  end
44
42
  else
45
43
  @items << (event || blk.call)
@@ -53,10 +51,10 @@ module NewRelic
53
51
  def capacity=(new_capacity)
54
52
  @capacity = new_capacity
55
53
  old_items = @items.to_a
56
- old_seen = @seen
54
+ old_seen = @seen
57
55
  reset!
58
56
  old_items.each { |i| append(event: i) }
59
- @seen = old_seen
57
+ @seen = old_seen
60
58
  end
61
59
 
62
60
  def to_a
@@ -92,4 +90,3 @@ module NewRelic
92
90
  end
93
91
  end
94
92
  end
95
-
@@ -7,7 +7,7 @@ module NewRelic
7
7
  class RulesEngine
8
8
  class ReplacementRule
9
9
  attr_reader(:terminate_chain, :each_segment, :ignore, :replace_all, :eval_order,
10
- :match_expression, :replacement)
10
+ :match_expression, :replacement)
11
11
 
12
12
  def initialize(options)
13
13
  if !options['match_expression']
@@ -18,12 +18,12 @@ module NewRelic
18
18
  end
19
19
 
20
20
  @match_expression = Regexp.new(options['match_expression'], Regexp::IGNORECASE)
21
- @replacement = options['replacement']
22
- @ignore = options['ignore'] || false
23
- @eval_order = options['eval_order'] || 0
24
- @replace_all = options['replace_all'] || false
25
- @each_segment = options['each_segment'] || false
26
- @terminate_chain = options['terminate_chain'] || false
21
+ @replacement = options['replacement']
22
+ @ignore = options['ignore'] || false
23
+ @eval_order = options['eval_order'] || 0
24
+ @replace_all = options['replace_all'] || false
25
+ @each_segment = options['each_segment'] || false
26
+ @terminate_chain = options['terminate_chain'] || false
27
27
  end
28
28
 
29
29
  def terminal?
@@ -56,9 +56,9 @@ module NewRelic
56
56
  end
57
57
 
58
58
  def apply_to_each_segment(string)
59
- string = string.dup
59
+ string = string.dup
60
60
  leading_slash = string.slice!(LEADING_SLASH_REGEX)
61
- segments = string.split(SEGMENT_SEPARATOR)
61
+ segments = string.split(SEGMENT_SEPARATOR)
62
62
 
63
63
  segments.map! do |segment|
64
64
  apply_replacement(segment)
@@ -6,19 +6,19 @@ module NewRelic
6
6
  module Agent
7
7
  class RulesEngine
8
8
  class SegmentTermsRule
9
- PREFIX_KEY = 'prefix'.freeze
10
- TERMS_KEY = 'terms'.freeze
11
- SEGMENT_PLACEHOLDER = '*'.freeze
12
- ADJACENT_PLACEHOLDERS_REGEX = %r{((?:^|/)\*)(?:/\*)*}.freeze
9
+ PREFIX_KEY = 'prefix'.freeze
10
+ TERMS_KEY = 'terms'.freeze
11
+ SEGMENT_PLACEHOLDER = '*'.freeze
12
+ ADJACENT_PLACEHOLDERS_REGEX = %r{((?:^|/)\*)(?:/\*)*}.freeze
13
13
  ADJACENT_PLACEHOLDERS_REPLACEMENT = '\1'.freeze
14
- VALID_PREFIX_SEGMENT_COUNT = 2
14
+ VALID_PREFIX_SEGMENT_COUNT = 2
15
15
 
16
16
  attr_reader :prefix, :terms
17
17
 
18
18
  def self.valid?(rule_spec)
19
19
  rule_spec[PREFIX_KEY].kind_of?(String) &&
20
- rule_spec[TERMS_KEY].kind_of?(Array) &&
21
- valid_prefix_segment_count?(rule_spec[PREFIX_KEY])
20
+ rule_spec[TERMS_KEY].kind_of?(Array) &&
21
+ valid_prefix_segment_count?(rule_spec[PREFIX_KEY])
22
22
  end
23
23
 
24
24
  def self.valid_prefix_segment_count?(prefix)
@@ -26,13 +26,13 @@ module NewRelic
26
26
  rindex = prefix.rindex(SEGMENT_SEPARATOR)
27
27
 
28
28
  (count == 2 && prefix[rindex + 1].nil?) ||
29
- (count == 1 && !prefix[rindex + 1].nil?)
29
+ (count == 1 && !prefix[rindex + 1].nil?)
30
30
  end
31
31
 
32
32
  def initialize(options)
33
- @prefix = options[PREFIX_KEY]
34
- @terms = options[TERMS_KEY]
35
- @trim_range = (@prefix.size..-1)
33
+ @prefix = options[PREFIX_KEY]
34
+ @terms = options[TERMS_KEY]
35
+ @trim_range = (@prefix.size..-1)
36
36
  end
37
37
 
38
38
  def terminal?
@@ -50,7 +50,7 @@ module NewRelic
50
50
  end
51
51
 
52
52
  def apply(string)
53
- rest = string[@trim_range]
53
+ rest = string[@trim_range]
54
54
  leading_slash = rest.slice!(LEADING_SLASH_REGEX)
55
55
  segments = rest.split(SEGMENT_SEPARATOR, -1)
56
56
  segments.map! { |s| @terms.include?(s) ? s : SEGMENT_PLACEHOLDER }
@@ -24,7 +24,7 @@ module NewRelic
24
24
  end
25
25
 
26
26
  def self.create_transaction_rules(connect_response)
27
- txn_name_specs = connect_response['transaction_name_rules'] || []
27
+ txn_name_specs = connect_response['transaction_name_rules'] || []
28
28
  segment_rule_specs = connect_response['transaction_segment_terms'] || []
29
29
 
30
30
  txn_name_rules = txn_name_specs.map { |s| ReplacementRule.new(s) }
@@ -54,7 +54,7 @@ module NewRelic
54
54
  rules.uniq! { |rule| rule.prefix }
55
55
  end
56
56
 
57
- def initialize(rules=[], segment_term_rules=[])
57
+ def initialize(rules = [], segment_term_rules = [])
58
58
  @rules = rules.sort
59
59
  @segment_term_rules = segment_term_rules
60
60
  end
@@ -12,9 +12,8 @@
12
12
  module NewRelic
13
13
  module Agent
14
14
  class Sampler
15
-
16
15
  # Exception denotes a sampler is not available and it will not be registered.
17
- class Unsupported < StandardError; end
16
+ class Unsupported < StandardError; end
18
17
 
19
18
  attr_reader :id
20
19
  @sampler_classes = []
@@ -52,7 +51,7 @@ module NewRelic
52
51
  # The ID passed in here is unused by our code, but is preserved in case
53
52
  # we have clients who are defining their own subclasses of this class, and
54
53
  # expecting to be able to call super with an ID.
55
- def initialize(id=nil)
54
+ def initialize(id = nil)
56
55
  @id = id || self.class.shorthand_name
57
56
  end
58
57
 
@@ -17,7 +17,7 @@ module NewRelic
17
17
  @samplers.each(&blk)
18
18
  end
19
19
 
20
- def clear()
20
+ def clear
21
21
  @samplers.clear
22
22
  end
23
23
 
@@ -34,7 +34,6 @@ module NewRelic
34
34
  end
35
35
  end
36
36
 
37
-
38
37
  def poll_samplers
39
38
  @samplers.delete_if do |sampler|
40
39
  begin
@@ -49,7 +48,7 @@ module NewRelic
49
48
 
50
49
  def add_sampler(sampler_class)
51
50
  supported = sampler_class.supported_on_this_platform?
52
- enabled = sampler_class.enabled?
51
+ enabled = sampler_class.enabled?
53
52
  if supported && enabled
54
53
  if !sampler_class_registered?(sampler_class)
55
54
  sampler = sampler_class.new
@@ -48,7 +48,7 @@ module NewRelic
48
48
  end
49
49
 
50
50
  def poll
51
- now = Time.now
51
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
52
52
  t = Process.times
53
53
 
54
54
  if @last_time && t.utime != 0.0 && t.stime != 0.0
@@ -62,9 +62,12 @@ module NewRelic
62
62
  end
63
63
 
64
64
  def poll
65
- record_failed_jobs(failed_jobs)
66
- record_locked_jobs(locked_jobs)
67
- record_queue_length_metrics
65
+ # Wrapping these queries within the same connection avoids deadlocks
66
+ ActiveRecord::Base.connection_pool.with_connection do
67
+ record_failed_jobs(failed_jobs)
68
+ record_locked_jobs(locked_jobs)
69
+ record_queue_length_metrics
70
+ end
68
71
  end
69
72
 
70
73
  private
@@ -97,11 +100,11 @@ module NewRelic
97
100
  # here that's valid on 2.x through 4.1, so split it up.
98
101
  result = if ::ActiveRecord::VERSION::MAJOR.to_i < 4
99
102
  ::Delayed::Job.count(:group => column_name,
100
- :conditions => [QUEUE_QUERY_CONDITION, now])
103
+ :conditions => [QUEUE_QUERY_CONDITION, now])
101
104
  else
102
- ::Delayed::Job.where(QUEUE_QUERY_CONDITION, now).
103
- group(column_name).
104
- count
105
+ ::Delayed::Job.where(QUEUE_QUERY_CONDITION, now)
106
+ .group(column_name)
107
+ .count
105
108
  end
106
109
  result.to_a
107
110
  end
@@ -3,11 +3,11 @@
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
5
  require 'new_relic/agent/sampler'
6
+ require 'new_relic/helper'
6
7
 
7
8
  module NewRelic
8
9
  module Agent
9
10
  module Samplers
10
-
11
11
  class MemorySampler < NewRelic::Agent::Sampler
12
12
  named :memory
13
13
 
@@ -47,11 +47,16 @@ module NewRelic
47
47
 
48
48
  def self.platform
49
49
  if RUBY_PLATFORM =~ /java/
50
- %x[uname -s].downcase
50
+ begin
51
+ NewRelic::Helper.run_command('uname -s').downcase
52
+ rescue NewRelic::CommandRunFailedError, NewRelic::CommandExecutableNotFoundError
53
+ 'unknown'
54
+ end
51
55
  else
52
56
  RUBY_PLATFORM.downcase
53
57
  end
54
58
  end
59
+
55
60
  def platform
56
61
  NewRelic::Agent::Samplers::MemorySampler.platform
57
62
  end
@@ -118,6 +123,7 @@ module NewRelic
118
123
  raise "Faulty command: `#{@command} #{process}`" if memory.nil? || memory <= 0
119
124
  memory
120
125
  end
126
+
121
127
  def to_s
122
128
  "shell command sampler: #{@command}"
123
129
  end
@@ -130,7 +136,7 @@ module NewRelic
130
136
  class ProcStatus < Base
131
137
  # Returns the amount of resident memory this process is using in MB
132
138
  def get_memory
133
- proc_status = File.open(proc_status_file, "r") {|f| f.read_nonblock(4096).strip }
139
+ proc_status = File.open(proc_status_file, "r") { |f| f.read_nonblock(4096).strip }
134
140
  if proc_status =~ /RSS:\s*(\d+) kB/i
135
141
  return $1.to_f / 1024.0
136
142
  end
@@ -9,14 +9,14 @@ module NewRelic
9
9
  module Agent
10
10
  module Samplers
11
11
  class VMSampler < Sampler
12
- GC_RUNS_METRIC = 'RubyVM/GC/runs'.freeze
13
- HEAP_LIVE_METRIC = 'RubyVM/GC/heap_live'.freeze
14
- HEAP_FREE_METRIC = 'RubyVM/GC/heap_free'.freeze
15
- THREAD_COUNT_METRIC = 'RubyVM/Threads/all'.freeze
16
- OBJECT_ALLOCATIONS_METRIC = 'RubyVM/GC/total_allocated_object'.freeze
17
- MAJOR_GC_METRIC = 'RubyVM/GC/major_gc_count'.freeze
18
- MINOR_GC_METRIC = 'RubyVM/GC/minor_gc_count'.freeze
19
- METHOD_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/method'.freeze
12
+ GC_RUNS_METRIC = 'RubyVM/GC/runs'.freeze
13
+ HEAP_LIVE_METRIC = 'RubyVM/GC/heap_live'.freeze
14
+ HEAP_FREE_METRIC = 'RubyVM/GC/heap_free'.freeze
15
+ THREAD_COUNT_METRIC = 'RubyVM/Threads/all'.freeze
16
+ OBJECT_ALLOCATIONS_METRIC = 'RubyVM/GC/total_allocated_object'.freeze
17
+ MAJOR_GC_METRIC = 'RubyVM/GC/major_gc_count'.freeze
18
+ MINOR_GC_METRIC = 'RubyVM/GC/minor_gc_count'.freeze
19
+ METHOD_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/method'.freeze
20
20
  CONSTANT_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/constant'.freeze
21
21
 
22
22
  attr_reader :transaction_count
@@ -49,7 +49,7 @@ module NewRelic
49
49
  end
50
50
  end
51
51
 
52
- def record_gc_runs_metric(snapshot, txn_count) #THREAD_LOCAL_ACCESS
52
+ def record_gc_runs_metric(snapshot, txn_count) # THREAD_LOCAL_ACCESS
53
53
  if snapshot.gc_total_time || snapshot.gc_runs
54
54
  if snapshot.gc_total_time
55
55
  gc_time = snapshot.gc_total_time - @last_snapshot.gc_total_time.to_f
@@ -59,30 +59,30 @@ module NewRelic
59
59
  end
60
60
  wall_clock_time = snapshot.taken_at - @last_snapshot.taken_at
61
61
  NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(GC_RUNS_METRIC) do |stats|
62
- stats.call_count += txn_count
63
- stats.total_call_time += gc_runs if gc_runs
62
+ stats.call_count += txn_count
63
+ stats.total_call_time += gc_runs if gc_runs
64
64
  stats.total_exclusive_time += gc_time if gc_time
65
- stats.max_call_time = (gc_time.nil? ? 0 : 1)
66
- stats.sum_of_squares += wall_clock_time
65
+ stats.max_call_time = (gc_time.nil? ? 0 : 1)
66
+ stats.sum_of_squares += wall_clock_time
67
67
  end
68
68
  end
69
69
  end
70
70
 
71
- def record_delta(snapshot, key, metric, txn_count) #THREAD_LOCAL_ACCESS
71
+ def record_delta(snapshot, key, metric, txn_count) # THREAD_LOCAL_ACCESS
72
72
  value = snapshot.send(key)
73
73
  if value
74
74
  delta = value - @last_snapshot.send(key)
75
75
  NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(metric) do |stats|
76
- stats.call_count += txn_count
76
+ stats.call_count += txn_count
77
77
  stats.total_call_time += delta
78
78
  end
79
79
  end
80
80
  end
81
81
 
82
- def record_gauge_metric(metric_name, value) #THREAD_LOCAL_ACCESS
82
+ def record_gauge_metric(metric_name, value) # THREAD_LOCAL_ACCESS
83
83
  NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(metric_name) do |stats|
84
- stats.call_count = value
85
- stats.sum_of_squares = 1
84
+ stats.call_count = value
85
+ stats.sum_of_squares = 1
86
86
  end
87
87
  end
88
88
 
@@ -2,8 +2,8 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
4
 
5
- require 'newrelic_rpm' unless defined?( NewRelic )
6
- require 'new_relic/agent' unless defined?( NewRelic::Agent )
5
+ require 'newrelic_rpm' unless defined?(NewRelic)
6
+ require 'new_relic/agent' unless defined?(NewRelic::Agent)
7
7
  require 'new_relic/agent/event_aggregator'
8
8
  require 'new_relic/agent/priority_sampled_buffer'
9
9
 
@@ -14,10 +14,10 @@ module NewRelic
14
14
  capacity_key :'span_events.max_samples_stored'
15
15
 
16
16
  enabled_keys :'span_events.enabled',
17
- :'distributed_tracing.enabled'
17
+ :'distributed_tracing.enabled'
18
18
 
19
- def record priority: nil, event:nil, &blk
20
- unless(event || priority && blk)
19
+ def record(priority: nil, event: nil, &blk)
20
+ unless event || priority && blk
21
21
  raise ArgumentError, "Expected priority and block, or event"
22
22
  end
23
23
 
@@ -31,16 +31,16 @@ module NewRelic
31
31
 
32
32
  SUPPORTABILITY_TOTAL_SEEN = "Supportability/SpanEvent/TotalEventsSeen".freeze
33
33
  SUPPORTABILITY_TOTAL_SENT = "Supportability/SpanEvent/TotalEventsSent".freeze
34
- SUPPORTABILITY_DISCARDED = "Supportability/SpanEvent/Discarded".freeze
34
+ SUPPORTABILITY_DISCARDED = "Supportability/SpanEvent/Discarded".freeze
35
35
 
36
- def after_harvest metadata
37
- seen = metadata[:seen]
38
- sent = metadata[:captured]
36
+ def after_harvest(metadata)
37
+ seen = metadata[:seen]
38
+ sent = metadata[:captured]
39
39
  discarded = seen - sent
40
40
 
41
41
  ::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SEEN, count: seen)
42
42
  ::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SENT, count: sent)
43
- ::NewRelic::Agent.record_metric(SUPPORTABILITY_DISCARDED, count: discarded)
43
+ ::NewRelic::Agent.record_metric(SUPPORTABILITY_DISCARDED, count: discarded)
44
44
 
45
45
  super
46
46
  end
@@ -16,39 +16,39 @@ module NewRelic
16
16
  extend self
17
17
 
18
18
  # Strings for static keys of the event structure
19
- ELLIPSIS = '...'
20
- TYPE_KEY = 'type'
21
- TRACE_ID_KEY = 'traceId'
22
- GUID_KEY = 'guid'
23
- PARENT_ID_KEY = 'parentId'
24
- GRANDPARENT_ID_KEY = 'grandparentId'
25
- TRANSACTION_ID_KEY = 'transactionId'
26
- SAMPLED_KEY = 'sampled'
27
- PRIORITY_KEY = 'priority'
28
- TIMESTAMP_KEY = 'timestamp'
29
- DURATION_KEY = 'duration'
30
- NAME_KEY = 'name'
31
- CATEGORY_KEY = 'category'
32
- HTTP_URL_KEY = 'http.url'
33
- HTTP_METHOD_KEY = 'http.method'
19
+ ELLIPSIS = '...'
20
+ TYPE_KEY = 'type'
21
+ TRACE_ID_KEY = 'traceId'
22
+ GUID_KEY = 'guid'
23
+ PARENT_ID_KEY = 'parentId'
24
+ GRANDPARENT_ID_KEY = 'grandparentId'
25
+ TRANSACTION_ID_KEY = 'transactionId'
26
+ SAMPLED_KEY = 'sampled'
27
+ PRIORITY_KEY = 'priority'
28
+ TIMESTAMP_KEY = 'timestamp'
29
+ DURATION_KEY = 'duration'
30
+ NAME_KEY = 'name'
31
+ CATEGORY_KEY = 'category'
32
+ HTTP_URL_KEY = 'http.url'
33
+ HTTP_METHOD_KEY = 'http.method'
34
34
  HTTP_STATUS_CODE_KEY = 'http.statusCode'
35
- COMPONENT_KEY = 'component'
36
- DB_INSTANCE_KEY = 'db.instance'
37
- DB_STATEMENT_KEY = 'db.statement'
38
- PEER_ADDRESS_KEY = 'peer.address'
39
- PEER_HOSTNAME_KEY = 'peer.hostname'
40
- SPAN_KIND_KEY = 'span.kind'
41
- ENTRY_POINT_KEY = 'nr.entryPoint'
42
- TRUSTED_PARENT_KEY = "trustedParentId"
43
- TRACING_VENDORS_KEY = "tracingVendors"
35
+ COMPONENT_KEY = 'component'
36
+ DB_INSTANCE_KEY = 'db.instance'
37
+ DB_STATEMENT_KEY = 'db.statement'
38
+ PEER_ADDRESS_KEY = 'peer.address'
39
+ PEER_HOSTNAME_KEY = 'peer.hostname'
40
+ SPAN_KIND_KEY = 'span.kind'
41
+ ENTRY_POINT_KEY = 'nr.entryPoint'
42
+ TRUSTED_PARENT_KEY = "trustedParentId"
43
+ TRACING_VENDORS_KEY = "tracingVendors"
44
44
  TRANSACTION_NAME_KEY = 'transaction.name'
45
45
 
46
46
  # Strings for static values of the event structure
47
- EVENT_TYPE = 'Span'
48
- GENERIC_CATEGORY = 'generic'
49
- HTTP_CATEGORY = 'http'
47
+ EVENT_TYPE = 'Span'
48
+ GENERIC_CATEGORY = 'generic'
49
+ HTTP_CATEGORY = 'http'
50
50
  DATASTORE_CATEGORY = 'datastore'
51
- CLIENT = 'client'
51
+ CLIENT = 'client'
52
52
 
53
53
  # Builds a Hash of error attributes as well as the Span ID when
54
54
  # an error is present. Otherwise, returns nil when no error present.
@@ -68,11 +68,11 @@ module NewRelic
68
68
  def for_external_request_segment segment
69
69
  intrinsics = intrinsics_for(segment)
70
70
 
71
- intrinsics[COMPONENT_KEY] = segment.library
71
+ intrinsics[COMPONENT_KEY] = segment.library
72
72
  intrinsics[HTTP_METHOD_KEY] = segment.procedure
73
73
  intrinsics[HTTP_STATUS_CODE_KEY] = segment.http_status_code if segment.http_status_code
74
- intrinsics[CATEGORY_KEY] = HTTP_CATEGORY
75
- intrinsics[SPAN_KIND_KEY] = CLIENT
74
+ intrinsics[CATEGORY_KEY] = HTTP_CATEGORY
75
+ intrinsics[SPAN_KIND_KEY] = CLIENT
76
76
 
77
77
  agent_attributes = error_attributes(segment) || {}
78
78
 
@@ -115,14 +115,14 @@ module NewRelic
115
115
 
116
116
  def intrinsics_for segment
117
117
  intrinsics = {
118
- TYPE_KEY => EVENT_TYPE,
119
- TRACE_ID_KEY => segment.transaction.trace_id,
120
- GUID_KEY => segment.guid,
118
+ TYPE_KEY => EVENT_TYPE,
119
+ TRACE_ID_KEY => segment.transaction.trace_id,
120
+ GUID_KEY => segment.guid,
121
121
  TRANSACTION_ID_KEY => segment.transaction.guid,
122
- PRIORITY_KEY => segment.transaction.priority,
123
- TIMESTAMP_KEY => milliseconds_since_epoch(segment),
124
- DURATION_KEY => segment.duration,
125
- NAME_KEY => segment.name
122
+ PRIORITY_KEY => segment.transaction.priority,
123
+ TIMESTAMP_KEY => milliseconds_since_epoch(segment),
124
+ DURATION_KEY => segment.duration,
125
+ NAME_KEY => segment.name
126
126
  }
127
127
 
128
128
  # with infinite-tracing, transactions may or may not be sampled!
@@ -165,18 +165,21 @@ module NewRelic
165
165
  end
166
166
  end
167
167
 
168
- def merge_and_freeze_attributes agent_attributes, error_attributes
169
- return agent_attributes.freeze unless error_attributes
170
- return error_attributes.freeze if agent_attributes.equal?(NewRelic::EMPTY_HASH)
171
- agent_attributes.merge!(error_attributes).freeze
168
+ def merge_hashes(hash1, hash2)
169
+ return hash1 if hash2.nil? || hash2.empty?
170
+ return hash2 if hash1.nil? || hash1.empty?
171
+
172
+ hash1.merge!(hash2)
172
173
  end
173
174
 
174
175
  def agent_attributes segment
175
176
  agent_attributes = segment.attributes
176
177
  .agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_SPAN_EVENTS)
177
178
  error_attributes = error_attributes(segment)
178
- return NewRelic::EMPTY_HASH unless agent_attributes || error_attributes
179
- merge_and_freeze_attributes(agent_attributes, error_attributes)
179
+ code_attributes = segment.code_attributes
180
+ agent_attributes = merge_hashes(agent_attributes, error_attributes)
181
+ agent_attributes = merge_hashes(agent_attributes, code_attributes)
182
+ agent_attributes.freeze
180
183
  end
181
184
 
182
185
  def parent_guid segment
@@ -191,7 +194,7 @@ module NewRelic
191
194
  Integer(segment.start_time.to_f * 1000.0)
192
195
  end
193
196
 
194
- def truncate value, max_size=255
197
+ def truncate value, max_size = 255
195
198
  value = value.to_s
196
199
  if value.bytesize > max_size
197
200
  value.byteslice(0, max_size - 2).chop! << ELLIPSIS
@@ -46,7 +46,7 @@ module NewRelic
46
46
  NewRelic::Agent::Database.should_record_sql?(:slow_sql)
47
47
  end
48
48
 
49
- def on_start_transaction(state, start_time, uri=nil)
49
+ def on_start_transaction(state, uri = nil)
50
50
  return unless enabled?
51
51
 
52
52
  state.sql_sampler_transaction_data = TransactionSqlData.new
@@ -83,7 +83,7 @@ module NewRelic
83
83
  # this should always be called under the @samples_lock
84
84
  def save_slow_sql(transaction_sql_data)
85
85
  path = transaction_sql_data.path
86
- uri = transaction_sql_data.uri
86
+ uri = transaction_sql_data.uri
87
87
 
88
88
  transaction_sql_data.sql_data.each do |sql_item|
89
89
  normalized_sql = sql_item.normalize
@@ -140,7 +140,7 @@ module NewRelic
140
140
  # @api public
141
141
  # @deprecated Use {Datastores.notice_sql} instead.
142
142
  #
143
- def notice_sql(sql, metric_name, config, duration, state=nil, explainer=nil, binds=nil, name=nil) #THREAD_LOCAL_ACCESS sometimes
143
+ def notice_sql(sql, metric_name, config, duration, state = nil, explainer = nil, binds = nil, name = nil) # THREAD_LOCAL_ACCESS sometimes
144
144
  state ||= Tracer.state
145
145
  data = state.sql_sampler_transaction_data
146
146
  return unless data
@@ -203,7 +203,7 @@ module NewRelic
203
203
  slowest = @sql_traces.values
204
204
  @sql_traces = {}
205
205
  end
206
- slowest.each {|trace| trace.prepare_to_send }
206
+ slowest.each { |trace| trace.prepare_to_send }
207
207
  slowest
208
208
  end
209
209
 
@@ -240,7 +240,7 @@ module NewRelic
240
240
  attr_reader :duration
241
241
  attr_reader :backtrace
242
242
 
243
- def initialize(statement, metric_name, duration, backtrace=nil, params=nil)
243
+ def initialize(statement, metric_name, duration, backtrace = nil, params = nil)
244
244
  @statement = statement
245
245
  @metric_name = metric_name
246
246
  @duration = duration
@@ -342,7 +342,7 @@ module NewRelic
342
342
  include NewRelic::Coerce
343
343
 
344
344
  def to_collector_array(encoder)
345
- [ string(@path),
345
+ [string(@path),
346
346
  string(@url),
347
347
  int(@sql_id),
348
348
  string(@sql),
@@ -351,7 +351,7 @@ module NewRelic
351
351
  Helper.time_to_millis(@total_call_time),
352
352
  Helper.time_to_millis(@min_call_time),
353
353
  Helper.time_to_millis(@max_call_time),
354
- encoder.encode(@params) ]
354
+ encoder.encode(@params)]
355
355
  end
356
356
 
357
357
  private
@@ -359,10 +359,10 @@ module NewRelic
359
359
  # need to hash the same way in every process, to be able to aggregate slow SQL traces
360
360
  def consistent_hash(string)
361
361
  if NewRelic::Agent.config[:'slow_sql.use_longer_sql_id']
362
- Digest::MD5.hexdigest(string).hex.modulo(2**63-1)
362
+ Digest::SHA1.hexdigest(string).hex.modulo(2**63 - 1)
363
363
  else
364
364
  # from when sql_id needed to fit in an INT(11)
365
- Digest::MD5.hexdigest(string).hex.modulo(2**31-1)
365
+ Digest::SHA1.hexdigest(string).hex.modulo(2**31 - 1)
366
366
  end
367
367
  end
368
368
  end