Instrument your Ruby application for Splunk Observability Cloud π
You can use the OpenTelemetry Collector to send traces from Ruby applications to Splunk APM.
Prerequisities π
Before starting, make sure youβve installed the following components:
Bundler version 2.4 or higher
Ruby version 3.0 or higher
Check that youβre using supported libraries and frameworks. For a list of supported libraries, see https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation.
Additionally, you need to install the Splunk Distribution of OpenTelemetry Collector. The following distributions are available:
After installing the Collector, make sure that you have an instance of the Collector running in your environment.
Instrument your application π
To instrument your Ruby application, follow these steps:
Install the
opentelemetry-sdk
andopentelemetry-instrumentation-all
packages:bundle add opentelemetry-sdk opentelemetry-instrumentation-all
In your project directory, create a file called opentelemetry.rb in config/initializers/ with the following code:
require 'opentelemetry/sdk' require 'opentelemetry/instrumentation/all' OpenTelemetry::SDK.configure do |c| c.use_all() # activates all instrumentation end
Run the instrumented application.
Send data directly to Splunk Observability Cloud π
By default, all data goes to the local instance of the Splunk Distribution of OpenTelemetry Collector.
If you need to send data directly to Splunk Observability Cloud, follow these steps:
Install the OpenTelemetry exporter package using the following command:
gem install opentelemetry-exporter-otlp
Edit the config/exporters/opentelemetry.rb file to include the OpenTelemetry exporter package.
require 'opentelemetry/sdk' require 'opentelemetry/instrumentation/all' require 'opentelemetry-exporter-otlp' OpenTelemetry::SDK.configure do |c| c.use_all() # activates all instrumentation end
Set the endpoint to Splunk Observability Cloud and send data using the grpc protocol. Use the following commands:
export OTEL_EXPORTER_OTLP_ENDPOINT="http://ingest.<realm>.signalfx.com" export OTEL_EXPORTER_OTLP_PROTOCOL="grpc" export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sf-token=<access_token>"
Replace
<realm>
with your Splunk Observability Cloud realm and<access-token>
with your Splunk Observability Cloud access token with ingest permissions.To obtain an access token, see Retrieve and manage user API access tokens using Splunk Observability Cloud.
To find your Splunk realm, see Note about realms.
Restart your application.
Learn more π
For example configurations, see https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples.