Welcome!

Ruby-On-Rails Authors: Liz McMillan, Pat Romanski, Elizabeth White, Hovhannes Avoyan, Yeshim Deniz

Related Topics: Ruby-On-Rails, Java IoT, Open Source Cloud, Machine Learning , Agile Computing, Cloud Security

Ruby-On-Rails: Article

Instrumenting Ruby on Rails with TraceView

In under 10 minutes

TraceView by AppNeta provides deep performance monitoring of web applications.

It gives you insight into your web application performance such as this:

and a per request drill-down that shows you the nitty gritty detail of where time is spent in individual requests (full-size):

and even end-user monitoring:

I run it on Gameface and PasswordPusher - it’s an essential tool in identifying problem areas, performance bottlenecks and simply poor performing code. (Read: ActionView)

Disclaimer: I authored the Ruby instrumentation for Traceview so I may be a bit biased. …but with good reason!

Installation
Installing TraceView consists of two parts: 1) installing the system daemon on your host and 2) installing the Ruby gem in your application.

Why a system daemon? TraceView uses a system daemon to collect instrumentation from sources beyond application code such as host metrics, Apache or Resque.

The system daemon is installed with two commands that can be pasted into your shell. An account specific version of these commands are available in your TraceView dashboard once you create an account. (Under Settings; App Configuration; Trace New Hosts)

And the gem for your application Gemfile available on RubyGems:

gem 'oboe'

Setup
TraceView functions by sampling a subset of all requests that go through your web application. This sample rate must be set at the entry point of requests in your application. This can be a load balancer, Apache/nginx or Ruby itself. Successive hosts and software stacks that requests pass through will act appropriately according to upstream settings.

Yes. That means requests can be traced across hosts, software stacks even track internal API calls via HTTP/SOAP/REST which make for spectacular application insight. But that’s another post for another time.

For this walkthrough we’re going to assume that you’re running a Ruby on Rails application with Unicorn, Thin, Puma or any other Rack based Ruby webserver.

To instead configure Apache/nginx as the entry point, see here.

Ruby as the Entry Point
If you set up Apache or nginx as your entry point then you can skip this part entirely. The oboe gem will take it’s tracing instructions from upstream automatically.

When the oboe gem is installed in your application, it makes available Oboe::Config which is a nested hash of configuration options that affect how your application is instrumented.

Luckily, the defaults are very smart and only a couple initial values need to be configured.

The two required values are:

Oboe::Config[:tracing_mode] = 'always'
Oboe::config[:sample_rate] = 100000  # 10% of incoming requests

These values enable tracing (:tracing_mode) and sets the sample rate to 10% (:sample_rate). The sample_rate is calculated by the value out of one million. e.g. 300000 would equal a 30% sample rate meaning 3 out of 10 requests would be sampled. (For low traffic sites, you may want to set these values higher.)

These values are usually set in a Rails initializer for Ruby on Rails. See the Optional Rails Initializer section on this page. A complete list of all configuration options for Oboe::Config is here.

Getting Performance Data
And that’s it. Now to the good stuff.

If you want to test that the oboe gem is functional, start-up a Rails console, you should see a message to stdout similar to:

Tracelytics oboe gem 1.4.0.2 successfully loaded.

Note that on hosts that don’t have the system daemon installed, the oboe gem disables itself and outputs a message to that fact.

Unsupported Tracelytics environment (no libs).  Going No-op.

Deploy/restart your application and you should start seeing traces show up in your TraceView dashboard after a couple minutes.

Summary
Installation and setup of TraceView for your application is a simple two step process that can be done in 10 minutes or less. Traceview gives a unique in-depth view into requests even as they cross hosts and software stacks.

Things are moving fast for the Ruby language instrumentation in TraceView. We already support tracing of memcache-client, memcached, dalli, mongo, moped, mongoid, mongomapper, cassandra, ActiveRecord (postgres, mysql, mysql2) plus more. Most recently we added support for Rack and Resque tracing. For a full-list of supported libraries, see the top of this article.

If you haven’t tried out TraceView yet, give it a run. You won’t be disappointed.

Extras: Some Random Chart Porn
A screenshot that I sent to Linode when performance unexpectedly dropped:

image

Linode migrated my VPS to a lesser utilized host with evident results (Thanks Linode):

image

An older issue that Gameface had with atrocious rendering times:

image

Related Articles:

Ruby 2.0 Released: Let The Tracing Begin!

AppNeta Rubygems Verified

Monitoring Background Jobs in Ruby’s Resque

More Stories By Peter Giacomo Lombardo

A Rubyist and Linux addict for over a decade, Peter mainly develops in Ruby and JavaScript (as well as PHP and Perl). He is the creator of numerous software tools and applications, most recently Password Pusher, a Ruby on Rails application to communicate passwords over the web and Gameface, a social networking platform for gamers using Rails 3. When he's not creating his own applications, he helps develop and maintain the infrastructure at OurStage and manages the Ruby community for AppNeta.

@ThingsExpo Stories
Elon Musk is among the notable industry figures who worries about the power of AI to destroy rather than help society. Mark Zuckerberg, on the other hand, embraces all that is going on. AI is most powerful when deployed across the vast networks being built for Internets of Things in the manufacturing, transportation and logistics, retail, healthcare, government and other sectors. Is AI transforming IoT for the good or the bad? Do we need to worry about its potential destructive power? Or will we...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Daiya Industry specializes in orthotic support systems and assistive devices with pneumatic artificial muscles in order to contribute to an extended healthy life expectancy. For more information, please visit https://www.daiyak...
SYS-CON Events announced today that SIGMA Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. uLaser flow inspection device from the Japanese top share to Global Standard! Then, make the best use of data to flip to next page. For more information, visit http://www.sigma-k.co.jp/en/.
SYS-CON Events announced today that B2Cloud will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. B2Cloud specializes in IoT devices for preventive and predictive maintenance in any kind of equipment retrieving data like Energy consumption, working time, temperature, humidity, pressure, etc.
SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp em...
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
SYS-CON Events announced today that Suzuki Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Suzuki Inc. is a semiconductor-related business, including sales of consuming parts, parts repair, and maintenance for semiconductor manufacturing machines, etc. It is also a health care business providing experimental research for...
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads. In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, will discuss how data centers of the future will be managed, how th...
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click. There is a large library of contributed nodes that help so...
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...