Minimal example of configuring the New Relic Ruby agent to use method chaining for Redis instrumentation
The New Relic Ruby agent has instrumentation support for the redis Rubygem.
By default, the agent will instrument redis
in "auto" mode and automatically decide whether to use method prepending or method chaining. The "auto" mode will opt for the use of method prepending unless it detects a condition known to cause a conflict. To explicitly use "chain" mode to force method chaining, the newrelic.yml
configuration file can be given the following entry:
instrumentation.redis: chain
NOTE that redis
must be required prior to New Relic's attempts to instrument it. If a defined?(Redis)
check fails when the New Relic agent looks for libraries to instrument, it will skip redis
.
This content exists to demonstrate having the New Relic Ruby agent use method chaining to instrument redis
with as little content as possible.
In an empty directory that you have write permission to, store the redis.rb
and newrelic.yml
files from this gist.
Next, make sure that no "NEW_RELIC" based environment variables are set.
With Ruby installed and ruby
in your PATH, run the redis.rb
script:
ruby ./redis.rb
This should create a new log
subdirectory with a newrelic_agent.log
log file inside. This log file should contain an entry stating that method chaining was used to instrument the redis
Rubygem.
You may use grep
to confirm this:
grep Redis log/newrelic_agent.log
[DEMO] INFO : Installing Redis Instrumentation
[DEMO] INFO : Installing New Relic supported Redis instrumentation using MethodChaining