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 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"
…
Splunk::Otel.configure
To send traces directly to Splunk Observability Cloud, you need to:
These environment variables configure the OpenTelemetry Ruby exporter to send traces to https://ingest<.<realm>.signalfx.com/v2/trace/otlp using the given access token for authorization.
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)
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"
end
The trace context allows you to correlate traces with log events in Observability Cloud.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.