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
@@ -4,6 +4,8 @@
4
4
  module NewRelic
5
5
  module Agent
6
6
  class Stats
7
+ SKIP_MARSHALLING = [:@lock]
8
+
7
9
  attr_accessor :call_count
8
10
  attr_accessor :min_call_time
9
11
  attr_accessor :max_call_time
@@ -12,6 +14,7 @@ module NewRelic
12
14
  attr_accessor :sum_of_squares
13
15
 
14
16
  def initialize
17
+ @lock = Mutex.new
15
18
  reset
16
19
  end
17
20
 
@@ -34,12 +37,14 @@ module NewRelic
34
37
  end
35
38
 
36
39
  def merge!(other)
37
- @min_call_time = other.min_call_time if min_time_less?(other)
38
- @max_call_time = other.max_call_time if other.max_call_time > max_call_time
39
- @total_call_time += other.total_call_time
40
- @total_exclusive_time += other.total_exclusive_time
41
- @sum_of_squares += other.sum_of_squares
42
- @call_count += other.call_count
40
+ @lock.synchronize do
41
+ @min_call_time = other.min_call_time if min_time_less?(other)
42
+ @max_call_time = other.max_call_time if other.max_call_time > max_call_time
43
+ @total_call_time += other.total_call_time
44
+ @total_exclusive_time += other.total_exclusive_time
45
+ @sum_of_squares += other.sum_of_squares
46
+ @call_count += other.call_count
47
+ end
43
48
  self
44
49
  end
45
50
 
@@ -49,16 +54,16 @@ module NewRelic
49
54
 
50
55
  def to_json(*_)
51
56
  {
52
- 'call_count' => call_count.to_i,
53
- 'min_call_time' => min_call_time.to_f,
54
- 'max_call_time' => max_call_time.to_f,
55
- 'total_call_time' => total_call_time.to_f,
57
+ 'call_count' => call_count.to_i,
58
+ 'min_call_time' => min_call_time.to_f,
59
+ 'max_call_time' => max_call_time.to_f,
60
+ 'total_call_time' => total_call_time.to_f,
56
61
  'total_exclusive_time' => total_exclusive_time.to_f,
57
- 'sum_of_squares' => sum_of_squares.to_f
62
+ 'sum_of_squares' => sum_of_squares.to_f
58
63
  }.to_json(*_)
59
64
  end
60
65
 
61
- def record(value=nil, aux=nil, &blk)
66
+ def record(value = nil, aux = nil, &blk)
62
67
  if blk
63
68
  yield self
64
69
  else
@@ -78,13 +83,15 @@ module NewRelic
78
83
  # will aggregate all data points collected over a specified period and upload
79
84
  # its data to the NewRelic server
80
85
  def record_data_point(value, exclusive_time = value)
81
- @call_count += 1
82
- @total_call_time += value
83
- @min_call_time = value if value < @min_call_time || @call_count == 1
84
- @max_call_time = value if value > @max_call_time
85
- @total_exclusive_time += exclusive_time
86
-
87
- @sum_of_squares += (value * value)
86
+ @lock.synchronize do
87
+ @call_count += 1
88
+ @total_call_time += value
89
+ @min_call_time = value if value < @min_call_time || @call_count == 1
90
+ @max_call_time = value if value > @max_call_time
91
+ @total_exclusive_time += exclusive_time
92
+
93
+ @sum_of_squares += (value * value)
94
+ end
88
95
  self
89
96
  end
90
97
 
@@ -92,7 +99,7 @@ module NewRelic
92
99
 
93
100
  # increments the call_count by one
94
101
  def increment_count(value = 1)
95
- @call_count += value
102
+ @lock.synchronize { @call_count += value }
96
103
  end
97
104
 
98
105
  # Concerned about implicit usage of inspect relying on stats format, so
@@ -106,14 +113,14 @@ module NewRelic
106
113
 
107
114
  def ==(other)
108
115
  other.class == self.class &&
109
- (
110
- @min_call_time == other.min_call_time &&
111
- @max_call_time == other.max_call_time &&
112
- @total_call_time == other.total_call_time &&
113
- @total_exclusive_time == other.total_exclusive_time &&
114
- @sum_of_squares == other.sum_of_squares &&
115
- @call_count == other.call_count
116
- )
116
+ (
117
+ @min_call_time == other.min_call_time &&
118
+ @max_call_time == other.max_call_time &&
119
+ @total_call_time == other.total_call_time &&
120
+ @total_exclusive_time == other.total_exclusive_time &&
121
+ @sum_of_squares == other.sum_of_squares &&
122
+ @call_count == other.call_count
123
+ )
117
124
  end
118
125
 
119
126
  # Apdex-related accessors
@@ -122,17 +129,35 @@ module NewRelic
122
129
  alias_method :apdex_f, :total_exclusive_time
123
130
 
124
131
  def record_apdex(bucket, apdex_t)
125
- case bucket
126
- when :apdex_s then @call_count += 1
127
- when :apdex_t then @total_call_time += 1
128
- when :apdex_f then @total_exclusive_time += 1
132
+ @lock.synchronize do
133
+ case bucket
134
+ when :apdex_s then @call_count += 1
135
+ when :apdex_t then @total_call_time += 1
136
+ when :apdex_f then @total_exclusive_time += 1
137
+ end
138
+ if apdex_t
139
+ @min_call_time = apdex_t
140
+ @max_call_time = apdex_t
141
+ else
142
+ ::NewRelic::Agent.logger.warn("Attempted to set apdex_t to #{apdex_t.inspect}, backtrace = #{caller.join("\n")}")
143
+ end
129
144
  end
130
- if apdex_t
131
- @min_call_time = apdex_t
132
- @max_call_time = apdex_t
133
- else
134
- ::NewRelic::Agent.logger.warn("Attempted to set apdex_t to #{apdex_t.inspect}, backtrace = #{caller.join("\n")}")
145
+ end
146
+
147
+ # Override marshalling methods to exclude @lock from being included in marshalled data
148
+ def marshal_dump
149
+ instance_variables.each_with_object({}) do |name, instance_copy|
150
+ next if SKIP_MARSHALLING.include?(name)
151
+ instance_copy[name] = instance_variable_get(name)
152
+ end
153
+ end
154
+
155
+ def marshal_load(marshalled_data)
156
+ marshalled_data.each do |name, value|
157
+ instance_variable_set(name, value) unless SKIP_MARSHALLING.include?(name)
135
158
  end
159
+ # since the lock is excluded when marshalling, create a new lock when loading marshalled data
160
+ @lock = Mutex.new
136
161
  end
137
162
 
138
163
  protected
@@ -22,7 +22,7 @@ module NewRelic
22
22
  end
23
23
 
24
24
  def self.reset
25
- @profiler = nil
25
+ @profiler = nil
26
26
  @initialized = nil
27
27
  end
28
28
 
@@ -30,15 +30,13 @@ module NewRelic
30
30
  init
31
31
  if @profiler
32
32
  GCSnapshot.new(@profiler.call_time_s, @profiler.call_count)
33
- else
34
- nil
35
33
  end
36
34
  end
37
35
 
38
36
  def self.record_delta(start_snapshot, end_snapshot)
39
37
  if @profiler && start_snapshot && end_snapshot
40
38
  elapsed_gc_time_s = end_snapshot.gc_time_s - start_snapshot.gc_time_s
41
- num_calls = end_snapshot.gc_call_count - start_snapshot.gc_call_count
39
+ num_calls = end_snapshot.gc_call_count - start_snapshot.gc_call_count
42
40
  record_gc_metric(num_calls, elapsed_gc_time_s)
43
41
 
44
42
  @profiler.reset
@@ -46,17 +44,17 @@ module NewRelic
46
44
  end
47
45
  end
48
46
 
