v8.0.0
add_method_tracer
refactored to use prepend over alias_method chainingThis release overhauls the implementation of
add_method_tracer
, as detailed in issue #502. The main breaking updates are as follows: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:# OLDadd_method_tracer :foo, '#{args[0]}.#{args[1]}'# NEWadd_method_tracer :foo, -> (*args) { "#{args[0]}.#{args[1]}" }Similarly, the
:code_header
and:code_footer
options toadd_method_tracer
will only accept a Proc object, which will be bound to the calling instance when the traced method is invoked.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 toadd_method_tracer
as an array.
See updated documentation on the following pages for full details:
Distributed tracing is enabled by default
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.
Bugfix: Incorrectly loading configuration options from newrelic.yml
The agent will now import the configuration options
error_collector.ignore_messages
anderror_collector.expected_messages
from thenewrelic.yml
file correctly.Cross Application is now deprecated, and disabled by default
Distributed tracing is replacing cross application tracing as the default means of tracing between services. To continue using it, enable it with
cross_application_tracer.enabled: true
anddistributed_tracing.enabled: false
Update configuration option default value for
span_events.max_samples_stored
from 1000 to 2000For more information about this congfiguration option, visit the Ruby agent documentation.
Agent now enforces server supplied maximum value for configuration option
span_events.max_samples_stored
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
sent from the New Relic servers.Remove Ruby 2.0 required kwarg compatibility checks
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.
Replace Time.now with Process.clock_gettime
Calls to
Time.now
have been replaced with calls toProcess.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!Updated generated default newrelic.yml
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.
Bugfix: Psych 4.0 causes errors when loading newrelic.yml
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.Remove support for Excon versions below 0.19.0
Excon versions below 0.19.0 will no longer be instrumented through the Ruby agent.
Remove support for Mongo versions below 2.1
Mongo versions below 2.1 will no longer be instrumented through the Ruby agent.
Remove tests for Rails 3.0 and Rails 3.1
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.
Update test Gemfiles for patched versions
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.
Remove Merb Support
This release removes the remaining support for the Merb 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.
Remove deprecated method External.start_segment
The method
NewRelic::Agent::External.start_segment
has been deprecated as of Ruby Agent 6.0.0. This method is now removed.Added testing and support for the following gem versions
- activemerchant 1.121.0
- bunny 2.19.0
- excon 0.85.0
- mongo 2.14.0, 2.15.1
- padrino 0.15.1
- resque 2.1.0
- sequel 5.48.0
- yajl-ruby 1.4.1
This version adds support for ARM64/Graviton2 platform using Ruby 3.0.2+
Support statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 5.4.0.347.
v7.2.0
Expected Errors and Ignore Errors This release adds support for configuration of expected/ignored errors by class name, status code, and message. The following configuration options are now available:
error_collector.ignore_classes
error_collector.ignore_messages
error_collector.ignore_status_codes
error_collector.expected_classes
error_collector.expected_messages
error_collector.expected_status_codes
For more details about expected and ignored errors, please see our configuration documentation
Bugfix: resolves "can't add a new key into hash during iteration" Errors
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.
Bugfix: kwarg support fixed for Rack middleware instrumentation
Thanks to @walro for submitting this fix. This fixes the rack instrumentation when using kwargs.
Update known conflicts with use of Module#Prepend
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'.
Support statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 5.2.0.345.
v7.1.0
Add support for CSP nonces when using our API to insert the Browser agent
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 methodbrowser_timing_header
to pass the nonce in and inject the script manually.Removed MD5 use in the SQL sampler
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.
Enable server-side configuration of distributed tracing
distributed_tracing.enabled
may now be set in server-side application configuration.Bugfix: Fix for missing part of a previous bugfix
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.
Update known conflicts with use of Module#Prepend
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'.Bugfix: Updated support for ActiveRecord 6.1+ instrumentation
Previously, the agent depended on
connection_id
to be present in the Active Support instrumentation forsql.active_record
to get the current ActiveRecord connection. As of Rails 6.1,connection_id
has been dropped in favor of providing the connection object through theconnection
value exclusively. This resulted in datastore spans displaying fallback behavior, including showing "ActiveRecord" as the database vendor.Bugfix: Updated support for Resque's FORK_PER_JOB option
Support for Resque's FORK_PER_JOB flag within the Ruby agent was incomplete and nonfunctional. The agent should now behave correctly when running in a non-forking Resque worker process.
Bugfix: Added check for ruby2_keywords in add_transaction_tracer
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.Confirmed support for yajl 1.4.0
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.
Support statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 5.2.0.345.
v7.0.0
Ruby Agent 6.x to 7.x Migration Guide Available
Please see our Ruby Agent 6.x to 7.x migration 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.
Ruby 2.0 and 2.1 dropped
Support for Ruby 2.0 and 2.1 dropped with this release. We do not know of code changes that would prevent the agent from continuing to work with these releases. However, Rubies 2.0 and 2.1 are no longer included in our test matrices and are not supported for 7.0.0 and onward.
Implemented prepend auto-instrumentation strategies for most Ruby gems/libraries
This release brings the auto-instrumentation strategies for most gems into the modern era for Ruby by providing both prepend and method-chaining (also known as method-aliasing) strategies for auto instrumenting. Prepend, which has been available since Ruby 2.0, is now the default strategy employed in auto-instrumenting. It's a known issue that some external gems lead to Stack Level too Deep exceptions when prepend and method-chaining are mixed. In such known cases, the auto-instrumenting strategy will fall back to method-chaining automatically.
This release also deprecates many overlapping and inconsistently named configuration settings in favor of being able to control behavior of instrumentation per library with one setting that can be one of auto (the default), disabled, prepend, or chain.
Please see the above-referenced migration guide for further details.
Removed SSL cert bundle
The agent will no longer ship this bundle and will rely on system certs.
Removed deprecated config options
The following config options were previously deprecated and are no longer available:
disable_active_record_4
disable_active_record_5
autostart.blacklisted_constants
autostart.blacklisted_executables
autostart.blacklisted_rake_tasks
strip_exception_messages.whitelist
Removed deprecated attribute
The attribute
httpResponseCode
was previously deprecated and replaced withhttp.statusCode
. This deprecated attribute has now been removed.Removed deprecated option in notice_error
Previously, the
:trace_only
option toNewRelic::Agent.notice_error
was deprecated and replaced with:expected
. This deprecated option has been removed.Removed deprecated API methods
Previously the API methods
create_distributed_trace_payload
andaccept_distributed_trace_payload
were deprecated. These have now been removed. Instead, please seeinsert_distributed_trace_headers
andaccept_distributed_trace_headers
, respectively.Bugfix: Prevent browser monitoring middleware from installing to middleware multiple times
In rare cases on jRuby, the BrowserMonitoring middleware could attempt to install itself multiple times at start up. This bug fix addresses that by using a mutex to introduce thread safety to the operation. Sinatra in particular can have this race condition because its middleware stack is not installed until the first request is received.
Skip constructing Time for transactions
Thanks to @viraptor, we are no longer constructing an unused Time object with every call to starting a new Transaction.
Bugfix: nil Middlewares injection now prevented and gracefully handled in Sinatra
Previously, the agent could potentially inject multiples of an instrumented middleware if Sinatra received many requests at once during start up and initialization due to Sinatra's ability to delay full startup as long as possible. This has now been fixed, and the Ruby agent correctly instruments only once as well as gracefully handles nil middleware classes in general.
Bugfix: Ensure transaction nesting max depth is always consistent with length of segments
Thanks to @warp for noticing and fixing the scenario where Transaction
nesting_max_depth
can get out of sync with segment length resulting in an exception when attempting to nest the initial segment which does not exist.
Support statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 4.8.0.
v6.15.0
Official Ruby 3.0 support
The Ruby agent has been verified to run on Ruby 3.0.0.
Added support for Rails 6.1
The Ruby agent has been verified to run with Rails 6.1. Special thanks to @hasghari for setting this up!
Added support for Sidekiq 6.0, 6.1
The Ruby agent has been verified to run with both 6.0 and 6.1 versions of sidekiq.
Bugfix: No longer overwrites sidekiq trace data
Distributed tracing data is now added to the job trace info rather than overwriting the existing data.
Bugfix: Fixes cases where errors are reported for spans with no other attributes
Previously, in cases where a span does not have any agent/custom attributes on it, but an error is noticed and recorded against the span, a
FrozenError: can't modify frozen Hash
is thrown. This is now fixed, and errors are now correctly recorded against such span events.Bugfix:
DistributedTracing.insert_distributed_trace_headers
Supportability metric now recordedPreviously, API calls to
DistributedTracing.insert_distributed_trace_headers
would lead to an exception about the missing supportability metric rather than flowing through the API implementation as intended. This would potentially lead to broken distributed traces, as the trace headers were not inserted on the API call.DistributedTracing.insert_distributed_trace_headers
now correctly records the supportability metric and inserts the distributed trace headers as intended.Bugfix: child completions after parent completes sometimes throws exception attempting to access nil parent
In scenarios where the child segment/span is completing after the parent in jRuby, the parent may have already been freed and no longer accessible. This would lead to attempting to calll
descendant_complete
on a nil object. This is fixed to protect against calling thedescendant_complete
in these cases.Feature: implements
force_install_exit_handler
config flagThe
force_install_exit_handler
configuration flag allows an application to instruct the agent to install its graceful shutdown exit handler. This sends any locally cached data to the New Relic collector before the application shuts down. This is useful when the primary framework has an embedded Sinatra application that is otherwise detected and skips installing the exit hook for graceful shutdowns.Default prepend_net_instrumentation to false
Previously,
prepend_net_instrumentation
defaulted totrue
. However, many gems are still using monkey patching on Net::HTTP, which causes compatibility issues with using prepend. Defaulting this tofalse
minimizes instances of unexpected compatibility issues.Infinite tracing adds additional data to connection metadata
Adds data from the agents connect response
request_headers_map
to the metadata for the connection to the infinite trace observer.
Support statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 4.8.0.
v6.14.0
Bugfix: Method tracers no longer cloning arguments
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.
Bugfix: Delayed Job instrumentation fixed for Ruby 2.7+
Previously, the agent was erroneousy separating positional and keyword arguments on the instrumented method calls into Delayed Job's library. The led to Delayed job not auto-instrumenting correctly and has been fixed.
Bugfix: Ruby 2.7+ methods sometimes erroneously attributed compiler warnings to the Agent's
add_method_tracer
The specific edge cases presented are now fixed by this release of the agent. There are still some known corner-cases that will be resolved with upcoming changes in next major release of the Agent. If you encounter a problem with adding method tracers and compiler warnings raised, please continue to submit small repoducible examples.
Bugfix: Ruby 2.7+ fix for keyword arguments on Rack apps is unnecessary and removed
A common fix for positional and keyword arguments for method parameters was implemented where it was not needed and led to RackApps getting extra arguments converted to keyword arguments rather than Hash when it expected one. This Ruby 2.7+ change was reverted so that Rack apps behave correctly for Ruby >= 2.7.
Feature: captures incoming and outgoing request headers for distributed tracing
HTTP request headers will be logged when log level is at least debug level. Similarly, request headers for exchanges with New Relic servers are now audit logged when audit logging is enabled.
Bugfix:
newrelic.yml.erb
added to the configuration search pathPreviously, when a user specifies a
newrelic.yml.erb
and nonewrelic.yml
file, the agent fails to find the.erb
file because it was not in the list of files searched at startup. The Ruby agent has long supported this as a means of configuring the agent programatically. Thenewrelic.yml.erb
filename is restored to the search path and will be utilized if present. NOTE:newrelic.yml
still takes precedence overnewrelic.yml.erb
If found, the.yml
file is used instead of the.erb
file. Search directories and order of traversal remain unchanged.Bugfix: dependency detection of Redis now works without raising an exception
Previously, when detecting if Redis was available to instrument, the dependency detection would fail with an Exception raised (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
.Bugfix: Gracefully handles NilClass as a Middleware Class when instrumenting
Previously, if a NilClass is passed as the Middleware Class to instrument when processing the middleware stack, the agent would fail to fully load and instrument the middleware stack. This fix gracefully skips over nil classes.
Memory Sampler updated to recognize macOS Big Sur
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.
Prepend implementation of Net::HTTP instrumentation available
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.
Support Statement
New Relic recommends that you upgrade the agent regularly and at a minimum every 3 months. As of this release, the oldest supported version is 4.5.0.
v6.13.1
Bugfix: obfuscating URLs to external services no longer modifying original URI
A recent change to the Ruby agent to obfuscate URIs sent to external services had the unintended side-effect of removing query parameters from the original URI. This is fixed to obfuscate while also preserving the original URI.
Thanks to @VictorJimenezKwast for pinpointing and helpful unit test to demonstrate.
v6.13.0
Bugfix: never use redirect host when accessing preconnect endpoint
When connecting to New Relic, the Ruby Agent uses the value in
Agent.config[:host]
to post a request to the New Relic preconnect endpoint. This endpoint returns a "redirect host" which is the URL to which agents send data from that point on.Previously, if the agent needed to reconnect to the collector, it would incorrectly use this redirect host to call the preconnect endpoint, when it should have used the original configured value in
Agent.config[:host]
. The agent now uses the correct host for all calls to preconnect.Bugfix: calling
add_custom_attributes
no longer modifies the params of the callerThe previous agent's improvements to recording attributes at the span level had an unexpected side-effect of modifying the params passed to the API call as duplicated attributes were deleted in the process. This is now fixed and params passed in are no longer modified.
Thanks to Pete Johns (@johnsyweb) for the PR that resolves this bug.
Bugfix:
http.url
query parameters spans are now obfuscatedPreviously, the agent was recording the full URL of the external requests, including the query and fragment parts of the URL as part of the attributes on the external request span. This has been fixed so that the URL is obfuscated to filter out potentially sensitive data.
Use system SSL certificates by default
The Ruby agent previously used a root SSL/TLS certificate bundle by default. Now the agent will attempt to use the default system certificates, but will fall back to the bundled certs if there is an issue (and log that this occurred).
Bugfix: reduce allocations for segment attributes
Previously, every segment received an
Attributes
object on initialization. The agent now lazily creates attributes on segments, resulting in a significant reduction in object allocations for a typical transaction.Bugfix: eliminate errors around Rake::VERSION with Rails
When running a Rails application with rake tasks, customers could see the following error:
Prevent connecting agent thread from hanging on shutdown
A bug in
Net::HTTP
's Gzip decoder can cause the (un-catchable) thread-kill exception to be replaced with a (catchable)Zlib
exception, which prevents a connecting agent thread from exiting during shutdown, causing the Ruby process to hang indefinitely. This workaround checks for anaborting
thread in the#connect
exception handler and re-raises the exception, allowing a killed thread to continue exiting.Thanks to Will Jordan (@wjordan) for chasing this one down and patching with tests.
Fix error messages about Rake instrumentation
When running a Rails application with rake tasks, customers could see the following error in logs resulting from a small part of rake functionality being loaded with the Rails test runner:
ERROR : Error while detecting rake_instrumentation:ERROR : NameError: uninitialized constant Rake::VERSIONSuch error messages should no longer appear in this context.
Thanks to @CamilleDrapier for pointing out this issue.
Remove NewRelic::Metrics
The
NewRelic::Metrics
module has been removed from the agent since it is no longer used.Thanks to @csaura for the contribution!
New Relic Ruby Agent Release Notes
v6.12.0
The New Relic Ruby agent is now open source under the Apache 2 license and you can now observe the project roadmap. See our Contributing guide and Code of Conduct for details on contributing!
Security: Updated all uses of Rake to >= 12.3.3
All versions of Rake testing prior to 12.3.3 were removed to address CVE-2020-8130. No functionality in the agent was removed nor deprecated with this change, and older versions of rake are expected to continue to work as they have in the past. However, versions of rake < 12.3.3 are no longer tested nor supported.
Bugfix: fixes an error capturing content length in middleware on multi-part responses
In the middleware tracing, the
Content-Length
header is sometimes returned as an array of values when content is a multi-part response. Previously, the agent would fail with "NoMethodError: undefined methodto_i
for Array" Error. This bug is now fixed and multi-part content lengths are summed for a total when anArray
is present.Added support for auto-instrumenting Mongo gem versions 2.6 to 2.12
Bugfix: MongoDB instrumentation did not handle CommandFailed events when noticing errors
The mongo gem sometimes returns a CommandFailed object instead of a CommandSucceeded object with error attributes populated. The instrumentation did not handle noticing errors on CommandFailed objects and resulted in logging an error and backtrace to the log file.
Additionally, a bug in recording the metric for "findAndModify" as all lowercased "findandmodify" for versions 2.1 through 2.5 was fixed.
Bugfix: Priority Sampler causes crash in high throughput environments in rare cases
Previously, the priority sampling buffer would, in rare cases, generate an error in high-throughput environments once capacity is reached and the sampling algorithm engages. This issue is fixed.
Additional transaction information applied to Spans
When distributed tracing and/or Infinite Tracing are enabled, the agent will now incorporate additional information from the Transaction event on to the root Span of the transaction.
The following items are affected:
- Custom attribute values applied to the Transaction via our add_custom_attributes API method.
- Request parameters:
request.parameters.*
- Request headers:
request.headers.*
- Response headers:
response.headers.*
- Resque job arguments:
job.resque.args.*
- Sidekiq job arguments:
job.sidekiq.args.*
- Messaging arguments:
message.*
httpResponseCode
(deprecated in this version; see note below)/http.statusCode
response.status
request.uri
request.method
host.displayName
Security recommendation
Review your Transaction attributes include and exclude configurations. Any attribute include or exclude settings specific to Transaction events should be applied to your Span attributes include and exclude configuration or your global attributes include and exclude configuration.
Agent attribute deprecation: httpResponseCode
Starting in this agent version, the agent attribute
httpResponseCode
(string value) has been deprecated. Customers can begin usinghttp.statusCode
(integer value) immediately, andhttpResponseCode
will be removed in the agent's next major version update.Bugfix: Eliminate warnings for distributed tracing when using sidekiq
Previously, using sidekiq with distributed tracing disabled resulted in warning messages\
WARN : Not configured to accept distributed trace headers
\WARN : Not configured to insert distributed trace headers
\ These messages no longer appear.
New Relic Ruby Agent Release Notes
v6.11.0
Infinite Tracing
This release adds support for Infinite Tracing. Infinite Tracing observes 100% of your distributed traces and provides visualizations for the most actionable data. With Infinite Tracing, you get examples of errors and long-running traces so you can better diagnose and troubleshoot your systems.
Configure your agent to send traces to a trace observer in New Relic Edge. View distributed traces through New Relic’s UI. There is no need to install a collector on your network.
Infinite Tracing is currently available on a sign-up basis. If you would like to participate, please contact your sales representative.
Bugfix: Cross Application Tracing (CAT) adds a missing field to response
Previously, the CAT header was missing a reserved field that would lead to an error in the Go Agent's processing of incoming headers from the Ruby Agent. This fix adds that missing field to the headers.
Bugfix: Environment Report now supports Rails >= 6.1
The API changed for how database connections are accessed in Rails versions starting with 6.1 to support multiple database feature. The Environment report was enhanced to use the Rails >= 6.1 API with fallback to old API when that fails.
Thanks to Sébastien Dubois (sedubois) for reporting this issue and contribution!
Bugfix: Eliminate warnings appearing when using
add_method_tracer
with Ruby 2.7Previously, using
add_method_tracer
with Ruby 2.7 to trace a method that included keyword arguments resulted in warning messages:warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
. These messages no longer appear.Thanks to Harm de Wit and Atsuo Fukaya for reporting the issue!
Added distributed tracing to Sidekiq jobs
Thanks to andreaseger for the contribution!