Monitoring Ruby

The instana gem provides automated code instrumentation for supported technologies, zero configuration health monitoring of Ruby instances, and end-to-end traces of requests across all systems.

Supported runtimes, frameworks and libraries

For more information, see the dedicated Ruby supported version documentation.

Runtime metrics

  • Ruby Version
  • Runtime Arguments
  • Framework
  • Gem Bundle
  • Time Spent in GC
  • Memory Usage
  • Heap Slots
  • Threads

Installation

The gem is available on Rubygems. To install, add this line to the end of your application's Gemfile:

gem 'instana'

And then execute:

bundle

Or install it yourself as:

gem install instana

If you encounter Bundler::HTTPError Could not fetch specs from # https://rubygems.org/ or Gem::RemoteFetcher::UnknownHostError timed out error when you run the bundle command, then try to disable IPv6 to fix the error.

Tracer logs

At require time, the library will output:

Stan is on the scene.  Starting Instana instrumentation version X.X.X.

Once the agent has made a connection to the host agent, it will output:

Host agent available. We're in business.

Other log messages may appear and indicate an error state. Refer to the Troubleshooting section for more details.

Platforms

Kubernetes

The Instana AutoTrace webhook is an implementation of a Kubernetes Mutating webhook Admission Controller that automatically sets up everything that is required to monitor Ruby applications with Instana, across an entire Kubernetes cluster.

If you elect to install the Instana AutoTrace webhook on your Kubernetes clusters, you have no need to perform any manual step to trace any of your Ruby applications running in those clusters.

For Kubernetes (and other container based deployments), the Instana Ruby gem requires an ip binary available (such as from the iproute2 OS package). This requirement will be removed in a future version.

Cloud Foundry

The standard installation method methods also works on Cloud Foundry using the Cloud Foundry Ruby Buildpack. Additionally, since the Tile version 1.177.0, the instana_buildpack automates the setup of Ruby applications on Cloud Foundry. For more information, refer to the Instana Buildpack documentation.

Configuration

Although the gem has no configuration required for out of the box metrics and distributed tracing, individual components can be configured as needed. See the Ruby configuration page for more information.

Software Development Kits

The Instana gem supports a native software development kit and the OpenTracing sdk.

Instana native SDK

OpenTracing

Troubleshooting

Ruby sensor not installed

Monitoring issue type: ruby_sensor_not_installed

The Instana AutoTrace webhook is not installed and the Ruby process does not include the instana Ruby gem, or the Ruby sensor cannot communicate with the Instana host agent.

To activate the Instana monitoring for Ruby, refer to the Installation section. If you are sure that either the Instana AutoTrace webhook or the Ruby gem is correctly installed, troubleshoot this issue by following the steps in Ruby Process doesn't show up in dashboard for the Instana Ruby sensor.

Verify the process is instrumented

If you are using the Instana AutoTrace webhook and the Ruby sensor is active, you can see the following line in your application's logs:

AutoTracing for Ruby is starting on version #<version>

If you do not see this line in your application's logs, then the setup is not correct. For more information about the correct setup, see Instana AutoTrace webhook.

If you are doing manual instrumentation, make sure that the instana gem is installed in your application and is active. If the Ruby sensor is active, you will see the following entries in your application's logs:

Stan is on the scene.  Starting Instana instrumentation version #<version>

If you do not see this log, then the setup is not correct. Please refer to the Installation documentation.

If you do see the log message above, then it is very likely a network connectivity issue with the host agent, see the next section.

Verify the tracer can connect to the host agent

If the Ruby tracer is installed (refer to he previous section), verify that the Ruby process can connect to the host agent on the same host on port 42699. For more information on the required network visibility, refer to the Network requirements documentation for the Instana host agent.

What we see increasingly often, is that in containerized platforms either there are network visibility issues between the container with the application to be traced and the container of the Instana host agent; another issue of the same kind, due to some overlay network setup, the container of the application to be traced does not connect to the Instana agent container on the same host.

Often the problem is that the Ruby tracer is using the wrong ip address or DNS name to talk to the Instana agent. You can instruct the Ruby tracer to user a specific network address via the INSTANA_AGENT_HOST environment-variable.

In very few cases, we have seen customers that set up their networking so that the problem was not the network address, but the port the tracer uses. In case you need a port remapping, because the host agent does not listen on port 42699 but something else, you can instruct the tracer to use a different port via the INSTANA_AGENT_PORT environment variable.

In case none of the above helps you troubleshoot the issue, open a Support Ticket.

Interactions with other instrumentation and monitoring libraries

As of the 194 release, the instana gem uses prepend instead of alias chaining to allow it to work along side of instrumentation and monitoring libraries. This means that if multiple libraries prepend their instrumentation to a target method, the instrumentation will fire sequence.

If you need to explicitly alias-chain a method that is instrumented by the instana gem or you are using a library that does the alias chaining for you, then the explicit alias-chaining or the loading of the library that does the alias chaining, needs to happen after the instana gem is loaded. Otherwise, the instana instrumentation doesn't function.

Other issues

Seeing something unexpected or having trouble trying to configure something? See the Ruby Troubleshooting page for help.

GitHub

Instana Ruby Github Repository