newrelic_rpm 7.0.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +187 -0
  4. data/CONTRIBUTING.md +13 -2
  5. data/README.md +5 -1
  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/commands/thread_profiler_session.rb +7 -3
  9. data/lib/new_relic/agent/configuration/default_source.rb +223 -158
  10. data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
  11. data/lib/new_relic/agent/configuration/manager.rb +1 -2
  12. data/lib/new_relic/agent/configuration/server_source.rb +3 -2
  13. data/lib/new_relic/agent/configuration/yaml_source.rb +22 -1
  14. data/lib/new_relic/agent/connect/request_builder.rb +4 -2
  15. data/lib/new_relic/agent/custom_event_aggregator.rb +2 -1
  16. data/lib/new_relic/agent/database.rb +5 -2
  17. data/lib/new_relic/agent/datastores/mongo.rb +5 -10
  18. data/lib/new_relic/agent/datastores.rb +7 -7
  19. data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
  20. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +10 -6
  21. data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +0 -1
  22. data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
  23. data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +1 -1
  24. data/lib/new_relic/agent/error_collector.rb +52 -37
  25. data/lib/new_relic/agent/error_filter.rb +175 -0
  26. data/lib/new_relic/agent/event_loop.rb +6 -6
  27. data/lib/new_relic/agent/external.rb +0 -32
  28. data/lib/new_relic/agent/http_clients/abstract.rb +2 -2
  29. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +7 -1
  30. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
  32. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -3
  33. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +1 -1
  34. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -1
  35. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -4
  36. data/lib/new_relic/agent/instrumentation/excon.rb +4 -23
  37. data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
  38. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +59 -0
  39. data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
  40. data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
  41. data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
  42. data/lib/new_relic/agent/instrumentation/net_http.rb +6 -1
  43. data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
  44. data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/padrino.rb +4 -2
  46. data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
  47. data/lib/new_relic/agent/instrumentation/rack/chain.rb +3 -2
  48. data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -1
  49. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +5 -5
  50. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
  51. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -41
  52. data/lib/new_relic/agent/instrumentation/redis.rb +4 -0
  53. data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
  54. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +5 -3
  55. data/lib/new_relic/agent/instrumentation/resque.rb +13 -4
  56. data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
  57. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +8 -2
  58. data/lib/new_relic/agent/javascript_instrumentor.rb +15 -10
  59. data/lib/new_relic/agent/messaging.rb +10 -24
  60. data/lib/new_relic/agent/method_tracer.rb +137 -138
  61. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +6 -1
  62. data/lib/new_relic/agent/new_relic_service.rb +16 -12
  63. data/lib/new_relic/agent/pipe_channel_manager.rb +10 -6
  64. data/lib/new_relic/agent/pipe_service.rb +1 -1
  65. data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
  66. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -6
  67. data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
  68. data/lib/new_relic/agent/sql_sampler.rb +3 -3
  69. data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
  70. data/lib/new_relic/agent/stats_engine.rb +1 -1
  71. data/lib/new_relic/agent/threading/backtrace_service.rb +4 -5
  72. data/lib/new_relic/agent/threading/thread_profile.rb +1 -1
  73. data/lib/new_relic/agent/tracer.rb +15 -37
  74. data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -3
  75. data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -11
  76. data/lib/new_relic/agent/transaction.rb +7 -28
  77. data/lib/new_relic/agent/transaction_time_aggregator.rb +5 -5
  78. data/lib/new_relic/agent/vm/snapshot.rb +1 -1
  79. data/lib/new_relic/agent/worker_loop.rb +5 -5
  80. data/lib/new_relic/agent.rb +10 -7
  81. data/lib/new_relic/cli/commands/deployments.rb +2 -2
  82. data/lib/new_relic/constants.rb +0 -4
  83. data/lib/new_relic/noticed_error.rb +4 -4
  84. data/lib/new_relic/version.rb +2 -2
  85. data/lib/newrelic_rpm.rb +10 -34
  86. data/lib/tasks/all.rb +1 -1
  87. data/lib/tasks/config.html.erb +14 -25
  88. data/lib/tasks/config.rake +8 -7
  89. data/newrelic.yml +594 -3
  90. data/newrelic_rpm.gemspec +1 -1
  91. data/test/agent_helper.rb +27 -2
  92. metadata +9 -9
  93. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
  94. data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
  95. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
  96. data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
  97. data/lib/new_relic/agent/supported_versions.rb +0 -275
  98. 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: 01dec51b68827b0fa9cd58d7882d9ddb29e7de80bcaa55cda486c30ff8529da9
4
- data.tar.gz: 358e73adb1e93b0e12bc7f415df728a4a8670bed0ac4eb36b81df545cc1c4651
3
+ metadata.gz: 8fab89acaea13ee0c348b26ff7d94118b358e9ac3ea6a48c4c231a1e0821d534
4
+ data.tar.gz: b434c14af26d097547b16601384c045a9b7b119261b17c58b2727b36ff05cf52
5
5
  SHA512:
6
- metadata.gz: b06d4efcd172c4517ac7be9c7271833cef6709ff18040ceaa81240bf4a3f8ce66f9c609cc78dfffbadc698cc761a2c7e7b439c72d69b024808c10d4b9873180f
7
- data.tar.gz: 6f665d24f019d4e5c55aef8851a48f3fe7ff9735e16c41ba97cc27664fdfc9f66cdbcfd698aebe2072b12c7124431e00f4c08bdb4b15a57350d886ff98745f08
6
+ metadata.gz: 9c568e526ec679b12cc06e3a9ed40b592665774775baf016b9be0374bea32518529c82eef199bc6369ff394c84732b0b6d7e8919f63097eb39343cde30cbca26
7
+ data.tar.gz: dde7b7c0d46c2b918d5b97f9e08eadbb1a0f1bccfcd52454600fb7fa17ea4de450c856f99ab87f2d030694ede1779b8224f8ff4c757f4755b9bd3213c181ee97
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,5 +1,192 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v8.1.0
4
+
5
+ * **Instrumentation for Ruby standard library Logger**
6
+
7
+ The agent will now automatically instrument Logger, recording number of lines and size of logging output, with breakdown by severity.
8
+
9
+ * **Bugfix for Padrino instrumentation**
10
+
11
+ A bug was introduced to the way the agent installs padrino instrumentation in 7.0.0. This release fixes the issues with the padrino instrumentation. Thanks to @sriedel for bringing this issue to our attention.
12
+
13
+ * **Bugfix: Stop deadlocks between New Relic thread and Delayed Job sampling thread**
14
+
15
+ Running the agent's polling queries for the DelayedJobSampler within the same ActiveRecord connection decreases the frequency of deadlocks in development environments. Thanks @jdelStrother for bringing this to our attention and providing excellent sample code to speed up development!
16
+
17
+ * **Bugfix: Allow Net::HTTP request to IPv6 addresses**
18
+
19
+ The agent will no longer raise an `URI::InvalidURIError` error if an IPv6 address is passed to Net::HTTP. Thank you @tristinbarnett and @tabathadelane for crafting a solution!
20
+
21
+ * **Bugfix: Allow integers to be passed to error_collector.ignore_status_codes configuration**
22
+
23
+ Integers not wrapped in quotation marks can be passed to `error_collector.ignore_status_codes` in the `newrelic.yml` file. Our thanks goes to @elaguerta and @brammerl for resolving this issue!
24
+
25
+
26
+ ## v8.0.0
27
+
28
+ * **`add_method_tracer` refactored to use prepend over alias_method chaining**
29
+
30
+ 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:
31
+ - 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:
32
+ ```ruby
33
+ # OLD
34
+ add_method_tracer :foo, '#{args[0]}.#{args[1]}'
35
+
36
+ # NEW
37
+ add_method_tracer :foo, -> (*args) { "#{args[0]}.#{args[1]}" }
38
+ ```
39
+
40
+ - 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.
41
+
42
+ - 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.
43
+
44
+ See updated documentation on the following pages for full details:
45
+ - [Ruby Custom Instrumentation: Method Tracers](https://docs.newrelic.com/docs/agents/ruby-agent/api-guides/ruby-custom-instrumentation/#method_tracers)
46
+ - [MethodTracer::ClassMethods#add_method_tracer](https://rubydoc.info/github/newrelic/newrelic-ruby-agent/NewRelic/Agent/MethodTracer/ClassMethods#add_method_tracer-instance_method)
47
+
48
+
49
+ * **Distributed tracing is enabled by default**
50
+
51
+ [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/).
52
+
53
+ * **Bugfix: Incorrectly loading configuration options from newrelic.yml**
54
+
55
+ 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.
56
+
57
+ * **Cross Application is now deprecated, and disabled by default**
58
+
59
+ [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`
60
+
61
+ * **Update configuration option default value for `span_events.max_samples_stored` from 1000 to 2000**
62
+
63
+ 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).
64
+
65
+ * **Agent now enforces server supplied maximum value for configuration option `span_events.max_samples_stored`**
66
+
67
+ 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.
68
+
69
+ * **Remove Ruby 2.0 required kwarg compatibility checks**
70
+
71
+ 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.
72
+
73
+ * **Replace Time.now with Process.clock_gettime**
74
+
75
+ 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!
76
+
77
+ * **Updated generated default newrelic.yml**
78
+
79
+ 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.
80
+
81
+ * **Bugfix: Psych 4.0 causes errors when loading newrelic.yml**
82
+
83
+ 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.
84
+
85
+ * **Remove support for Excon versions below 0.19.0**
86
+
87
+ Excon versions below 0.19.0 will no longer be instrumented through the Ruby agent.
88
+
89
+ * **Remove support for Mongo versions below 2.1**
90
+
91
+ Mongo versions below 2.1 will no longer be instrumented through the Ruby agent.
92
+
93
+ * **Remove tests for Rails 3.0 and Rails 3.1**
94
+
95
+ 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.
96
+
97
+ * **Update test Gemfiles for patched versions**
98
+
99
+ 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.
100
+
101
+ * **Remove Merb Support**
102
+
103
+ 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.
104
+
105
+ * **Remove deprecated method External.start_segment**
106
+
107
+ The method `NewRelic::Agent::External.start_segment` has been deprecated as of Ruby Agent 6.0.0. This method is now removed.
108
+
109
+ * **Added testing and support for the following gem versions**
110
+
111
+ - activemerchant 1.121.0
112
+ - bunny 2.19.0
113
+ - excon 0.85.0
114
+ - mongo 2.14.0, 2.15.1
115
+ - padrino 0.15.1
116
+ - resque 2.1.0
117
+ - sequel 5.48.0
118
+ - yajl-ruby 1.4.1
119
+
120
+ * **This version adds support for ARM64/Graviton2 platform using Ruby 3.0.2+**
121
+
122
+
123
+ ## v7.2.0
124
+
125
+ * **Expected Errors and Ignore Errors**
126
+ This release adds support for configuration for expected/ignored errors by class name, status code, and message. The following configuration options are now available:
127
+ - `error_collector.ignore_classes`
128
+ - `error_collector.ignore_messages`
129
+ - `error_collector.ignore_status_codes`
130
+ - `error_collector.expected_classes`
131
+ - `error_collector.expected_messages`
132
+ - `error_collector.expected_status_codes`
133
+ For more details about expected and ignored errors, please see our [configuration documentation](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/)
134
+
135
+ * **Bugfix: resolves "can't add a new key into hash during iteration" Errors**
136
+
137
+ 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.
138
+
139
+ * **Bugfix: kwarg support fixed for Rack middleware instrumentation**
140
+
141
+ Thanks to @walro for submitting this fix. This fixes the rack instrumentation when using kwargs.
142
+
143
+ * **Update known conflicts with use of Module#Prepend**
144
+
145
+ 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'.
146
+
147
+ ## v7.1.0
148
+
149
+ * **Add support for CSP nonces when using our API to insert the browser agent**
150
+
151
+ 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.
152
+
153
+ * **Removed MD5 use in the SQL sampler**
154
+
155
+ 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.
156
+
157
+ * **Enable server-side configuration of distributed tracing**
158
+
159
+ `distributed_tracing.enabled` may now be set in server-side application configuration.
160
+
161
+ * **Bugfix: Fix for missing part of a previous bugfix**
162
+
163
+ 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.
164
+
165
+ * **Update known conflicts with use of Module#Prepend**
166
+
167
+ 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'.
168
+
169
+ * **Bugfix: Updated support for ActiveRecord 6.1+ instrumentation**
170
+
171
+ Previously, the agent depended on `connection_id` to be present in the Active Support instrumentation for `sql.active_record`
172
+ to get the current ActiveRecord connection. As of Rails 6.1, `connection_id` has been dropped in favor of providing the connection
173
+ object through the `connection` value exclusively. This resulted in datastore spans displaying fallback behavior, including showing
174
+ "ActiveRecord" as the database vendor.
175
+
176
+ * **Bugfix: Updated support for Resque's FORK_PER_JOB option**
177
+
178
+ Support for Resque's FORK_PER_JOB flag within the Ruby agent was incomplete and nonfunctional. The agent should now behave
179
+ correctly when running in a non-forking Resque worker process.
180
+
181
+ * **Bugfix: Added check for ruby2_keywords in add_transaction_tracer**
182
+
183
+ 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.
184
+
185
+ * **Confirmed support for yajl 1.4.0**
186
+
187
+ 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.
188
+
189
+
3
190
  ## v7.0.0
4
191
 
5
192
  * **Ruby Agent 6.x to 7.x Migration Guide Available**
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
@@ -21,6 +23,8 @@ Environments" section below.
21
23
 
22
24
  ## Installing and Using
23
25
 
26
+ The latest released gem for the Ruby Agent can be found at [Rubygems.org](https://rubygems.org/gems/newrelic_rpm)
27
+
24
28
  ### Quick Start
25
29
 
26
30
  #### With Bundler
@@ -131,6 +135,6 @@ The New Relic Ruby agent also uses source code from third-party libraries. Full
131
135
 
132
136
  Thank you, and may your application scale to infinity plus one.
133
137
 
134
- Lew Cirne, Founder and CEO
138
+ Lew Cirne, Founder
135
139
 
136
140
  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
@@ -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?