49
- def self.record_gc_metric(call_count, elapsed) #THREAD_LOCAL_ACCESS
47
+ def self.record_gc_metric(call_count, elapsed) # THREAD_LOCAL_ACCESS
50
48
  NewRelic::Agent.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(gc_metric_name, GC_ROLLUP) do |stats|
51
- stats.call_count += call_count
52
- stats.total_call_time += elapsed
49
+ stats.call_count += call_count
50
+ stats.total_call_time += elapsed
53
51
  stats.total_exclusive_time += elapsed
54
52
  end
55
53
  end
56
54
 
57
55
  GC_ROLLUP = 'GC/Transaction/all'.freeze
58
- GC_OTHER = 'GC/Transaction/allOther'.freeze
59
- GC_WEB = 'GC/Transaction/allWeb'.freeze
56
+ GC_OTHER = 'GC/Transaction/allOther'.freeze
57
+ GC_WEB = 'GC/Transaction/allWeb'.freeze
60
58
 
61
59
  def self.gc_metric_name
62
60
  if NewRelic::Agent::Transaction.recording_web_transaction?
@@ -30,13 +30,12 @@ require 'new_relic/agent/internal_agent_error'
30
30
  module NewRelic
31
31
  module Agent
32
32
  class StatsHash
33
-
34
33
  attr_accessor :started_at, :harvested_at
35
34
 
36
- def initialize(started_at=Time.now)
35
+ def initialize(started_at = Process.clock_gettime(Process::CLOCK_REALTIME))
37
36
  @started_at = started_at.to_f
38
- @scoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
39
- @unscoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
37
+ @scoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
38
+ @unscoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
40
39
  end
41
40
 
42
41
  def marshal_dump
@@ -45,7 +44,7 @@ module NewRelic
45
44
 
46
45
  def marshal_load(data)
47
46
  @started_at = data.shift
48
- @scoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
47
+ @scoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
49
48
  @unscoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
50
49
  @scoped.merge!(data.shift)
51
50
  @unscoped.merge!(data.shift)
@@ -57,7 +56,7 @@ module NewRelic
57
56
 
58
57
  def to_h
59
58
  hash = {}
60
- @scoped.each { |k, v| hash[k] = v }
59
+ @scoped.each { |k, v| hash[k] = v }
61
60
  @unscoped.each { |k, v| hash[NewRelic::MetricSpec.new(k)] = v }
62
61
  hash
63
62
  end
@@ -99,7 +98,7 @@ module NewRelic
99
98
  end
100
99
  end
101
100
 
102
- def record(metric_specs, value=nil, aux=nil, &blk)
101
+ def record(metric_specs, value = nil, aux = nil, &blk)
103
102
  Array(metric_specs).each do |metric_spec|
104
103
  if metric_spec.scope.empty?
105
104
  key = metric_spec.name
@@ -122,8 +121,8 @@ module NewRelic
122
121
  def handle_stats_lookup_error(key, hash, error)
123
122
  # This only happen in the case of a corrupted default_proc
124
123
  # Side-step it manually, notice the issue, and carry on....
125
- NewRelic::Agent.instance.error_collector. \
126
- notice_agent_error(StatsHashLookupError.new(error, hash, key))
124
+ NewRelic::Agent.instance.error_collector \
125
+ .notice_agent_error(StatsHashLookupError.new(error, hash, key))
127
126
  stats = NewRelic::Agent::Stats.new
128
127
  hash[key] = stats
129
128
  # Try to restore the default_proc so we won't continually trip the error
@@ -13,8 +13,8 @@ module NewRelic
13
13
  attr_accessor :metric_rules
14
14
 
15
15
  def initialize
16
- @stats_lock = Mutex.new
17
- @stats_hash = StatsHash.new
16
+ @stats_lock = Mutex.new
17
+ @stats_hash = StatsHash.new
18
18
  @metric_rules = RulesEngine.new
19
19
  end
20
20
 
@@ -60,12 +60,12 @@ module NewRelic
60
60
  #
61
61
  # @api private
62
62
  #
63
- def tl_record_unscoped_metrics(metric_names, value=nil, aux=nil, &blk)
63
+ def tl_record_unscoped_metrics(metric_names, value = nil, aux = nil, &blk)
64
64
  state = NewRelic::Agent::Tracer.state
65
65
  record_unscoped_metrics(state, metric_names, value, aux, &blk)
66
66
  end
67
67
 
68
- def record_unscoped_metrics(state, metric_names, value=nil, aux=nil, &blk)
68
+ def record_unscoped_metrics(state, metric_names, value = nil, aux = nil, &blk)
69
69
  txn = state.current_transaction
70
70
  if txn
71
71
  txn.metrics.record_unscoped(metric_names, value, aux, &blk)
@@ -96,12 +96,12 @@ module NewRelic
96
96
  #
97
97
  # @api private
98
98
  #
99
- def tl_record_scoped_and_unscoped_metrics(scoped_metric, summary_metrics=nil, value=nil, aux=nil, &blk)
99
+ def tl_record_scoped_and_unscoped_metrics(scoped_metric, summary_metrics = nil, value = nil, aux = nil, &blk)
100
100
  state = NewRelic::Agent::Tracer.state
101
101
  record_scoped_and_unscoped_metrics(state, scoped_metric, summary_metrics, value, aux, &blk)
102
102
  end
103
103
 
104
- def record_scoped_and_unscoped_metrics(state, scoped_metric, summary_metrics=nil, value=nil, aux=nil, &blk)
104
+ def record_scoped_and_unscoped_metrics(state, scoped_metric, summary_metrics = nil, value = nil, aux = nil, &blk)
105
105
  txn = state.current_transaction
106
106
  if txn
107
107
  txn.metrics.record_scoped_and_unscoped(scoped_metric, value, aux, &blk)
@@ -150,7 +150,7 @@ module NewRelic
150
150
  end
151
151
 
152
152
  def harvest!
153
- now = Time.now
153
+ now = Process.clock_gettime(Process::CLOCK_REALTIME)
154
154
  snapshot = reset!
155
155
  snapshot = apply_rules_to_metric_data(@metric_rules, snapshot)
156
156
  snapshot.harvested_at = now
@@ -13,7 +13,7 @@ module NewRelic
13
13
 
14
14
  named :SyntheticsEventAggregator
15
15
  capacity_key :'synthetics.events_limit'
16
- enabled_key :'analytics_events.enabled'
16
+ enabled_key :'transaction_events.enabled'
17
17
  buffer_class TimestampSampledBuffer
18
18
 
19
19
  def record event
@@ -42,4 +42,3 @@ module NewRelic
42
42
  end
43
43
  end
44
44
  end
45
-
@@ -43,8 +43,8 @@ module NewRelic
43
43
  if @processor_info.nil?
44
44
  if darwin?
45
45
  @processor_info = {
46
- :num_physical_packages => sysctl_value('hw.packages').to_i,
47
- :num_physical_cores => sysctl_value('hw.physicalcpu_max').to_i,
46
+ :num_physical_packages => sysctl_value('hw.packages').to_i,
47
+ :num_physical_cores => sysctl_value('hw.physicalcpu_max').to_i,
48
48
  :num_logical_processors => sysctl_value('hw.logicalcpu_max').to_i
49
49
  }
50
50
  # in case those don't work, try backup values
@@ -64,8 +64,8 @@ module NewRelic
64
64
 
65
65
  elsif bsd?
66
66
  @processor_info = {
67
- :num_physical_packages => nil,
68
- :num_physical_cores => nil,
67
+ :num_physical_packages => nil,
68
+ :num_physical_cores => nil,
69
69
  :num_logical_processors => sysctl_value('hw.ncpu').to_i
70
70
  }
71
71
  end
@@ -111,9 +111,9 @@ module NewRelic
111
111
  end
112
112
  cores[[phys_id, core_id]] += 1 if phys_id && core_id
113
113
 
