Community Blog
Get the latest updates on the Splunk Community, including member experiences, product education, events, and more!

Get Started With the Splunk Distribution of OpenTelemetry Ruby

Splunk Employee
Splunk Employee

This blog post is part of an ongoing series on OpenTelemetry.

The Splunk Distribution of OpenTelemetry Ruby has recently hit version 1.0. The distribution provides a Ruby gem for reporting distributed traces to Splunk APM using the Ruby OpenTelemetry SDK.

The distribution comes with the following defaults:

If you're currently using the SignalFx Tracing Library for Node and want to migrate to the Splunk Distribution of OpenTelemetry Node, see Migrate from the SignalFx Tracing Library for Ruby.

The instrumentation works with Ruby version 2.7 and higher. Supported libraries are listed here.

Install and Configure the Distribution

Install the gem by adding it to your project's Gemfile:



gem "splunk-otel", "~> 1.0"



You can also use bundle:



bundle add splunk-otel --version "~> 1.0"



Then, configure the OpenTelemetry SDK using the Splunk::Otel module from splunk/otel:



require "splunk/otel"





Send Data Directly to Splunk Observability Cloud

To send traces directly to Splunk Observability Cloud, you need to:

  1. Set SPLUNK_REALM to your Splunk APM realm (for example, us0).
  2. Set the SPLUNK_ACCESS_TOKEN to your Splunk Observability Cloud access token.

These environment variables configure the OpenTelemetry Ruby exporter to send traces to https://ingest<.<realm> using the given access token for authorization.

Automatically Instrument an Application

You can instrument many Ruby libraries without code changes. 

Include the gem opentelemetry-instrumentation-all in your Gemfile:



gem "opentelemetry-instrumentation-all", "~> 0.28"



This instruments any supported library in your project. Check the dependencies of opentelemetry-instrumentation-all to see what libraries are supported.

To enable the autoinstrumentations, pass auto_instrument:true to the configure method of Splunk::Otel. For example:



require "splunk/otel"

Splunk::Otel.configure(auto_instrument: true)



Correlate Traces and Logs

The Splunk Distribution includes a function, format_correlation that injects the current trace context into your logs using the standard Ruby logging formatter.: For example:



require "splunk/otel"

logger.formatter = proc do |severity, datetime, progname, msg|  
  "#{Splunk::Otel::Logging.format_correlation} : #{msg}\n"



The trace context allows you to correlate traces with log events in Observability Cloud.

Where to go Next

More details on how to instrument your Ruby application can be found in the Splunk documentation and on the OpenTelemetry website in the Ruby documentation.


For troubleshooting issues with the Splunk Distribution of OpenTelemetry Ruby, see Troubleshooting.

What Does This Mean for Splunk Customers?

Splunk is a contributor to OpenTelemetry and is committed to accelerating the adoption of the project. For more information about Splunk and OpenTelemetry, you can check out our latest OpenTelemetry blog posts.

— Tristan Sloughter, Senior Software Engineer

Get Updates on the Splunk Community!

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...