Ruby Release Notes

Notes

Initialize New Relic Agent before config initializers

When running in a Rails environment, the agent registers an initializer that
starts the agent. This initializer is now defined to run before config/initializers.
Previously, the ordering was not specified for the initializer. This change
guarantees the agent will started by the time your initializers run, so you can
safely reference the Agent in your custom initializers. Thanks to Tony Ta for
the contribution.

Ruby 2.5 Support

The Ruby Agent has been verified to run under Ruby 2.5.

request.uri Collected as an Agent Attribute

Users can now control the collection of request.uri on errors and transaction
traces. Previously it was always collected without the ability to turn it off.
It is now an agent attribute that can be controlled via the attributes config.
For more information on agent attributes see here.

Notes

Bugfix for Manual Browser Instrumentation

There was a previous bug that required setting both rum.enabled: false and
browser.auto_instrument: false to completely disable browser monitoring. An
attempt to fix this in 4.7.0 resulted in breaking manual browser
instrumentation. Those changes have been reverted. We will revisit this issue
in an upcoming release.

Notes

Expected Error API

The agent now sends up error.expected as an intrinsic attribute on error
events and error traces. When you pass expected: true to the notice_error
method, both Insights and APM will indicate that the error is expected.

Typhoeus Hydra Instrumentation

The agent now has request level visibility for HTTP requests made using
Typhoeus Hydra.

Total Time Metrics are Recorded

The agent now records Total Time metrics. In an application where segments
execute concurrently, the total time can exceed the wall-clock time for a
transaction. Users of the new Typhoeus Hydra instrumentation will notice
this as changes on the overview page. Immediately after upgrading there
will be an alert in the APM dashboard that states: "There are both old and
new time metrics for this time window". This indicates that during that time
window, some transactions report the total time metrics, while others do not.
The message will go away after waiting for enough time to elapse and / or
updating the time window.

Add :message category to set_transaction_name public API method

The agent now permits the :message category to be passed into the public
API method set_transaction_name, which will enable the transaction to be
displayed as a messaging transaction.

Create prepend_active_record_instrumentation config option

Users may now set the prepend_active_record_instrumentation option in
their agent config to install Active Record 3 or 4 instrumentation using
Module.prepend rather than alias_method.

Use Lazy load hooks for ActionController::Base and ActionController::API

The agent now uses lazy load hooks to hook on ActionController::Base and
ActionController::API. Thanks Edouard Chin for the contribution!

Use Lazy load hooks for ActiveRecord::Base and ActiveRecord::Relation

The agent uses lazy load hooks when recording supportability metrics
for ActiveRecord::Base and ActiveRecord::Relation. Thanks Joseph Haig
for the contribution!

Check that Rails::VERSION is defined instead of just Rails

The agent now checks that Rails::VERSION is defined since there are cases
where Rails is defined but Rails::VERSION is not. Thanks to Alex Riedler
and nilsding for the contribution!

Support fast RPC/direct reply-to in RabbitMQ

The agent can now handle the pseudo-queue 'amq.rabbitmq.reply-to' in its
Bunny instrumentation. Previously, using fast RPC led to a NoMethodError
because the reply-to queue was expected to be a Queue object instead of
a string.

Notes

The agent now sends synthetics headers whenever they are received from an
external request, even if cross-application tracing is disabled.

Bugfix for DelayedJob Daemonization

Customers using the delayed_job script that ships with the gem may encounter
an IOError with a message indicating the stream was closed. This was due to
the agent attempting to write a byte into a Pipe that was closed during the
deamonization of the delayed_job script. This issue has been fixed.

Collect supportability metrics for public API

The agent now collects Supportability/API/{method} metrics to track usage of
all methods in the agent's public API.

Collect supportability metrics on Module#prepend

The agent now collects Supportability/PrependedModules/{Module} metrics
for ActiveRecord 4 and 5, ActionController 4 and 5, ActionView 4 and 5,
ActiveJob 5, and ActionCable 5. These help track the adoption of the
Module#prepend method so we can maintain compatibility with newer versions
of Ruby and Rails.

Collect explain plans when using PostGIS ActiveRecord adapter

The agent will now collect slow SQL explain plans, if configured to, on
connections using the PostGIS adapter. Thanks Ari Pollak for the contribution!

Lazily Intialize New Relic Config

The agent will lazily initialize the New Relic config. This allows the agent
to pickup configuration from environment variables set by dotenv and similar
tools.

Notes

Include test helper for 3rd party use