114
- num_physical_packages = cores.keys.map(&:first).uniq.size
115
- num_physical_cores = cores.size
116
- num_logical_processors = cores.values.reduce(0,:+)
114
+ num_physical_packages = cores.keys.map(&:first).uniq.size
115
+ num_physical_cores = cores.size
116
+ num_logical_processors = cores.values.reduce(0, :+)
117
117
 
118
118
  if num_physical_cores == 0
119
119
  num_logical_processors = total_processors
@@ -127,24 +127,26 @@ module NewRelic
127
127
  # Some older, single-core processors might not list ids,
128
128
  # so we'll just mark them all 1.
129
129
  num_physical_packages = 1
130
- num_physical_cores = 1
130
+ num_physical_cores = 1
131
131
  else
132
132
  # We have no way of knowing how many packages or cores
133
133
  # we have, even though we know how many processors there are.
134
134
  num_physical_packages = nil
135
- num_physical_cores = nil
135
+ num_physical_cores = nil
136
136
  end
137
137
  end
138
138
 
139
139
  {
140
- :num_physical_packages => num_physical_packages,
141
- :num_physical_cores => num_physical_cores,
140
+ :num_physical_packages => num_physical_packages,
141
+ :num_physical_cores => num_physical_cores,
142
142
  :num_logical_processors => num_logical_processors
143
143
  }
144
144
  end
145
145
 
146
- def self.num_physical_packages ; get_processor_info[:num_physical_packages ] end
147
- def self.num_physical_cores ; get_processor_info[:num_physical_cores ] end
146
+ def self.num_physical_packages; get_processor_info[:num_physical_packages] end
147
+
148
+ def self.num_physical_cores; get_processor_info[:num_physical_cores] end
149
+
148
150
  def self.num_logical_processors; get_processor_info[:num_logical_processors] end
149
151
 
150
152
  def self.processor_arch
@@ -178,12 +180,12 @@ module NewRelic
178
180
  return
179
181
  end
180
182
  # docker native driver with systemd
181
- when '/' then nil
183
+ when '/' then nil
182
184
  # in a cgroup, but we don't recognize its format
183
- when /docker\/.*[^0-9a-f]/ then
185
+ when /docker\/.*[^0-9a-f]/
184
186
  ::NewRelic::Agent.logger.debug("Cgroup indicates docker but container_id has invalid characters: '#{cpu_cgroup}'")
185
187
  return
186
- when /docker/ then
188
+ when /docker/
187
189
  ::NewRelic::Agent.logger.debug("Cgroup indicates docker but container_id unrecognized: '#{cpu_cgroup}'")
188
190
  ::NewRelic::Agent.increment_metric "Supportability/utilization/docker/error"
189
191
  return
@@ -241,12 +243,12 @@ module NewRelic
241
243
 
242
244
  def self.ram_in_mib
243
245
  if darwin?
244
- (sysctl_value('hw.memsize').to_i / (1024 ** 2)).to_i
246
+ (sysctl_value('hw.memsize').to_i / (1024**2)).to_i
245
247
  elsif linux?
246
248
  meminfo = proc_try_read('/proc/meminfo')
247
249
  parse_linux_meminfo_in_mib(meminfo)
248
250
  elsif bsd?
249
- (sysctl_value('hw.realmem').to_i / (1024 ** 2)).to_i
251
+ (sysctl_value('hw.realmem').to_i / (1024**2)).to_i
250
252
  else
251
253
  ::NewRelic::Agent.logger.debug("Unable to determine ram_in_mib for host os: #{ruby_os_identifier}")
252
254
  nil
@@ -254,7 +256,7 @@ module NewRelic
254
256
  end
255
257
 
256
258
  def self.parse_linux_meminfo_in_mib(meminfo)
257
- if meminfo && mem_total = meminfo[/MemTotal:\s*(\d*)\skB/,1]
259
+ if meminfo && mem_total = meminfo[/MemTotal:\s*(\d*)\skB/, 1]
258
260
  (mem_total.to_i / 1024).to_i
259
261
  else
260
262
  ::NewRelic::Agent.logger.debug("Failed to parse MemTotal from /proc/meminfo: #{meminfo}")
@@ -279,7 +281,7 @@ module NewRelic
279
281
  else
280
282
  ::NewRelic::Agent.logger.debug("Found boot_id with invalid length: #{bid}")
281
283
  ::NewRelic::Agent.increment_metric "Supportability/utilization/boot_id/error"
282
- bid[0,128]
284
+ bid[0, 128]
283
285
 
284
286
  end
285
287
  else
@@ -6,7 +6,6 @@ module NewRelic
6
6
  module Agent
7
7
  module Threading
8
8
  class AgentThread
9
-
10
9
  def self.create(label, &blk)
11
10
  ::NewRelic::Agent.logger.debug("Creating New Relic thread: #{label}")
12
11
  wrapped_blk = Proc.new do
@@ -33,16 +32,16 @@ module NewRelic
33
32
  backing_thread_class.list
34
33
  end
35
34
 
36
- def self.bucket_thread(thread, profile_agent_code) #THREAD_LOCAL_ACCESS
35
+ def self.bucket_thread(thread, profile_agent_code) # THREAD_LOCAL_ACCESS
37
36
  if thread.key?(:newrelic_label)
38
37
  profile_agent_code ? :agent : :ignore
39
38
  else
40
39
  state = Tracer.state_for(thread)
41
- txn = state.current_transaction
40
+ txn = state.current_transaction
42
41
 
43
- if txn && !txn.recording_web_transaction?
42
+ if txn && !txn.recording_web_transaction?
44
43
  :background
45
- elsif txn && txn.recording_web_transaction?
44
+ elsif txn && txn.recording_web_transaction?
46
45
  :request
47
46
  else
48
47
  :other
@@ -13,7 +13,7 @@ module NewRelic
13
13
 
14
14
  def initialize
15
15
  @children = []
16
- @depth = 0
16
+ @depth = 0
17
17
  end
18
18
 
19
19
  def add_child_unless_present(child)
@@ -31,7 +31,6 @@ module NewRelic
31
31
  end
32
32
  end
33
33
 
34
-
35
34
  class BacktraceRoot < BacktraceBase
36
35
  attr_reader :flattened
37
36
 
@@ -78,9 +77,8 @@ module NewRelic
78
77
  end
79
78
  end
80
79
 
81
-
82
80
  class BacktraceNode < BacktraceBase
83
- attr_reader :file, :method, :line_no, :raw_line, :as_array
81
+ attr_reader :file, :method, :line_no, :raw_line, :as_array
84
82
  attr_accessor :runnable_count, :depth
85
83
 
86
84
  def initialize(line)
@@ -92,8 +90,8 @@ module NewRelic
92
90
 
93
91
  def ==(other)
94
92
  (
95
- @raw_line == other.raw_line &&
96
- @depth == other.depth &&
93
+ @raw_line == other.raw_line &&
94
+ @depth == other.depth &&
97
95
  @runnable_count == other.runnable_count
98
96
  )
99
97
  end
@@ -115,10 +113,10 @@ module NewRelic
115
113
  @as_array << child_arrays
116
114
  end
117
115
 
118
- def dump_string(indent=0)
116
+ def dump_string(indent = 0)
119
117
  @file, @method, @line_no = parse_backtrace_frame(@raw_line)
120
118
  result = "#{" " * indent}#<BacktraceNode:#{object_id} [#{@runnable_count}] #{@file}:#{@line_no} in #{@method}>"
121
- child_results = @children.map { |c| c.dump_string(indent+2) }.join("\n")
119
+ child_results = @children.map { |c| c.dump_string(indent + 2) }.join("\n")
122
120
  result << "\n" unless child_results.empty?
123
121
  result << child_results
124
122
  end
@@ -129,7 +127,6 @@ module NewRelic
129
127
  [$1, $4, $3] # sic
130
128
  end
131
129
  end
132
-
133
130
  end
134
131
  end
135
132
  end
@@ -20,10 +20,10 @@ module NewRelic
20
20
  end
