Announcing Grape Support
Ever since we launched Skylight for Rails and Sinatra apps, we've been getting requests for Grape support. Today we are pleased to announce that Grape is supported in the latest 0.8.0 version of the Skylight gem!
If you haven't heard about Grape, it's best described in its own words as "a REST-like API micro-framework for Ruby." Grape makes it super simple to add APIs to your existing Rails or Sinatra apps. Since it's based on Rack, you can also run it standalone.
If you're already a Grape user you just want to know how to get into it, let's jump in!
If you've upgraded to the most recent version of Grape (0.13.0 or higher) and you're running Rails, you don't have to do anything! Just upgrade your Skylight gem and you're all set.
If you're running an older version of Grape or are using it standalone or in Sinatra, follow the detailed instructions in our docs.
If all you wanted was to instrument your Grape app, you can stop reading now since I've already told you how :) But if you're curious about what we did to make Skylight work with Grape, keep reading.
How Skylight Instruments
To provide a little bit of background, Skylight has two main ways of instrumenting applications. The first, and preferred, solution is to hook into
AS::N is a nifty feature that's been a part of Rails for a while, but has gone unnoticed by many. The short explanation is that the library provides instrumentation hook points that are a no-op until someone starts watching. Once someone starts watching,
AS::N will report back timing and other relevant information.
AS::N is preferred because it requires no changes to the underlying library's code. All we have to do is run it through some "normalizers" in Skylight's internals and we have the information we need to give you pretty trace data.
The second option is a bit more of a brute force type solution, and we call it Probes. Probes are really just a somewhat normalized way for us to monkey patch existing code.
As we all know, monkey patching can be dangerous and it's not something we take lightly or do frequently. The demand for Grape support was growing though, and we worked carefully. You do what you gotta do, right?
As of version 0.12, Grape didn't contain any
AS::N hooks. This meant that we had to go the Probes route for instrumentation. We released the first beta with Probes support and it worked fine, but we wanted to do better.
AS::N is so lightweight, we believe it makes sense for most gems to include support. In Grape's case,
activesupport was already a dependency so there wasn't even a question of having to add additional gems. So, we went ahead and sent a PR to the Grape repo to add support for
AS::N. After a bit of back and forth, it was merged and released as part of Grape 0.13.
The best part of this, is that if you're running Grape 0.13+, we don't have to do any monkey patching. For users of earlier version of Grape, we still kept around our Probes code, which now, instead of instrumenting directly, patches in the
As always, we want to hear how things work out for you! Let us know if we're instrumenting what you want to see, both in Grape and elsewhere. We're constantly working on adding new features and your feedback helps us prioritize.
And, of course, if you hit any bugs or other issues, we want to know about that too. Just click the question mark in the bottom right corner of the app or shoot us an email at firstname.lastname@example.org.
We hope you enjoy using Skylight in your apps. Sign up today and your first 30-days are free. Or, refer a friend and you both get $50 in credit.