Instrument your Ruby application for Splunk Observability Cloud π
The Ruby agent from the Splunk Distribution of OpenTelemetry Ruby can automatically instrument your Ruby application by dynamically patching supported libraries.
To get started, use the guided setup or follow the instructions manually.
Generate customized instructions using the guided setup π
To generate all the basic installation commands for your environment and application, use the Ruby guided setup. To access the Ruby guided setup:
Log in to Splunk Observability Cloud.
Open the Ruby guided setup . Optionally, you can navigate to the guided setup on your own:
In the navigation menu, select
.Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.
In the integration filter menu, select By Product.
Select the APM product.
Select the Ruby tile to open the Ruby guided setup.
Install the Splunk Distribution of OpenTelemetry Ruby manually π
If you donβt use the guided setup, follow these instructions to manually install the Splunk Distribution of OpenTelemetry Ruby:
Install and activate the Ruby agent π
Follow these steps to automatically instrument your application using the Ruby agent:
Check that you meet the requirements. See OpenTelemetry Ruby compatibility and requirements.
Add the following gems to your projectβs Gemfile:
gem "splunk-otel", "~> 1.0" gem "opentelemetry-instrumentation-all", "~> 0.27"
Run
bundle install
to install the gems.Activate the instrumentation by passing
auto_instrument:true
to theconfigure
method ofSplunk::Otel
:require "splunk/otel" require "opentelemetry/instrumentation/all" Splunk::Otel.configure(auto_instrument: true)
Set the
OTEL_SERVICE_NAME
environment variable:export OTEL_SERVICE_NAME=<yourServiceName>
$env:OTEL_SERVICE_NAME=<yourServiceName>
(Optional) Set the endpoint URL if the Splunk OpenTelemetry Collector is running on a different host:
export OTEL_EXPORTER_OTLP_ENDPOINT=<yourCollectorEndpoint>:<yourCollectorPort>
$env:OTEL_EXPORTER_OTLP_ENDPOINT=<yourCollectorEndpoint>:<yourCollectorPort>
(Optional) Set the deployment environment and service version:
export OTEL_RESOURCE_ATTRIBUTES='deployment.environment=<envtype>,service.version=<version>'
$env:OTEL_RESOURCE_ATTRIBUTES='deployment.environment=<envtype>,service.version=<version>'
If no data appears in APM, see Troubleshoot Ruby instrumentation for Splunk Observability Cloud.
If you want to manually install and activate instrumentation libraries, see Manually instrument Ruby applications for Splunk Observability Cloud.
Instrument Ruby on Rails applications π
To instrument a Ruby on Rails application, see Instrument your Rails application.
Activate server timing for RUM π
You can connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data produced by your Ruby application or service. For more information, see Server trace information.
Configure the Ruby agent π
In most cases, the only configuration setting you need to enter is the service name. You can also define other basic settings, like the deployment environment, the service version, and the endpoint, among others.
For advanced configuration of the Ruby agent, like changing trace propagation formats, correlating traces and logs, or configuring server trace data, see Configure the Ruby agent for Splunk Observability Cloud.
Deploy the Ruby agent in Kubernetes π
To deploy the Ruby agent in Kubernetes, configure the Kubernetes Downward API to expose environment variables to Kubernetes resources.
The following example shows how to update a deployment to expose environment variables by adding the agent configuration under the .spec.template.spec.containers.env
section:
apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
app: your-application
template:
spec:
containers:
- name: myapp
env:
- name: SPLUNK_OTEL_AGENT
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://$(SPLUNK_OTEL_AGENT):4318"
- name: OTEL_SERVICE_NAME
value: "<serviceName>"
- name: OTEL_RESOURCE_ATTRIBUTES
value: "deployment.environment=<environmentName>"
Send data directly to Splunk Observability Cloud π
By default, all telemetry is sent to the local instance of the Splunk Distribution of OpenTelemetry Collector.
If you need to send data directly to Splunk Observability Cloud, set the following environment variables:
export SPLUNK_ACCESS_TOKEN=<access_token>
export SPLUNK_REALM=<realm>
$env:SPLUNK_ACCESS_TOKEN=<access_token>
$env:SPLUNK_REALM=<realm>
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.
Note
For more information on the ingest API endpoints, see Send APM traces .
Specify the source host π
To override the host used by the agent, use the environment variable OTEL_RESOURCE_ATTRIBUTES
to set your hostβs name to the desired source:
$env:OTEL_RESOURCE_ATTRIBUTES=host.name=<host_name>
export OTEL_RESOURCE_ATTRIBUTES=host.name=<host_name>
Instrument Lambda functions π
You can instrument AWS Lambda functions using the Splunk OpenTelemetry Lambda Layer. See Instrument your AWS Lambda function for Splunk Observability Cloud for more information.