21
21
 
22
22
  attr_reader :worker_loop, :buffer, :effective_polling_period,
23
- :overhead_percent_threshold
23
+ :overhead_percent_threshold
24
24
  attr_accessor :worker_thread, :profile_agent_code
25
25
 
26
- def initialize(event_listener=nil)
26
+ def initialize(event_listener = nil)
27
27
  @profiles = {}
28
28
  @buffer = {}
29
29
  @last_poll = nil
@@ -52,7 +52,7 @@ module NewRelic
52
52
  @running
53
53
  end
54
54
 
55
- def subscribe(transaction_name, command_arguments={})
55
+ def subscribe(transaction_name, command_arguments = {})
56
56
  if self.class.is_resque?
57
57
  NewRelic::Agent.logger.info("Backtracing threads on Resque is not supported, so not subscribing transaction '#{transaction_name}'")
58
58
  return
@@ -105,7 +105,7 @@ module NewRelic
105
105
  @lock.synchronize do
106
106
  if @profiles[transaction_name]
107
107
  profile = @profiles.delete(transaction_name)
108
- profile.finished_at = Time.now
108
+ profile.finished_at = Process.clock_gettime(Process::CLOCK_REALTIME)
109
109
  @profiles[transaction_name] = ThreadProfile.new(profile.command_arguments)
110
110
  profile
111
111
  end
@@ -113,11 +113,11 @@ module NewRelic
113
113
  end
114
114
 
115
115
  def on_transaction_finished(payload)
116
- name = payload[:name]
117
- start = payload[:start_timestamp]
116
+ name = payload[:name]
117
+ start = payload[:start_timestamp]
118
118
  duration = payload[:duration]
119
- thread = payload[:thread] || Thread.current
120
- bucket = payload[:bucket]
119
+ thread = payload[:thread] || Thread.current
120
+ bucket = payload[:bucket]
121
121
  @lock.synchronize do
122
122
  backtraces = @buffer.delete(thread)
123
123
  if backtraces && @profiles.has_key?(name)
@@ -163,7 +163,7 @@ module NewRelic
163
163
  end
164
164
 
165
165
  def poll
166
- poll_start = Time.now
166
+ poll_start = Process.clock_gettime(Process::CLOCK_REALTIME)
167
167
 
168
168
  @lock.synchronize do
169
169
  AgentThread.list.each do |thread|
@@ -173,7 +173,7 @@ module NewRelic
173
173
  @buffer.delete_if { |thread, _| !thread.alive? }
174
174
  end
175
175
 
176
- end_time = Time.now
176
+ end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
177
177
  adjust_polling_time(end_time, poll_start)
178
178
  record_supportability_metrics(end_time, poll_start)
179
179
  end
@@ -197,7 +197,7 @@ module NewRelic
197
197
  # This method is expected to be called with @lock held
198
198
  def watching_for_transaction?
199
199
  @profiles.size > 1 ||
200
- (@profiles.size == 1 && @profiles[ALL_TRANSACTIONS].nil?)
200
+ (@profiles.size == 1 && @profiles[ALL_TRANSACTIONS].nil?)
201
201
  end
202
202
 
203
203
  def allowed_bucket?(bucket)
@@ -230,7 +230,7 @@ module NewRelic
230
230
  bucket = AgentThread.bucket_thread(thread, @profile_agent_code)
231
231
 
232
232
  if need_backtrace?(bucket)
233
- timestamp = Time.now.to_f
233
+ timestamp = Process.clock_gettime(Process::CLOCK_REALTIME)
234
234
  backtrace = AgentThread.scrub_backtrace(thread, @profile_agent_code)
235
235
  aggregate_global_backtrace(backtrace, bucket, thread)
236
236
  buffer_backtrace_for_thread(thread, timestamp, backtrace, bucket)
@@ -277,7 +277,6 @@ module NewRelic
277
277
  end
278
278
  @last_poll = poll_start
279
279
  end
280
-
281
280
  end
282
281
  end
283
282
  end