Monitor Sinatra performance with OpenTelemetry

Sinatra is a powerful and flexible micro web framework built with Ruby. It allows to quickly create web applications in Ruby with minimal effort.

This article explains how you can monitor and optimize Sinatra performance using OpenTelemetry observability framework.

What is OpenTelemetry?

OpenTelemetryopen in new window is an open-source observability framework hosted by Cloud Native Computing Foundation. It is a merger of OpenCensus and OpenTracing projects.

OpenTelemetry aims to provide a single standard across all types of observability signals such as OpenTemetry tracingopen in new window, and OpenTelemetry metricsopen in new window.

OpenTelemetry specifies how to collect and send telemetry data to backend platforms. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation.

OpenTelemetry is available for most programming languages and provides interoperability across different languages and environments.

Sinatra instrumentation

To instrument Sinatra app, you need a corresponding Sinatra OpenTelemetry instrumentation:

gem install opentelemetry-instrumentation-sinatra

If you use bundler, add opentelemetry-instrumentation-sinatra to your Gemfile.

Getting started

To get started, call use with the name of the instrumentation:

require 'uptrace'
require 'opentelemetry-instrumentation-sinatra'

Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.use 'OpenTelemetry::Instrumentation::Sinatra
end

Alternatively, you can call use_all to install all available instrumentations:

require 'uptrace'
require 'opentelemetry-instrumentation-sinatra'

Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.use_all
end

What is Uptrace?

Uptrace is an open source APMopen in new window for OpenTelemetry that helps developers pinpoint failures and find performance bottlenecks. Uptrace can process billions of spans on a single server and allows to monitor your software at 10x lower cost.

You can get startedopen in new window with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.

What's next?

Next, instrumentopen in new window more operations, for example, database queries and network calls. You can also learn about OpenTelemetry Ruby APIopen in new window to create your own instrumentations.

Popular instrumentations:

Last Updated: