newrelic_rpm 6.15.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +260 -22
  4. data/CONTRIBUTING.md +13 -2
  5. data/README.md +4 -2
  6. data/lib/new_relic/agent/adaptive_sampler.rb +2 -2
  7. data/lib/new_relic/agent/agent.rb +8 -7
  8. data/lib/new_relic/agent/autostart.rb +1 -2
  9. data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -3
  10. data/lib/new_relic/agent/configuration/default_source.rb +456 -233
  11. data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
  12. data/lib/new_relic/agent/configuration/manager.rb +3 -4
  13. data/lib/new_relic/agent/configuration/server_source.rb +3 -2
  14. data/lib/new_relic/agent/configuration/yaml_source.rb +22 -1
  15. data/lib/new_relic/agent/connect/request_builder.rb +4 -2
  16. data/lib/new_relic/agent/custom_event_aggregator.rb +2 -1
  17. data/lib/new_relic/agent/database.rb +5 -2
  18. data/lib/new_relic/agent/datastores/mongo.rb +5 -10
  19. data/lib/new_relic/agent/datastores/redis.rb +0 -4
  20. data/lib/new_relic/agent/datastores.rb +7 -7
  21. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
  22. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +10 -6
  23. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +0 -1
  24. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
  25. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +1 -1
  26. data/lib/new_relic/agent/distributed_tracing.rb +0 -66
  27. data/lib/new_relic/agent/error_collector.rb +52 -37
  28. data/lib/new_relic/agent/error_filter.rb +167 -0
  29. data/lib/new_relic/agent/event_loop.rb +6 -6
  30. data/lib/new_relic/agent/external.rb +0 -32
  31. data/lib/new_relic/agent/http_clients/abstract.rb +2 -2
  32. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -1
  33. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
  34. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
  35. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -3
  36. data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
  37. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
  38. data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
  39. data/lib/new_relic/agent/instrumentation/bunny.rb +10 -152
  40. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -1
  41. data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
  42. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
  43. data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
  44. data/lib/new_relic/agent/instrumentation/curb.rb +9 -241
  45. data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
  46. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
  47. data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
  48. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -50
  49. data/lib/new_relic/agent/instrumentation/excon.rb +4 -22
  50. data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
  51. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
  52. data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
  53. data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
  54. data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
  55. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
  56. data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
  57. data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
  58. data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
  59. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
  60. data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
  61. data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
  62. data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
  63. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
  64. data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
  65. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
  66. data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
  67. data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
  68. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -0
  69. data/lib/new_relic/agent/instrumentation/mongo.rb +3 -134
  70. data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
  71. data/lib/new_relic/agent/instrumentation/{net_prepend.rb → net_http/instrumentation.rb} +3 -3
  72. data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
  73. data/lib/new_relic/agent/instrumentation/net_http.rb +44 -0
  74. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
  75. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
  76. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
  77. data/lib/new_relic/agent/instrumentation/padrino.rb +18 -53
  78. data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
  79. data/lib/new_relic/agent/instrumentation/rack/chain.rb +58 -0
  80. data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
  81. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
  82. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +37 -0
  83. data/lib/new_relic/agent/instrumentation/rack.rb +29 -139
  84. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +5 -5
  85. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
  86. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -41
  87. data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
  88. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
  89. data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
  90. data/lib/new_relic/agent/instrumentation/rake.rb +13 -154
  91. data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
  92. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
  93. data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
  94. data/lib/new_relic/agent/instrumentation/redis.rb +12 -107
  95. data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
  96. data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
  97. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +35 -0
  98. data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
  99. data/lib/new_relic/agent/instrumentation/resque.rb +21 -32
  100. data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
  101. data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
  102. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
  103. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +124 -0
  104. data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
  105. data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -158
  106. data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
  107. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
  108. data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
  109. data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
  110. data/lib/new_relic/agent/javascript_instrumentor.rb +15 -10
  111. data/lib/new_relic/agent/messaging.rb +10 -24
  112. data/lib/new_relic/agent/method_tracer.rb +132 -138
  113. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +6 -1
  114. data/lib/new_relic/agent/new_relic_service.rb +24 -22
  115. data/lib/new_relic/agent/pipe_channel_manager.rb +10 -6
  116. data/lib/new_relic/agent/pipe_service.rb +1 -1
  117. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  118. data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
  119. data/lib/new_relic/agent/sql_sampler.rb +4 -4
  120. data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
  121. data/lib/new_relic/agent/stats_engine.rb +1 -1
  122. data/lib/new_relic/agent/supported_versions.rb +1 -1
  123. data/lib/new_relic/agent/threading/backtrace_service.rb +4 -5
  124. data/lib/new_relic/agent/threading/thread_profile.rb +1 -1
  125. data/lib/new_relic/agent/tracer.rb +15 -37
  126. data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -3
  127. data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -11
  128. data/lib/new_relic/agent/transaction.rb +8 -32
  129. data/lib/new_relic/agent/transaction_time_aggregator.rb +5 -5
  130. data/lib/new_relic/agent/vm/snapshot.rb +1 -1
  131. data/lib/new_relic/agent/worker_loop.rb +5 -5
  132. data/lib/new_relic/agent.rb +10 -13
  133. data/lib/new_relic/cli/commands/deployments.rb +2 -2
  134. data/lib/new_relic/constants.rb +0 -4
  135. data/lib/new_relic/control/frameworks/rails.rb +11 -9
  136. data/lib/new_relic/control/instance_methods.rb +1 -0
  137. data/lib/new_relic/dependency_detection.rb +116 -10
  138. data/lib/new_relic/noticed_error.rb +5 -9
  139. data/lib/new_relic/supportability_helper.rb +1 -2
  140. data/lib/new_relic/version.rb +2 -2
  141. data/lib/newrelic_rpm.rb +10 -34
  142. data/lib/tasks/all.rb +1 -1
  143. data/lib/tasks/config.html.erb +14 -25
  144. data/lib/tasks/config.rake +8 -7
  145. data/newrelic.yml +593 -3
  146. data/newrelic_rpm.gemspec +1 -1
  147. data/test/agent_helper.rb +27 -2
  148. metadata +56 -14
  149. data/cert/cacert.pem +0 -1177
  150. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
  151. data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
  152. data/lib/new_relic/agent/instrumentation/http.rb +0 -49
  153. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
  154. data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
  155. data/lib/new_relic/agent/instrumentation/net.rb +0 -70
  156. data/lib/new_relic/control/frameworks/merb.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59fdb006789ae2f1cb776c15084ad1bc7f854abf000573fd11dd2c14882b4273