In 4.2.0, all test files were excluded from being packaged in the gem. An
agent class method NewRelic::Agent.require_test_helper was used by 3rd
party gem authors to test extensions to the agent. The required file is now
included in the gem.

Collect cloud metadata from Azure, GCP, PCF, and AWS cloud platform

The agent now collects additional metadata when running in AWS, GCP, Azure, and
PCF. This information is used to provide an enhanced experience when the agent
is deployed on those platforms.

Install at_exit hook when running JRuby

The agent now installs an at_exit hook when running JRuby, which wasn't
done before because of constraints related to older JRuby versions that
are no longer supported.

User/Utilization and System/Utilization metrics not recorded after Resque forks

The agent no longer records invalid User/Utilization and System/Utilization
metrics, which can lead to negative values, in forks of Resque processes.

Add identifier field to agent connect settings

The agent now includes a unique identifier in its connect settings, ensuring
that when multiple agents connect to multiple different apps, data are reported
for each of the apps.

Clear transaction state after forking now opt-in

The agent waits to connect until the first web request when it detects it's
running in a forking dispatcher. When clearing the transaction state in this
situation we lose the first frame of the transaction and the subsequent
trace becomes corrupted. We've made this feature opt-in and is turned off by
default. This behavior only affects the first transaction after a dispatcher
forks.

v4.3.0

Instrumentation for the Bunny AMQP Client

The Bunny AMQP Client is now automatically instrumented. The agent will
report data for messages sent and received by an application. Data on messages
is available in both APM and Insights. Applications connected through a
RabbitMQ exchange will now also be visible on Service Maps as part of Cross
Application Tracing. See the message queues documentation page
for more details.

Safely normalize external hostnames

The agent has been updated to check for nil host values before downcasing the
hostname. Thanks Rafael Valério for the contribution!

PageView events will not be generated for ignored transactions

The agent now checks if transaction is ignored before injecting the New Relic
Browser Agent. This will prevent PageView events from being generated for
ignored transactions.

Datastores required explicitly in agent

The agent has been modified to explicity require the Datastores module
whereas previously there were situations where the module could be
implicitly defined. Thanks Kevin Griffin for the contribution!

Clear transaction state after forking

Previously, if a transaction was started and the process forks, the transaction
state survived the fork and #after_fork call in thread local storage. Now,
this state is cleared by #after_fork.

Postgis adapter reports as Postgres for datastores

The agent now maps the Postgis adapter to Postgres for datastore metrics.
Thanks Vojtěch Vondra for the contribution!

Deprecate :trace_only option

The NewRelic::Agent.notice_error API has been updated to deprecate the
:trace_only option in favor of :expected.

v4.1.0

The Ruby Agent's Developer Mode, which provided a very limited view of your
application performance data, has been removed. For more information, check
out our community forum.

Support NEW_RELIC_ENV for Rails apps

Previously, users could set the agent environment with NEW_RELIC_ENV only
for non-Rails apps. For Rails app, the agent environment would use whatever
the Rails environment was set to. Now, NEW_RELIC_ENV can also be used for
Rails apps, so that it is possible to have an agent environment that is
different from the Rails environment. Thanks Andrea Campolonghi for the
contribution, as well as Steve Schwartz for also looking into this issue!

Normalization of external hostnames

Hostnames from URIs used in external HTTP requests are now always downcased
to prevent duplicate metrics when only case is different.

v4.0.0

Require Ruby 2.0.0+

The agent no longer supports Ruby versions prior to 2.0, JRuby 1.7 and
earlier, and all versions of Rubinius. Customers using affected Rubies
can continue to run 3.x agent versions, but new features or bugfixes
will not be published for 3.x agents. For more information, check out our
community forum.

OkJson vendored library removed

Ruby 1.8 did not include the JSON gem by default, so the agent included a
vendored version of OkJson that it would fall
back on using in cases where the JSON gem was not available. This has been
removed.

YAJL workaround removed

yajl-ruby versions prior to 1.2 had
the potential to cause a segmentation fault when working large, deeply-nested
objects like thread profiles. If you are using yajl-ruby with the JSON
monkey patches enabled by requiring yajl/json_gem, you should upgrade to
at least version 1.2.

Deprecated APIs removed

Agent.abort_transaction!

Agent.add_custom_parameters

Agent.add_request_parameters

Agent.browser_timing_footer

Agent.get_stats

Agent.get_stats_no_scope

Agent.record_transaction

Agent.reset_stats

Agent.set_user_attributes

Agent::Instrumentation::Rack

ActionController#newrelic_notice_error

ActiveRecordHelper.rollup_metrics_for (may be incompatible with newrelic_moped)

The agent no longer deletes deprecated keys passed to add_method_tracer. Passing
in deprecated keys can cause an exception. Ensure that you are not passing any of
the following keys: :force, :scoped_metric_only, :deduct_call_time_from_parent
to add_method_tracer.

The agent no longer deletes deprecated keys passed in as options to
NewRelic::Agent.notice_error. If you are passing any of these deprecated
keys: :request_params, :request, :referer to the notice_error API, please
delete them otherwise they will be collected as custom attributes.

Error handling changes

The agent now only checks for original_exception in environments with Rails
versions prior to 5. Checking for Exception#cause has been removed. In addition,
the agent now will match class name with message and backtrace when noticing
errors that have an original_exception.

v3.18.1

Ensure Mongo aggregate queries are properly obfuscated

Instrumentation for the Mongo 2.x driver had a bug where the pipeline
attribute of Mongo aggregate queries was not properly obfuscated. Users
who have sensitive data in their aggregate queries are strongly encouraged
to upgrade to this version of the agent. Users who are unable to upgrade are
encouraged to turn off query collection using by setting
mongo.capture_queries to false in their newrelic.yml files.

v3.18.0

Ruby 2.4.0 support

The agent is now tested against the official release of ruby 2.4.0,
excluding incompatible packages.

Agent-based metrics will not be recorded outside of active transactions

The agent has historically recorded metrics outside of a transaction. In
practice, this usually occurs in applications that run background job
processors. The agent would record metrics for queries the
background job processor is making between transactions. This can lead
to display issues on the background overview page and the presence of
metrics generated by the background job processor can mask the application
generated metrics on the database page. The agent will no longer generate
metrics outside of a transaction. Custom metrics recorded using
NewRelic::Agent.record_metric will continue to be recorded regardless
of whether there is an active transaction.

Include ControllerInstrumentation module with ActiveSupport.on_load

The agent will now use the on_load :action_controller hook to include
the ControllerInstrumentation module in to both the Base and API
classes of ActionController for Rails 5. This ensures that the proper
load order is retained, minimizing side-effects of having the agent in
an application.

Ensure values for revisions on Capistrano deploy notices

Previously, running the task to look up the changelog could
generate an error, if there weren't previous and current revisions
defined. This has now been fixed. Thanks Winfield Peterson for the
contribution!

External Segment Rewrites

The agent has made internal changes to how it represents segments for
external web requests.

v3.17.2

Our Sinatra instrumentation has been updated to work with Sinatra
2.0.0.beta2.

Include controller instrumentation module in Rails 5 API

The agent now includes the ControllerInstrumentation module into
ActionController::API. This gives Rails API controllers access to
helper methods like newrelic_ignore in support of the existing
event-subscription-based action instrumentation. Thanks Andreas
Thurn for the contribution!

Use Module#prepend for ActiveRecord 5 Instrumentation

Rails 5 deprecated the use of alias_method_chain in favor of using
Module#prepend. Mixing Module#prepend and alias_method_chain
can lead to a SystemStackError when an alias_method_chain is
applied after a module has been prepended. This should ensure
better compatibility between our ActiveRecord Instrumentation and
other third party gems that modify ActiveRecord using Module#prepend.

Use license key passed in to NewRelic::Agent.manual_start

Previously, the license key passed in when manually starting the agent
with NewRelic::Agent.manual_start was not referenced when setting up
the connection to report data to New Relic. This is now fixed.

Account for DataMapper database connection errors

Our DataMapper instrumentation traces instances of DataObjects::SQLError
being raised and removes the password from the URI attribute. However,
when DataObjects cannot connect to the database (ex: could not resolve
host), it will raise a DataObjects::ConnectionError. This inherits from
DataObjects::SQLError but has nil for its URI attribute, since no
connection has been made yet. To avoid the password check here on nil,
the agent catches and re-raises any instances of DataObjects::ConnectionError
explicitly. Thanks Postmodern for this contribution!

Account for request methods that require arguments

When tracing a transaction, the agent tries to get the request object
from a controller if it wasn't explicitly passed in. However, this posed
problems in non-controller transactions with their own request methods
defined that required arguments, such as in Resque jobs. This is now fixed.

v3.17.1

Datastore instance reporting for Redis, MongoDB, and memcached

The agent now collects datastore instance information for Redis, MongoDB,
and memcached. This information is displayed in transaction traces and slow
query traces. For memcached only, multi requests will expand to individual
server nodes, and the operation and key(s) will show in the trace details
"Database query" section. Metrics for get_multi nodes will change slightly.
Parent nodes for a get_multi will be recorded as generic segments. Their
children will be recorded as datastore segments under the name
get_multi_request and represent a batch request to a single Memcached
instance.

Rescue errors from attempts to fetch slow query explain plans

For slow queries through ActiveRecord 4+, the agent will attempt to fetch
an explain plan on SELECT statements. In the event that this causes an
error, such as being run on an adapter that doesn't implement exec_query,
the agent will now rescue and log those errors. n

Notes

Add :trace_only option to notice_error API

Previously, calling notice_error would record the trace, increment the
error count, and consider the transaction failing for Apdex purposes. This
method now accepts a :trace_only boolean option which, if true, will only
record the trace and not affect the error count or transaction.

HTTP.rb support

The agent has been updated to add instrumentation support for the HTTP gem,
including Cross Application Tracing. Thanks Tiago Sousa for the contribution!

Prevent redundant Delayed::Job instrumentation installation

This change was to handle situations where multiple Delayed::Worker instances
are being created but Delayed::Job has already been instrumented. Thanks Tony
Brown for the contribution!

v3.16.2

Fix for "Unexpected frame in traced method stack" errors

Our ActiveRecord 4.x instrumentation could have generated "Unexpected frame in
traced method stack" errors when used outside of an active transaction (for
example, in custom background job handlers). This has been fixed.

v3.16.1

The agent's internal tracing of datastore segments has been rewritten, and
instrumentation updated to utilize the new classes.

Fix Grape endpoint versions in transaction names

Grape 0.16 changed Route#version (formerly #route_version) to possibly return
an Array of versions for the current endpoint. The agent has been updated to
use rack.env['api.version'] set by Grape, and fall back to joining the version
Array with '|' before inclusion in the transaction name when api.version is
not available. Thanks Geoff Massanek for the contribution!

Fix deprecation warnings from various Rails error subclasses

Rails 5 deprecates #original_exception on a few internal subclasses of
StandardError in favor of Exception#cause from Ruby stdlib. The agent has
been updated to try Exception#cause first, thus avoiding deprecation
warnings. Thanks Alexander Stuart-Kregor for the contribution!

Fix instrumentation for Sequel 4.35.0

The latest version of Sequel changes the name and signature of the method
that the Ruby Agent wraps for instrumentation. The agent has been updated
to handle these changes. Users using Sequel 4.35.0 or newer should upgrade
their agent.

Fix DataMapper instrumentation for additional versions

Different versions of DataMapper have different methods for retrieving the
adapter name, and Postmodern expanded our coverage. Thanks for the
contribution!

This change allows the oracle_enhanced adapter to use the same
obfuscation as oracle adapters. Thanks Dan Drinkard for the contribution!

Make it possible to define a newrelic_role for deployment with Capistrano 3

Thanks NielsKSchjoedt for the contribution!

Retry initial connection to New Relic in Resque master if needed

Previously, if the initial connection to New Relic in a monitored Resque
master process failed, the agent would not retry, and monitoring for the
process would be lost. This has been fixed, and the agent will continue
retrying in its background harvest thread until it successfully connects.

v3.15.2

Run explain plans on parameterized slow queries in AR4

In our ActiveRecord 4 instrumentation, we moved to tracing slow queries
using the payloads from ActiveSupport::Notifications sql.active_record
events. As a result, we were unable to run explain plans on parameterized
queries. This has now been updated to pass along and use the parameter values,
when available, to get the explain plans.

Fix getMore metric grouping issue in Mongo 2.2.x instrumentation

A metric grouping issue had cropped up when using the most recent Mongo gem
(2.2.0) with the most recent release of the server (3.2.4). We now have a more
future-proof setup for preventing these.

Restore older DataMapper support after password obfuscation fix

Back in 3.14.3, we released a fix to avoid inadvertently sending sensitive
information from DataMapper SQLErrors. Our implementation did not account for
DataMapper versions below v0.10.0 not implementing the #options accessor.
Thanks Bram de Vries for the fix to our fix!

Padrino 0.13.1 Support

Users with Padrino 0.13.x apps were previously seeing the default transaction
name "(unknown)" for all of their routes. We now provide the full Padrino
route template in transaction names, including any parameter placeholders.
Thanks Robert Schulze for the contribution!

Update transaction naming for Grape 0.16.x

In Grape 0.16.x, route_ methods are no longer prefixed. Thanks to Daniel
Doubrovkine for the contribution!

Fix name collision on method created for default metric name fix

We had a name collision with the yard gem, which sets a class_name method
on Module. We've renamed our internal method to derived_class_name instead.