4
- data.tar.gz: 7b8d00cdaa547832fb34c1f76a697b694ff28c9a74be046545e7d3b0866d97e6
3
+ metadata.gz: ea3d77f1e8feb27c92b40dbd4d1732c5c068c786a99ab3f9cd76573ed6a201a1
4
+ data.tar.gz: a825501f60da5aa176ac391cc4acd91192b57736f476b477eae29efec1ca7e53
5
5
  SHA512:
6
- metadata.gz: 5cadb8ca1d02feadc30a85871d1e8cd6c24064bfc3b1bed98680573bb4c29075e07447f4290dfc360d9607c1ff3a5433d0c36be9eaeae515c725547424ee92cc
7
- data.tar.gz: c3901a54a577cdab2159ee6a93bf4bd6acf82d6629d4d4ba99c4565d7155efc7d653387f9fcee8cd246d19cecfe662b60bd63f05cbf19d38194e0b6d9d6ce0b9
6
+ metadata.gz: 4019cf2596a500dd0b0ffb0c316d5f68bcef00ffd114a480045ad8e3cee708002211da40a3240f0db1b924be06b4656d0e2964818cbce4cc86427436684f0c22
7
+ data.tar.gz: 8b0849f1c3c8ff8b770e83fb67dc77d5ccf0e3f4302c7d77359764c967bec4e2ee1064207a499e0a6a8acf17f25e60a07c974133ade3b14c4866af26ea306052
data/.gitignore CHANGED
@@ -35,3 +35,5 @@ test/fixtures/cross_agent_tests/*/README.md
35
35
  node_modules/
36
36
  yarn.lock
37
37
  errors.txt
38
+ .history/
39
+ vendor/
data/CHANGELOG.md CHANGED
@@ -1,9 +1,247 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v8.0.0
4
+
5
+ * **`add_method_tracer` refactored to use prepend over alias_method chaining**
6
+
7
+ This release overhauls the implementation of `add_method_tracer`, as detailed in [issue #502](https://github.com/newrelic/newrelic-ruby-agent/issues/502). The main breaking updates are as follows:
8
+ - A metric name passed to `add_method_tracer` will no longer be interpolated in an instance context as before. To maintain this behavior, pass a Proc object with the same arity as the method being traced. For example:
9
+ ```ruby
10
+ # OLD
11
+ add_method_tracer :foo, '#{args[0]}.#{args[1]}'
12
+
13
+ # NEW
14
+ add_method_tracer :foo, -> (*args) { "#{args[0]}.#{args[1]}" }
15
+ ```
16
+
17
+ - Similarly, the `:code_header` and `:code_footer` options to `add_method_tracer` will *only* accept a Proc object, which will be bound to the calling instance when the traced method is invoked.
18
+
19
+ - Calling `add_method_tracer` for a method will overwrite any previously defined tracers for that method. To specify multiple metric names for a single method tracer, pass them to `add_method_tracer` as an array.
20
+
21
+ See updated documentation on the following pages for full details:
22
+ - [Ruby Custom Instrumentation: Method Tracers](https://docs.newrelic.com/docs/agents/ruby-agent/api-guides/ruby-custom-instrumentation/#method_tracers)
23
+ - [MethodTracer::ClassMethods#add_method_tracer](https://rubydoc.info/github/newrelic/newrelic-ruby-agent/NewRelic/Agent/MethodTracer/ClassMethods#add_method_tracer-instance_method)
24
+
25
+
26
+ * **Distributed tracing is enabled by default**
27
+
28
+ [Distributed tracing](https://docs.newrelic.com/docs/distributed-tracing/enable-configure/language-agents-enable-distributed-tracing/) tracks and observes service requests as they flow through distributed systems. Distributed tracing is now enabled by default and replaces [cross application tracing](https://docs.newrelic.com/docs/agents/ruby-agent/features/cross-application-tracing-ruby/).
29
+
30
+ * **Bugfix: Incorrectly loading configuration options from newrelic.yml**
31
+
32
+ The agent will now import the configuration options [`error_collector.ignore_messages`](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration/#error_collector-ignore_messages) and [`error_collector.expected_messages`](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration/#error_collector-expected_messages) from the `newrelic.yml` file correctly.
33
+
34
+ * **Cross Application is now deprecated, and disabled by default**
35
+
36
+ [Distributed tracing](https://docs.newrelic.com/docs/distributed-tracing/enable-configure/language-agents-enable-distributed-tracing/) is replacing [cross application tracing](https://docs.newrelic.com/docs/agents/ruby-agent/features/cross-application-tracing-ruby/) as the default means of tracing between services. To continue using it, enable it with `cross_application_tracer.enabled: true` and `distributed_tracing.enabled: false`
37
+
38
+ * **Update configuration option default value for `span_events.max_samples_stored` from 1000 to 2000**
39
+
40
+ For more information about this congfiguration option, visit [the Ruby agent documentation](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration/#span_events-max_samples_stored).
41
+
42
+ * **Agent now enforces server supplied maximum value for configuration option `span_events.max_samples_stored`**
43
+
44
+ Upon connection to the New Relic servers, the agent will now enforce a maximum value allowed for the configuration option [`span_events.max_samples_stored`](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration/#span_events-max_samples_stored) sent from the New Relic servers.
45
+
46
+ * **Remove Ruby 2.0 required kwarg compatibility checks**
47
+
48
+ Our agent has code that provides compatibility for required keyword arguments in Ruby versions below 2.1. Since the agent now only supports Ruby 2.2+, this code is no longer required.
49
+
50
+ * **Replace Time.now with Process.clock_gettime**
51
+
52
+ Calls to `Time.now` have been replaced with calls to `Process.clock_gettime` to leverage the system's built-in clocks for elapsed time (`Process::CLOCK_MONOTONIC`) and wall-clock time (`Process::CLOCK_REALTIME`). This results in fewer object allocations, more accurate elapsed time records, and enhanced performance. Thanks to @sdemjanenko and @viraptor for advocating for this change!
53
+
54
+ * **Updated generated default newrelic.yml**
55
+
56
+ Thank you @wyhaines and @creaturenex for your contribution. The default newrelic.yml that the agent can generate is now updated with commented out examples of all configuration options.
57
+
58
+ * **Bugfix: Psych 4.0 causes errors when loading newrelic.yml**
59
+
60
+ Psych 4.0 now uses safe load behavior when using `YAML.load` which by default doesn't allow aliases, causing errors when the agent loads the config file. We have updated how we load the config file to avoid these errors.
61
+
62
+ * **Remove support for Excon versions below 0.19.0**
63
+
64
+ Excon versions below 0.19.0 will no longer be instrumented through the Ruby agent.
65
+
66
+ * **Remove support for Mongo versions below 2.1**
67
+
68
+ Mongo versions below 2.1 will no longer be instrumented through the Ruby agent.
69
+
70
+ * **Remove tests for Rails 3.0 and Rails 3.1**
71
+
72
+ As of the 7.0 release, the Ruby agent stopped supporting Rails 3.0 and Rails 3.1. Despite this, we still had tests for these versions running on the agent's CI. Those tests are now removed.
73
+
74
+ * **Update test Gemfiles for patched versions**
75
+
76
+ The gem has individual Gemfiles it uses to test against different common user setups. Rails 5.2, 6.0, and 6.1 have been updated to the latest patch versions in the test Gemfiles. Rack was updated in the Rails61 test suite to 2.1.4 to resolve a security vulnerability.
77
+
78
+ * **Remove Merb Support**
79
+
80
+ This release removes the remaining support for the [Merb](https://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3/) framework. It merged with Rails during the 3.0 release. Now that the Ruby agent supports Rails 3.2 and above, we thought it was time to say goodbye.
81
+
82
+ * **Remove deprecated method External.start_segment**
83
+
84
+ The method `NewRelic::Agent::External.start_segment` has been deprecated as of Ruby Agent 6.0.0. This method is now removed.
85
+
86
+ * **Added testing and support for the following gem versions**
87
+
88
+ - activemerchant 1.121.0
89
+ - bunny 2.19.0
90
+ - excon 0.85.0
91
+ - mongo 2.14.0, 2.15.1
92
+ - padrino 0.15.1
93
+ - resque 2.1.0
94
+ - sequel 5.48.0
95
+ - yajl-ruby 1.4.1
96
+
97
+ * **This version adds support for ARM64/Graviton2 platform using Ruby 3.0.2+**
98
+
99
+
100
+ ## v7.2.0
101
+
102
+ * **Expected Errors and Ignore Errors**
103
+ This release adds support for configuration for expected/ignored errors by class name, status code, and message. The following configuration options are now available:
104
+ - `error_collector.ignore_classes`
105
+ - `error_collector.ignore_messages`
106
+ - `error_collector.ignore_status_codes`
107
+ - `error_collector.expected_classes`
108
+ - `error_collector.expected_messages`
109
+ - `error_collector.expected_status_codes`
110
+ For more details about expected and ignored errors, please see our [configuration documentation](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/)
111
+
112
+ * **Bugfix: resolves "can't add a new key into hash during iteration" Errors**
113
+
114
+ Thanks to @wyhaines for this fix that prevents "can't add a new key into hash during iteration" errors from occuring when iterating over environment data.
115
+
116
+ * **Bugfix: kwarg support fixed for Rack middleware instrumentation**
117
+
118
+ Thanks to @walro for submitting this fix. This fixes the rack instrumentation when using kwargs.
119
+
120
+ * **Update known conflicts with use of Module#Prepend**
121
+
122
+ With our release of v7.0.0, we updated our instrumentation to use Module#Prepend by default, instead of method chaining. We have received reports of conflicts and added a check for these known conflicts. If a known conflict with prepend is detected while using the default value of 'auto' for gem instrumentation, the agent will instead install method chaining instrumentation in order to avoid this conflict. This check can be bypassed by setting the instrumentation method for the gem to 'prepend'.
123
+
124
+ ## v7.1.0
125
+
126
+ * **Add support for CSP nonces when using our API to insert the browser agent**
127
+
128
+ We now support passing in a nonce to our API method `browser_timing_header` to allow the browser agent to run on applications using CSP nonces. This allows users to inject the browser agent themselves and use the nonce required for the script to run. In order to utilize this new feature, you must disable auto instrumentation for the browser agent, and use the API method browser_timing_header to pass the nonce in and inject the script manually.
129
+
130
+ * **Removed MD5 use in the SQL sampler**
131
+
132
+ In order to allow the agent to run in FIPS compliant environments, the usage of MD5 for aggregating slow sql traces has been replaced with SHA1.
133
+
134
+ * **Enable server-side configuration of distributed tracing**
135
+
136
+ `distributed_tracing.enabled` may now be set in server-side application configuration.
137
+
138
+ * **Bugfix: Fix for missing part of a previous bugfix**
139
+
140
+ Our previous fix of "nil Middlewares injection now prevented and gracefully handled in Sinatra" released in 7.0.0 was partially overwritten by some of the other changes in that release. This release adds back those missing sections of the bugfix, and should resolve the issue for sinatra users.
141
+
142
+ * **Update known conflicts with use of Module#Prepend**
143
+
144
+ With our release of v7.0.0, we updated our instrumentation to use Module#Prepend by default, instead of method chaining. We have received reports of conflicts and added a check for these known conflicts. If a known conflict with prepend is detected while using the default value of 'auto' for gem instrumentation, the agent will instead install method chaining instrumentation in order to avoid this conflict. This check can be bypassed by setting the instrumentation method for the gem to 'prepend'.
145
+
146
+ * **Bugfix: Updated support for ActiveRecord 6.1+ instrumentation**
147
+
148
+ Previously, the agent depended on `connection_id` to be present in the Active Support instrumentation for `sql.active_record`
149
+ to get the current ActiveRecord connection. As of Rails 6.1, `connection_id` has been dropped in favor of providing the connection
150
+ object through the `connection` value exclusively. This resulted in datastore spans displaying fallback behavior, including showing
151
+ "ActiveRecord" as the database vendor.
152
+
153
+ * **Bugfix: Updated support for Resque's FORK_PER_JOB option**
154
+
155
+ Support for Resque's FORK_PER_JOB flag within the Ruby agent was incomplete and nonfunctional. The agent should now behave
156
+ correctly when running in a non-forking Resque worker process.
157
+
158
+ * **Bugfix: Added check for ruby2_keywords in add_transaction_tracer**
159
+
160
+ Thanks @beauraF for the contribution! Previously, the add_transaction_tracer was not updated when we added support for ruby 3. In order to correctly support `**kwargs`, ruby2_keywords was added to correctly update the method signature to use **kwargs in ruby versions that support that.
161
+
162
+ * **Confirmed support for yajl 1.4.0**
163
+
164
+ Thanks to @creaturenex for the contribution! `yajl-ruby` 1.4.0 was added to our test suite and confirmed all tests pass, showing the agent supports this version as well.
165
+
166
+
167
+ ## v7.0.0
168
+
169
+ * **Ruby Agent 6.x to 7.x Migration Guide Available**
170
+
171
+ Please see our [Ruby Agent 6.x to 7.x migration guide](https://docs.newrelic.com/docs/agents/ruby-agent/getting-started/migration-7x-guide/) for helpful strategies and tips for migrating from earlier versions of the Ruby agent to 7.0.0. We cover new configuration settings, diagnosiing and installing SSL CA certificates and deprecated items and their replacements in this guide.
172
+
173
+ * **Ruby 2.0 and 2.1 Dropped**
174
+
175
+ Support for Ruby 2.0 and 2.1 dropped with this release. No code changes that would prevent the agent from continuing to
176
+ work with these releases are known. However, Rubies 2.0 and 2.1 are no longer included in our test matrices and are not supported
177
+ for 7.0.0 and onward.
178
+
179
+ * **Implemented prepend auto-instrumentation strategies for most Ruby gems/libraries**
180
+
181
+ This release brings the auto-instrumentation strategies for most gems into the modern era for Ruby by providing both
182
+ prepend and method-chaining (a.k.a. method-aliasing) strategies for auto instrumenting. Prepend, which has been available since
183
+ Ruby 2.0 is now the default strategy employed in auto-instrumenting. It is known that some external gems lead to Stack Level
184
+ too Deep exceptions when prepend and method-chaining are mixed. In such known cases, auto-instrumenting strategy will fall back
185
+ to method-chaining automatically.
186
+
187
+ This release also deprecates many overlapping and inconsistently named configuration settings in favor of being able to control
188
+ behavior of instrumentation per library with one setting that can be one of auto (the default), disabled, prepend, or chain.
189
+
190
+ Please see the above-referenced migration guide for further details.
191
+
192
+ * **Removed SSL cert bundle**
193
+
194
+ The agent will no longer ship this bundle and will rely on system certs.
195
+
196
+ * **Removed deprecated config options**
197
+
198
+ The following config options were previously deprecated and are no longer available
199
+ - `disable_active_record_4`
200
+ - `disable_active_record_5`
201
+ - `autostart.blacklisted_constants`
202
+ - `autostart.blacklisted_executables`
203
+ - `autostart.blacklisted_rake_tasks`
204
+ - `strip_exception_messages.whitelist`
205
+
206
+ * **Removed deprecated attribute**
207
+
208
+ The attribute `httpResponseCode` was previously deprecated and replaced with `http.statusCode`. This deprecated attribute has now been removed.
209
+
210
+ * **Removed deprecated option in notice_error**
211
+
212
+ Previously, the `:trace_only` option to NewRelic::Agent.notice_error was deprecated and replaced with `:expected`. This deprecated option has been removed.
213
+
214
+ * **Removed deprecated api methods**
215
+
216
+ Previously the api methods `create_distributed_trace_payload` and `accept_distributed_trace_payload` were deprecated. These have now been removed. Instead, please see `insert_distributed_trace_headers` and `accept_distributed_trace_headers`, respectively.
217
+
218
+ * **Bugfix: Prevent browser monitoring middleware from installing to middleware multiple times**
219
+
220
+ In rare cases on jRuby, the BrowserMonitoring middleware could attempt to install itself
221
+ multiple times at start up. This bug fix addresses that by using a mutex to introduce
222
+ thread safety to the operation. Sintra in particular can have this race condition because
223
+ its middleware stack is not installed until the first request is received.
224
+
225
+ * **Skip constructing Time for transactions**
226
+
227
+ Thanks to @viraptor, we are no longer constructing an unused Time object with every call to starting a new Transaction.
228
+
229
+ * **Bugfix: nil Middlewares injection now prevented and gracefully handled in Sinatra**
230
+
231
+ Previously, the agent could potentially inject multiples of an instrumented middleware if Sinatra received many
232
+ requests at once during start up and initialization due to Sinatra's ability to delay full start up as long as possible.
233
+ This has now been fixed and the Ruby agent correctly instruments only once as well as gracefully handles nil middleware
234
+ classes in general.
235
+
236
+ * **Bugfix: Ensure transaction nesting max depth is always consistent with length of segments**
237
+
238
+ Thanks to @warp for noticing and fixing the scenario where Transaction nesting_max_depth can get out of sync
239
+ with segments length resulting in an exception when attempting to nest the initial segment which does not exist.
240
+
3
241
  ## v6.15.0
4
242
 
5
243
  * **Official Ruby 3.0 support**
6
-
244
+
7
245
  The ruby agent has been verified to run on ruby 3.0.0
8
246
 
9
247
  * **Added support for Rails 6.1**
@@ -17,7 +255,7 @@
17
255
 
18
256
  * **Bugfix: No longer overwrites sidekiq trace data**
19
257
 
20
- Distributed traing data is now added to the job trace info rather than overwriting the existing data.
258
+ Distributed tracing data is now added to the job trace info rather than overwriting the existing data.
21
259
 
22
260
  * **Bugfix: Fixes cases where errors are reported for spans with no other attributes**
23
261
 
@@ -26,7 +264,7 @@
26
264
  This is now fixed and errors are now correctly recorded against such span events.
27
265
 
28
266
  * **Bugfix: `DistributedTracing.insert_distributed_trace_headers` Supportability metric now recorded**
29
-
267
+
30
268
  Previously, API calls to `DistributedTracing.insert_distributed_trace_headers` would lead to an exception
31
269
  about the missing supportability metric rather than flowing through the API implementation as intended.
32
270
  This would potentially lead to broken distributed traces as the trace headers were not inserted on the API call.
@@ -36,25 +274,25 @@
36
274
  * **Bugfix: child completions after parent completes sometimes throws exception attempting to access nil parent**
37
275
 
38
276
  In scenarios where the child segment/span is completing after the parent in jRuby, the parent may have already
39
- been freed and no longer accessible. This would lead to attempting to calll `descendant_complete` on a Nil
277
+ been freed and no longer accessible. This would lead to an attempt to call `descendant_complete` on a Nil
40
278
  object. This is fixed to protect against calling the `descendant_complete` in such cases.
41
-
279
+
42
280
  * **Feature: implements `force_install_exit_handler` config flag**
43
-
44
- The `force_install_exit_handler` configuration flag allows an application to instruct the agent to install it's
45
- graceful shutdown exit handler, which will send any locally cached data to the New Relic collector prior to the
46
- application shutting down. This useful for when the primary framework has an embedded Sinatra application that
281
+
282
+ The `force_install_exit_handler` configuration flag allows an application to instruct the agent to install its
283
+ graceful shutdown exit handler, which will send any locally cached data to the New Relic collector prior to the
284
+ application shutting down. This is useful for when the primary framework has an embedded Sinatra application that
47
285
  is otherwise detected and skips installing the exit hook for graceful shutdowns.
48
286
 
49
287
  * **Default prepend_net_instrumentation to false**
50
288
 
51
- Previously, `prepend_net_instrumentation` defaulted to true. However, many gems are still using monkey patching on Net::HTTP, which causes compatibility issues with using prepend. Defaulting this to false minimizes instances of
289
+ Previously, `prepend_net_instrumentation` defaulted to true. However, many gems are still using monkey patching on Net::HTTP, which causes compatibility issues with using prepend. Defaulting this to false minimizes instances of
52
290
  unexpected compatibilty issues.
53
-
291
+
54
292
  ## v6.14.0
55
293
 
56
294
  * **Bugfix: Method tracers no longer cloning arguments**
57
-
295
+
58
296
  Previously, when calling add_method_tracer with certain combination of arguments, it would lead to the wrapped method's arguments being cloned rather than passed to the original method for manipulation as intended. This has been fixed.
59
297
 
60
298
  * **Bugfix: Delayed Job instrumentation fixed for Ruby 2.7+**
@@ -63,22 +301,22 @@
63
301
  Delayed Job's library. The led to Delayed job not auto-instrumenting correctly and has been fixed.
64
302
 
65
303
  * **Bugfix: Ruby 2.7+ methods sometimes erroneously attributed compiler warnings to the Agent's `add_method_tracer`**
66
-
304
+
67
305
  The specific edge cases presented are now fixed by this release of the agent. There are still some known corner-cases
68
- that will be resolved with upcoming changes in next major release of the Agent. If you encounter a problem with adding
306
+ that will be resolved with upcoming changes in next major release of the Agent. If you encounter a problem with adding
69
307
  method tracers and compiler warnings raised, please continue to submit small repoducible examples.
70
308
 
71
309
  * **Bugfix: Ruby 2.7+ fix for keyword arguments on Rack apps is unnecessary and removed**
72
310
 
73
- A common fix for positional and keyword arguments for method parameters was implemented where it was not needed and
74
- led to RackApps getting extra arguments converted to keyword arguments rather than Hash when it expected one. This
311
+ A common fix for positional and keyword arguments for method parameters was implemented where it was not needed and
312
+ led to RackApps getting extra arguments converted to keyword arguments rather than Hash when it expected one. This
75
313
  Ruby 2.7+ change was reverted so that Rack apps behave correctly for Ruby >= 2.7.
76
314
 
77
315
  * **Feature: captures incoming and outgoing request headers for distributed tracing**
78
316
 
79
- HTTP request headers will be logged when log level is at least debug level. Similarly, request headers
317
+ HTTP request headers will be logged when log level is at least debug level. Similarly, request headers
80
318
  for exchanges with New Relic servers are now audit logged when audit logging is enabled.
81
-
319
+
82
320
  * **Bugfix: `newrelic.yml.erb` added to the configuration search path**
83
321
 
84
322
  Previously, when a user specifies a `newrelic.yml.erb` and no `newrelic.yml` file, the agent fails to find
@@ -88,7 +326,7 @@
88
326
  the `.yml` file is used instead of the `.erb` file. Search directories and order of traversal remain unchanged.
89
327
 
90
328
  * **Bugfix: dependency detection of Redis now works without raising an exception**
91
-
329
+
92
330
  Previously, when detecting if Redis was available to instrument, the dependency detection would fail with an Exception raised
93
331
  (with side effect of not attempting to instrument Redis). This is now fixed with a better dependency check that resolves falsly without raising an `Exception`.
94
332
 
@@ -99,12 +337,12 @@
99
337
 
100
338
  * **Memory Sampler updated to recognize macOS Big Sur**
101
339
 
102
- Previously, the agent was unable to recognize the platform macOS Big Sur in the memory sampler, resulting in an error being logged. The memory sampler is now able to recognize Big Sur.
340
+ Previously, the agent was unable to recognize the platform macOS Big Sur in the memory sampler, resulting in an error being logged. The memory sampler is now able to recognize Big Sur.
103
341
 
104
342
  * **Prepend implementation of Net::HTTP instrumentation available**
105
-
343
+
106
344
  There is now a config option (`prepend_net_instrumentation`) that will enable the agent to use prepend while instrumenting Net::HTTP. This option is set to true by default.
107
-
345
+
108
346
  ## v6.13.1
109
347
 
110
348
  * **Bugfix: obfuscating URLs to external services no longer modifying original URI**
data/CONTRIBUTING.md CHANGED
@@ -6,8 +6,7 @@ development team.
6
6
 
7
7
  When contributing, keep in mind that the agent runs in a wide variety of Ruby
8
8
  language implementations (e.g. 2.x.x, jruby, etc.) as well as a wide variety of
9
- application environments (e.g. Rails, Sinatra, roll-your-own, etc.) See [Ruby agent requirements and supported frameworks]
10
- (https://docs.newrelic.com/docs/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks)
9
+ application environments (e.g. Rails, Sinatra, roll-your-own, etc.) See [Ruby agent requirements and supported frameworks](https://docs.newrelic.com/docs/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks)
11
10
  for the current full list.
12
11
 
13
12
  Because of this, we need to be more defensive in our coding practices than most
@@ -85,6 +84,18 @@ release from this repo, use the appropriate tag. New Relic usually pushes beta
85
84
  versions of a release to a working branch before tagging them for General
86
85
  Availability.
87
86
 
87
+ ## Development Environment Setup
88
+
89
+ 1. Fork and clone the repo locally
90
+ - Fork the repository inside GitHub
91
+ - `git clone git@github.com:<gh username>/newrelic-ruby-agent.git`
92
+ 1. Pick a Ruby version
93
+ - Use rbenv or rvm to install any version of Ruby between 2.2 up to 3.0.1
94
+ 1. Install development dependencies
95
+ - `bundle install`
96
+ 1. Check that your env is setup correctly
97
+ - `bundle exec rake`
98
+
88
99
  ## Testing
89
100
 
90
101
  The agent includes a suite of unit and functional tests which should be used to
data/README.md CHANGED
@@ -11,6 +11,8 @@ to help you improve the customer experience and make data-driven business decisi
11
11
  The New Relic Ruby Agent is dual-purposed as a either a Gem or a Rails plugin,
12
12
  hosted on [github](https://github.com/newrelic/newrelic-ruby-agent).
13
13
 
14
+ [![Gem Version](https://badge.fury.io/rb/newrelic_rpm.svg)](https://badge.fury.io/rb/newrelic_rpm)
15
+
14
16
  ## Supported Environments
15
17
 
16
18
  An up-to-date list of Ruby versions and frameworks for the latest agent
@@ -47,7 +49,7 @@ and then require the New Relic Ruby agent in your Ruby start-up sequence:
47
49
  require 'newrelic_rpm'
48
50
  ```
49
51
 
50
- #### Oher Environments
52
+ #### Other Environments
51
53
 
52
54
  Assuming you have installed the agent per above, you may also need to tell the Ruby agent to start for some frameworks and non-framework environments. To do so, add the following to your Ruby start-up sequence start the agent:
53
55
 
@@ -133,4 +135,4 @@ Thank you, and may your application scale to infinity plus one.
133
135
 
134
136
  Lew Cirne, Founder and CEO
135
137
 
136
- New Relic, Inc.
138
+ New Relic, Inc.
@@ -13,7 +13,7 @@ module NewRelic
13
13
  @sampled_count = 0
14
14
  @period_duration = period_duration
15
15
  @first_period = true
16
- @period_start = Time.now.to_f
16
+ @period_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
17
17
  @lock = Mutex.new
18
18
  register_config_callbacks
19
19
  end
@@ -53,7 +53,7 @@ module NewRelic
53
53
  private
54
54
 
55
55
  def reset_if_period_expired!
56
- now = Time.now.to_f
56
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
57
57
  return unless @period_start + @period_duration <= now
58
58
 
59
59
  elapsed_periods = Integer((now - @period_start) / @period_duration)
@@ -17,6 +17,7 @@ require 'new_relic/agent/new_relic_service'
17
17
  require 'new_relic/agent/pipe_service'
18
18
  require 'new_relic/agent/configuration/manager'
19
19
  require 'new_relic/agent/database'
20
+ require 'new_relic/agent/instrumentation/resque/helper'
20
21
  require 'new_relic/agent/commands/agent_command_router'
21
22
  require 'new_relic/agent/event_listener'
22
23
  require 'new_relic/agent/distributed_tracing'
@@ -214,7 +215,7 @@ module NewRelic
214
215
  @connected_pid = Process.pid
215
216
  else
216
217
  ::NewRelic::Agent.logger.debug("Child process #{Process.pid} not reporting to non-connected parent (process #{Process.ppid}).")
217
- @service.shutdown(Time.now)
218
+ @service.shutdown
218
219
  disconnect
219
220
  end
220
221
  end
@@ -470,7 +471,7 @@ module NewRelic
470
471
  # before Resque calls Process.daemon (Jira RUBY-857)
471
472
  def defer_for_resque?
472
473
  NewRelic::Agent.config[:dispatcher] == :resque &&
473
- NewRelic::LanguageSupport.can_fork? &&
474
+ NewRelic::Agent::Instrumentation::Resque::Helper.resque_fork_per_job? &&
474
475
  !PipeChannelManager.listener.started?
475
476
  end
476
477
 
@@ -1122,7 +1123,7 @@ module NewRelic
1122
1123
  end
1123
1124
 
1124
1125
  def transmit_single_data_type(harvest_method, supportability_name)
1125
- now = Time.now
1126
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
1126
1127
 
1127
1128
  msg = "Sending #{supportability_name} data to New Relic Service"
1128
1129
  ::NewRelic::Agent.logger.debug msg
@@ -1131,12 +1132,12 @@ module NewRelic
1131
1132
  self.send(harvest_method)
1132
1133
  end
1133
1134
  ensure
1134
- duration = (Time.now - now).to_f
1135
+ duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
1135
1136
  NewRelic::Agent.record_metric("Supportability/#{supportability_name}Harvest", duration)
1136
1137
  end
1137
1138
 
1138
1139
  def transmit_data
1139
- now = Time.now
1140
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
1140
1141
  ::NewRelic::Agent.logger.debug "Sending data to New Relic Service"
1141
1142
 
1142
1143
  @events.notify(:before_harvest)
@@ -1153,7 +1154,7 @@ module NewRelic
1153
1154
  end
1154
1155
  ensure
1155
1156
  NewRelic::Agent::Database.close_connections
1156
- duration = (Time.now - now).to_f
1157
+ duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - now
1157
1158
  NewRelic::Agent.record_metric('Supportability/Harvest', duration)
1158
1159
  end
1159
1160
 
@@ -1178,7 +1179,7 @@ module NewRelic
1178
1179
 
1179
1180
  if @connected_pid == $$ && !@service.kind_of?(NewRelic::Agent::NewRelicService)
1180
1181
  ::NewRelic::Agent.logger.debug "Sending New Relic service agent run shutdown message"
1181
- @service.shutdown(Time.now.to_f)
1182
+ @service.shutdown
1182
1183
  else
1183
1184
  ::NewRelic::Agent.logger.debug "This agent connected from parent process #{@connected_pid}--not sending shutdown"
1184
1185
  end
@@ -32,8 +32,7 @@ module NewRelic
32
32
  COMMA = ",".freeze
33
33
 
34
34
  def denylisted_constants?
35
- # For backwards compatibility until :'autostart_blacklisted_constants' config option is removed
36
- constants = NewRelic::Agent.config[:'autostart.denylisted_constants'] << COMMA << NewRelic::Agent.config[:'autostart.blacklisted_constants']
35
+ constants = NewRelic::Agent.config[:'autostart.denylisted_constants']
37
36
 
38
37
  denylisted?(constants) do |name|
39
38
  constant_is_defined?(name)
@@ -38,7 +38,7 @@ module NewRelic
38
38
  agent_command.arguments
39
39
  )
40
40
 
41
- @started_at = Time.now
41
+ @started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
42
42
  @duration = profile.duration if profile
43
43
  end
44
44
 
@@ -51,7 +51,9 @@ module NewRelic
51
51
  end
52
52
 
53
53
  def harvest
54
- NewRelic::Agent.logger.debug("Harvesting from Thread Profiler #{@finished_profile.to_log_description unless @finished_profile.nil?}")
54
+ NewRelic::Agent.logger.debug(
55
+ "Harvesting from Thread Profiler #{@finished_profile.to_log_description unless @finished_profile.nil?}"
56
+ )
55
57
  profile = @finished_profile
56
58
  @backtrace_service.profile_agent_code = false
57
59
  @finished_profile = nil
@@ -72,7 +74,9 @@ module NewRelic
72
74
  end
73
75
 
74
76
  def past_time?
75
- @started_at && (Time.now > @started_at + @duration)
77
+ @started_at && (
78
+ Process.clock_gettime(Process::CLOCK_REALTIME) > @started_at + @duration
79
+ )
76
80
  end
77
81
 
78
82
  def stopped?